* 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>
107 lines
2.5 KiB
JavaScript
107 lines
2.5 KiB
JavaScript
/**
|
|
* 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.
|
|
*/
|
|
|
|
export const hasWelcomeMessage = (updates) => updates.hasUpdate;
|
|
|
|
export const hasGradingPolicy = (grades) => {
|
|
// eslint-disable-next-line no-shadow
|
|
const { hasGradingPolicy, sumOfWeights } = grades;
|
|
|
|
return hasGradingPolicy && parseFloat(sumOfWeights.toPrecision(2), 10) === 1.0;
|
|
};
|
|
|
|
export const hasCertificate = (certificates) => {
|
|
// eslint-disable-next-line no-shadow
|
|
const { isActivated, hasCertificate } = certificates;
|
|
|
|
return isActivated && hasCertificate;
|
|
};
|
|
|
|
export const hasDates = (dates) => {
|
|
const { hasStartDate, hasEndDate } = dates;
|
|
|
|
return hasStartDate && hasEndDate;
|
|
};
|
|
|
|
export const hasAssignmentDeadlines = (assignments, dates) => {
|
|
const {
|
|
totalNumber,
|
|
assignmentsWithDatesBeforeStart,
|
|
assignmentsWithDatesAfterEnd,
|
|
assignmentsWithOraDatesBeforeStart,
|
|
assignmentsWithOraDatesAfterEnd,
|
|
} = assignments;
|
|
|
|
if (!hasDates(dates)) {
|
|
return false;
|
|
}
|
|
if (totalNumber === 0) {
|
|
return false;
|
|
}
|
|
if (assignmentsWithDatesBeforeStart.length > 0) {
|
|
return false;
|
|
}
|
|
if (assignmentsWithDatesAfterEnd.length > 0) {
|
|
return false;
|
|
}
|
|
if (assignmentsWithOraDatesBeforeStart.length > 0) {
|
|
return false;
|
|
}
|
|
if (assignmentsWithOraDatesAfterEnd.length > 0) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
export const hasShortVideoDuration = (videos) => {
|
|
const { totalNumber, durations } = videos;
|
|
|
|
if (totalNumber === 0) {
|
|
return true;
|
|
}
|
|
if (totalNumber > 0 && durations.median <= 600) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
export const hasMobileFriendlyVideos = (videos) => {
|
|
const { totalNumber, numMobileEncoded } = videos;
|
|
|
|
if (totalNumber === 0) {
|
|
return true;
|
|
}
|
|
if (totalNumber > 0 && (numMobileEncoded / totalNumber) >= 0.9) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
export const hasDiverseSequences = (subsections) => {
|
|
const { totalVisible, numWithOneBlockType } = subsections;
|
|
|
|
if (totalVisible === 0) {
|
|
return false;
|
|
}
|
|
if (totalVisible > 0) {
|
|
return ((numWithOneBlockType / totalVisible) < 0.2);
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
export const hasWeeklyHighlights = (sections) => {
|
|
const { highlightsActiveForCourse, highlightsEnabled } = sections;
|
|
|
|
return highlightsActiveForCourse && highlightsEnabled;
|
|
};
|
|
|
|
export const hasShortUnitDepth = (units) => units.numBlocks.median <= 3;
|
|
|
|
export const hasProctoringEscalationEmail = (proctoring) => proctoring.hasProctoringEscalationEmail;
|