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.
This commit is contained in:
committed by
Dan Marsden
parent
f61ee4e857
commit
7dcbe6a983
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user