Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/courseware/course/sidebar/sidebars/course-outline/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,17 @@ export const useCourseOutlineSidebar = () => {

const handleUnitClick = ({ sequenceId, activeUnitId, id }) => {
const logEvent = (eventName, widgetPlacement) => {
const findSequenceByUnitId = () => Object.values(sequences).find(seq => seq.unitIds.includes(activeUnitId));
const findSequenceByUnitId = (searchUnitId) => {
if (!searchUnitId) {
return null;
}
return Object.values(sequences).find(seq => seq.unitIds.includes(searchUnitId));
};
const activeSequence = findSequenceByUnitId(activeUnitId);
const targetSequence = findSequenceByUnitId(id);
if (!activeSequence || !targetSequence) {
return;
}
const payload = {
id: activeUnitId,
current_tab: activeSequence.unitIds.indexOf(activeUnitId) + 1,
Expand All @@ -95,7 +103,9 @@ export const useCourseOutlineSidebar = () => {
};

logEvent('edx.ui.lms.sequence.tab_selected', 'left');
dispatch(checkBlockCompletion(courseId, sequenceId, activeUnitId));
if (activeUnitId) {
dispatch(checkBlockCompletion(courseId, sequenceId, activeUnitId));
}

// Hide the sidebar after selecting a unit on a mobile device.
if (shouldDisplayFullScreen) {
Expand Down
4 changes: 4 additions & 0 deletions src/courseware/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@

export function checkBlockCompletion(courseId, sequenceId, unitId) {
return async (dispatch, getState) => {
if (!unitId) {
return {};
}

Check failure on line 182 in src/courseware/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

Trailing spaces not allowed
const { models } = getState();
if (models.units[unitId]?.complete) {
return {}; // do nothing. Things don't get uncompleted after they are completed.
Expand Down
Loading