diff --git a/src/course-home/data/api.js b/src/course-home/data/api.js index 6ffa9b468d..389242aa98 100644 --- a/src/course-home/data/api.js +++ b/src/course-home/data/api.js @@ -3,7 +3,6 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { logInfo } from '@edx/frontend-platform/logging'; import { appendBrowserTimezoneToUrl } from '../../utils'; - const calculateAssignmentTypeGrades = (points, assignmentWeight, numDroppable) => { let dropCount = numDroppable; // Drop the lowest grades @@ -158,25 +157,26 @@ export function normalizeOutlineBlocks(courseId, blocks) { showLink: !!block.legacy_web_url, title: block.display_name, unitIds: block.children || [], - }; + }; break; case 'vertical': - models.units[block.id] = { - complete: block.complete, - description: block.description, - due: block.due, - effortActivities: block.effort_activities, - effortTime: block.effort_time, - icon: block.icon, - id: block.id, - legacyWebUrl: block.legacy_web_url, - // The presence of an legacy URL for the sequence indicates that we want this - // sequence to be a clickable link in the outline (even though, if the new - // courseware experience is active, we will ignore `legacyWebUrl` and build a - // link to the MFE ourselves). - showLink: !!block.legacy_web_url, - title: block.display_name, - } + models.units[block.id] = { + complete: block.complete, + description: block.description, + due: block.due, + effortActivities: block.effort_activities, + effortTime: block.effort_time, + icon: block.icon, + id: block.id, + legacyWebUrl: block.legacy_web_url, + // The presence of an legacy URL for the sequence indicates that we want this + // sequence to be a clickable link in the outline (even though, if the new + // courseware experience is active, we will ignore `legacyWebUrl` and build a + // link to the MFE ourselves). + showLink: !!block.legacy_web_url, + title: block.display_name, + }; + break; default: logInfo(`Unexpected course block type: ${block.type} with ID ${block.id}. Expected block types are course, chapter, and sequential.`); @@ -377,9 +377,6 @@ export function getTimeOffsetMillis(headerDate, requestTime, responseTime) { return timeOffsetMillis; } - - - export async function getOutlineTabData(courseId) { const url = `${getConfig().LMS_BASE_URL}/api/course_home/outline/${courseId}`; let { tabData } = {}; diff --git a/src/course-home/outline-tab/Section.jsx b/src/course-home/outline-tab/Section.jsx index f606cf6110..2cc074d7cb 100644 --- a/src/course-home/outline-tab/Section.jsx +++ b/src/course-home/outline-tab/Section.jsx @@ -30,7 +30,6 @@ function Section({ }, } = useModel('outline', courseId); - const [open, setOpen] = useState(defaultOpen); useEffect(() => { @@ -97,13 +96,13 @@ function Section({ )} >
    - {sequenceIds.map((sequenceId, index) => ( + {sequenceIds.map((sequenceId) => ( ))} diff --git a/src/course-home/outline-tab/SequenceLink.jsx b/src/course-home/outline-tab/SequenceLink.jsx index 7e8aa04f43..ad0d6b7880 100644 --- a/src/course-home/outline-tab/SequenceLink.jsx +++ b/src/course-home/outline-tab/SequenceLink.jsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { Link } from 'react-router-dom'; -import { Collapsible, Hyperlink, IconButton } from '@edx/paragon'; +import { Collapsible, IconButton } from '@edx/paragon'; import { FormattedMessage, FormattedTime, @@ -14,15 +13,12 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import UnitLink from './UnitLink'; - import EffortEstimate from '../../shared/effort-estimate'; import { useModel } from '../../generic/model-store'; import genericMessages from '../../generic/messages'; import messages from './messages'; - - function SequenceLink({ id, intl, @@ -37,7 +33,7 @@ function SequenceLink({ due, // legacyWebUrl, // showLink, - title, + title, unitIds, } = sequence; const { @@ -56,15 +52,12 @@ function SequenceLink({ const timezoneFormatArgs = userTimezone ? { timeZone: userTimezone } : {}; - const [open, setOpen] = useState(defaultOpen); - + useEffect(() => { setOpen(expand); }, [expand]); - - // canLoadCourseware is true if the Courseware MFE is enabled, false otherwise // const coursewareUrl = ( // canLoadCourseware @@ -74,8 +67,8 @@ function SequenceLink({ // const displayTitle = showLink ? coursewareUrl : title; const sequenceTitle = (
    - { unitIds.length > 0 ? ( -
    + {unitIds.length > 0 ? ( +
    {complete ? ( , {intl.formatMessage(complete ? messages.completedAssignment : messages.incompleteAssignment)} - +
    {due && ( -
    - - - ), - description: description || '', - }} - /> - -
    - )} -
    - ) : ( -
    -
    -
    -
    - {title} (No Units) -
    + )} +
    + ) : ( +
    +
    +
    +
    + {title} (No Units)
    - )} +
    + )}
    - ) + ); return (
  1. - { setOpen(true); }} size="sm" /> - )} + )} iconWhenOpen={( { setOpen(false); }} size="sm" /> - )} - > -
      - {unitIds.map((unitId, index) => ( - - ))} -
    -
    + )} + > +
      + {unitIds.map((unitId, index) => ( + + ))} +
    +
  2. ); } diff --git a/src/course-home/outline-tab/UnitLink.jsx b/src/course-home/outline-tab/UnitLink.jsx index 9c5f289f01..709aed625c 100644 --- a/src/course-home/outline-tab/UnitLink.jsx +++ b/src/course-home/outline-tab/UnitLink.jsx @@ -8,7 +8,7 @@ import { FormattedTime, injectIntl, intlShape, -} from '@edx/frontend-platform/i18n'; +} from '@edx/frontend-platform/i18n'; import { faCheckCircle as fasCheckCircle } from '@fortawesome/free-solid-svg-icons'; import { faCheckCircle as farCheckCircle } from '@fortawesome/free-regular-svg-icons'; @@ -18,7 +18,6 @@ import EffortEstimate from '../../shared/effort-estimate'; import { useModel } from '../../generic/model-store'; import messages from './messages'; - function UnitLink({ id, courseId, @@ -26,7 +25,6 @@ function UnitLink({ first, intl, }) { - const { complete, description, @@ -50,65 +48,65 @@ function UnitLink({ ); const displayTitle = showLink ? coursewareUrl : title; - return ( -
  3. -
    -
    -
    - {complete ? ( -
    -
    - {displayTitle} - - , {intl.formatMessage(complete ? messages.completedAssignment : messages.incompleteAssignment)} - - -
    + return ( +
  4. +
    +
    +
    + {complete ? ( +
    +
    + {displayTitle} + + , {intl.formatMessage(complete ? messages.completedAssignment : messages.incompleteAssignment)} + +
    - {due && ( -
    - - - ), - description: description || '', - }} - /> - -
    - )}
    -
  5. - ) + {due && ( +
    + + + ), + description: description || '', + }} + /> + +
    + )} +
    + + ); } UnitLink.propTypes = { @@ -119,4 +117,4 @@ UnitLink.propTypes = { intl: intlShape.isRequired, }; -export default injectIntl(UnitLink); \ No newline at end of file +export default injectIntl(UnitLink); diff --git a/src/courseware/data/api.js b/src/courseware/data/api.js index 857d83d699..ccbc3d61c3 100644 --- a/src/courseware/data/api.js +++ b/src/courseware/data/api.js @@ -134,7 +134,6 @@ export async function getCourseMetadata(courseId) { return normalizeMetadata(metadata); } - function normalizeSequenceMetadata(sequence) { return { sequence: { @@ -181,7 +180,7 @@ export async function getSequenceMetadata(sequenceId) { .get(`${getConfig().LMS_BASE_URL}/api/courseware/sequence/${sequenceId}`, {}); return normalizeSequenceMetadata(data); -} +} const getSequenceHandlerUrl = (courseId, sequenceId) => `${getConfig().LMS_BASE_URL}/courses/${courseId}/xblock/${sequenceId}/handler`;