From dc4608fca4220ca0a53998446e90cfa40161001c Mon Sep 17 00:00:00 2001 From: Samson Akol Date: Tue, 22 Aug 2023 14:44:35 +0300 Subject: [PATCH] Fixes incorrect value for Practice quiz --- .../frontend/channelEdit/utils.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/utils.js b/contentcuration/contentcuration/frontend/channelEdit/utils.js index 97dd9d4713..5e7b868ca9 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/utils.js +++ b/contentcuration/contentcuration/frontend/channelEdit/utils.js @@ -6,6 +6,7 @@ import { metadataStrings, constantStrings } from 'shared/mixins'; import { AssessmentItemTypes, CompletionCriteriaModels, + ContentModalities, SHORT_LONG_ACTIVITY_MIDPOINT, CompletionDropdownMap, } from 'shared/constants'; @@ -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, }; @@ -323,11 +326,11 @@ export function getCompletionCriteriaLabels(node = {}, files = []) { if (!node && !files) { return; } - const { completionModel, completionThreshold, masteryModel, + modality, suggestedDuration, } = getCompletionDataFromNode(node); @@ -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); }