From 7dcbe6a9833a6ab7a2be6f850a3adfa0fe8b9153 Mon Sep 17 00:00:00 2001 From: Christian Lawson-Perfect Date: Mon, 5 Feb 2018 15:09:27 +0000 Subject: [PATCH] MDL-61355 SCORM: fix correct_response prefix check The regexes to detect the optional prefixes at the start of some interaction types are constructed to optionally match the prefix, so we need to ensure that the matched group is really there when trying to strip it from the given value in CRCheckValueNodes. also remove "check for prefix" from CRcheckValueNodes prefixes on correct responses patterns are removed in the section above by CRremovePrefixes, so this block was redundant. The `.pre` property for each correct_response is not used anywhere else, so this removes their definitions too. --- mod/scorm/datamodels/scorm_13.js | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/mod/scorm/datamodels/scorm_13.js b/mod/scorm/datamodels/scorm_13.js index e3b02a4c106..ac520e9f456 100644 --- a/mod/scorm/datamodels/scorm_13.js +++ b/mod/scorm/datamodels/scorm_13.js @@ -120,31 +120,28 @@ function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scorm } var correct_responses = { - 'true-false':{'pre':'', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':false, + 'true-false':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':false, 'format':'^true$|^false$', 'limit':1}, - 'choice':{'pre':'', 'max':36, 'delimiter':'[,]', 'unique':true, 'duplicate':false, + 'choice':{'max':36, 'delimiter':'[,]', 'unique':true, 'duplicate':false, 'format':CMIShortIdentifier}, -// 'fill-in':{'pre':'^(((\{case_matters=(true|false)\})(\{order_matters=(true|false)\})?)|((\{order_matters=(true|false)\})(\{case_matters=(true|false)\})?))(.*?)$', - 'fill-in':{'pre':'', - 'max':10, 'delimiter':'[,]', 'unique':false, 'duplicate':false, + 'fill-in':{'max':10, 'delimiter':'[,]', 'unique':false, 'duplicate':false, 'format':CMILangString250cr}, - 'long-fill-in':{'pre':'^(\{case_matters=(true|false)\})?', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':true, + 'long-fill-in':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':true, 'format':CMILangString4000}, - 'matching':{'pre':'', 'max':36, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false, + 'matching':{'max':36, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false, 'format':CMIShortIdentifier, 'format2':CMIShortIdentifier}, - 'performance':{'pre':'^(\{order_matters=(true|false)\})?', - 'max':250, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false, + 'performance':{'max':250, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false, 'format':'^$|' + CMIShortIdentifier, 'format2':CMIDecimal + '|^$|' + CMIShortIdentifier}, - 'sequencing':{'pre':'', 'max':36, 'delimiter':'[,]', 'unique':false, 'duplicate':false, + 'sequencing':{'max':36, 'delimiter':'[,]', 'unique':false, 'duplicate':false, 'format':CMIShortIdentifier}, - 'likert':{'pre':'', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':false, + 'likert':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':false, 'format':CMIShortIdentifier, 'limit':1}, - 'numeric':{'pre':'', 'max':2, 'delimiter':'[:]', 'unique':false, 'duplicate':false, + 'numeric':{'max':2, 'delimiter':'[:]', 'unique':false, 'duplicate':false, 'format':CMIDecimal, 'limit':1}, - 'other':{'pre':'', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':false, + 'other':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':false, 'format':CMIString4000, 'limit':1} } @@ -862,14 +859,6 @@ function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scorm nodes[i] = result.node; } - // check for prefix on each node - if (correct_responses[interactiontype].pre != '') { - matches = nodes[i].match(correct_responses[interactiontype].pre); - if (matches != null) { - nodes[i] = nodes[i].substr(matches[1].length); - } - } - if (correct_responses[interactiontype].delimiter2 != undefined) { values = nodes[i].split(correct_responses[interactiontype].delimiter2); if (values.length == 2) {