* feat: Course outline Top level page (#36) * feat: [2u-259] add components * feat: [2u-259] fix sidebar * feat: [2u-259] add tests, fix links * feat: [2u-259] fix messages * feat: [2u-159] fix reducer and sidebar * feat: [2u-259] fix reducer * feat: [2u-259] remove warning from selectors * feat: [2u-259] remove indents --------- Co-authored-by: Vladislav Keblysh <vladislavkeblysh@Vladislavs-MacBook-Pro.local> feat: Course outline Status Bar (#50) * feat: [2u-259] add components * feat: [2u-259] fix sidebar * feat: [2u-259] add tests, fix links * feat: [2u-259] fix messages * feat: [2u-159] fix reducer and sidebar * feat: add checklist * feat: [2u-259] fix reducer * feat: [2u-259] remove warning from selectors * feat: [2u-259] remove indents * feat: [2u-259] add api, enable modal * feat: [2u-259] add tests * feat: [2u-259] add translates * feat: [2u-271] fix transalates * feat: [2u-281] fix isQuery pending, utils, hooks * feat: [2u-281] fix useScrollToHashElement * feat: [2u-271] fix imports --------- Co-authored-by: Vladislav Keblysh <vladislavkeblysh@Vladislavs-MacBook-Pro.local> feat: Course Outline Reindex (#55) * feat: [2u-277] add alerts * feat: [2u-277] add translates * feat: [2u-277] fix tests * fix: [2u-277] fix slice and hook --------- Co-authored-by: Vladislav Keblysh <vladislavkeblysh@Vladislavs-MacBook-Pro.local> fix: Course outline tests (#56) * fix: fixed course outline status bar tests * fix: fixed course outline status bar tests * fix: fixed course outline enable highlights modal tests * fix: enable modal tests fix: increase code coverage on the page * refactor: improve course outline page feat: lms live link chore: update outline link fix: course outline link refactor: remove unnecessary css and rename test file refactor: remove unnecessary css from outlineSidebar test: make use of message variable instead of hardcoded text refactor: remove unnecessary h5 class test: use test id for detecting component refactor: update course outline url and some default messages --------- Co-authored-by: vladislavkeblysh <138868841+vladislavkeblysh@users.noreply.github.com>
80 lines
2.5 KiB
JavaScript
80 lines
2.5 KiB
JavaScript
import { CHECKLIST_FILTERS } from '../constants';
|
|
import * as healthValidators from './courseChecklistValidators';
|
|
|
|
/**
|
|
* The utilities are taken from the https://github.com/openedx/studio-frontend repository.
|
|
* Perform a minor refactoring of the functions while preserving their original functionality.
|
|
*/
|
|
const getChecklistValidatedValue = (data, id) => {
|
|
const {
|
|
updates,
|
|
grades,
|
|
certificates,
|
|
dates,
|
|
assignments,
|
|
videos,
|
|
subsections,
|
|
sections,
|
|
units,
|
|
proctoring,
|
|
} = data;
|
|
|
|
switch (id) {
|
|
case 'welcomeMessage':
|
|
return healthValidators.hasWelcomeMessage(updates);
|
|
case 'gradingPolicy':
|
|
return healthValidators.hasGradingPolicy(grades);
|
|
case 'certificate':
|
|
return healthValidators.hasCertificate(certificates);
|
|
case 'courseDates':
|
|
return healthValidators.hasDates(dates);
|
|
case 'assignmentDeadlines':
|
|
return healthValidators.hasAssignmentDeadlines(assignments, dates);
|
|
case 'videoDuration':
|
|
return healthValidators.hasShortVideoDuration(videos);
|
|
case 'mobileFriendlyVideo':
|
|
return healthValidators.hasMobileFriendlyVideos(videos);
|
|
case 'diverseSequences':
|
|
return healthValidators.hasDiverseSequences(subsections);
|
|
case 'weeklyHighlights':
|
|
return healthValidators.hasWeeklyHighlights(sections);
|
|
case 'unitDepth':
|
|
return healthValidators.hasShortUnitDepth(units);
|
|
case 'proctoringEmail':
|
|
return healthValidators.hasProctoringEscalationEmail(proctoring);
|
|
default:
|
|
throw new Error(`Unknown validator ${id}.`);
|
|
}
|
|
};
|
|
|
|
const getChecklistValues = ({
|
|
checklist,
|
|
isSelfPaced,
|
|
hasCertificatesEnabled,
|
|
hasHighlightsEnabled,
|
|
needsProctoringEscalationEmail,
|
|
}) => {
|
|
let filteredCheckList;
|
|
|
|
if (isSelfPaced) {
|
|
filteredCheckList = checklist.filter(({ pacingTypeFilter }) => pacingTypeFilter === CHECKLIST_FILTERS.ALL
|
|
|| pacingTypeFilter === CHECKLIST_FILTERS.SELF_PACED);
|
|
} else {
|
|
filteredCheckList = checklist.filter(({ pacingTypeFilter }) => pacingTypeFilter === CHECKLIST_FILTERS.ALL
|
|
|| pacingTypeFilter === CHECKLIST_FILTERS.INSTRUCTOR_PACED);
|
|
}
|
|
|
|
filteredCheckList = filteredCheckList.filter(({ id }) => id !== 'certificate'
|
|
|| hasCertificatesEnabled);
|
|
|
|
filteredCheckList = filteredCheckList.filter(({ id }) => id !== 'weeklyHighlights'
|
|
|| hasHighlightsEnabled);
|
|
|
|
filteredCheckList = filteredCheckList.filter(({ id }) => id !== 'proctoringEmail'
|
|
|| needsProctoringEscalationEmail);
|
|
|
|
return filteredCheckList;
|
|
};
|
|
|
|
export { getChecklistValues, getChecklistValidatedValue };
|