Skip to content

Commit

Permalink
Merge pull request #4260 from akolson/quiz-incorrect-completion-value
Browse files Browse the repository at this point in the history
Fixes incorrect value for Practice quiz
  • Loading branch information
marcellamaki authored Aug 29, 2023
2 parents 2f0ac11 + dc4608f commit dc357cc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions contentcuration/contentcuration/frontend/channelEdit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { metadataStrings, constantStrings } from 'shared/mixins';
import {
AssessmentItemTypes,
CompletionCriteriaModels,
ContentModalities,
SHORT_LONG_ACTIVITY_MIDPOINT,
CompletionDropdownMap,
} from 'shared/constants';
Expand Down Expand Up @@ -280,18 +281,20 @@ export function getCompletionDataFromNode(node) {
return;
}

const completionCriteria = node.extra_fields?.options?.completion_criteria
? JSON.parse(JSON.stringify(node.extra_fields?.options?.completion_criteria))
: null;
const extraFields = node?.extra_fields || {};
const options = extraFields?.options || {};
const completionCriteria = options?.completion_criteria || null;
const threshold = completionCriteria?.threshold || generateDefaultThreshold(node);
const model = completionCriteria?.model || defaultCompletionCriteriaModels[node.kind];
const suggestedDurationType = node.extra_fields?.suggested_duration_type;
const modality = options?.modality || null;
const suggestedDurationType = extraFields?.suggested_duration_type;
const suggestedDuration = node.suggested_duration;

return {
completionModel: model,
completionThreshold: threshold,
masteryModel: threshold?.mastery_model,
modality,
suggestedDurationType,
suggestedDuration,
};
Expand Down Expand Up @@ -323,11 +326,11 @@ export function getCompletionCriteriaLabels(node = {}, files = []) {
if (!node && !files) {
return;
}

const {
completionModel,
completionThreshold,
masteryModel,
modality,
suggestedDuration,
} = getCompletionDataFromNode(node);

Expand Down Expand Up @@ -374,6 +377,11 @@ export function getCompletionCriteriaLabels(node = {}, files = []) {
m: completionThreshold.m,
n: completionThreshold.n,
});
} else if (
masteryModel === MasteryModelsNames.DO_ALL &&
modality === ContentModalities.QUIZ
) {
labels.completion = metadataStrings.$tr('practiceQuiz');
} else {
labels.completion = constantStrings.$tr(masteryModel);
}
Expand Down

0 comments on commit dc357cc

Please sign in to comment.