Fixing an issue with double digit interaction counts
This commit is contained in:
@@ -41,13 +41,13 @@ export default class AICC extends Scorm12API {
|
|||||||
let newChild = super.getChildElement(CMIElement, value, foundFirstIndex);
|
let newChild = super.getChildElement(CMIElement, value, foundFirstIndex);
|
||||||
|
|
||||||
if (!newChild) {
|
if (!newChild) {
|
||||||
if (this.stringMatches(CMIElement, 'cmi\\.evaluation\\.comments\\.\\d')) {
|
if (this.stringMatches(CMIElement, 'cmi\\.evaluation\\.comments\\.\\d+')) {
|
||||||
newChild = new CMIEvaluationCommentsObject();
|
newChild = new CMIEvaluationCommentsObject();
|
||||||
} else if (this.stringMatches(CMIElement,
|
} else if (this.stringMatches(CMIElement,
|
||||||
'cmi\\.student_data\\.tries\\.\\d')) {
|
'cmi\\.student_data\\.tries\\.\\d+')) {
|
||||||
newChild = new CMITriesObject();
|
newChild = new CMITriesObject();
|
||||||
} else if (this.stringMatches(CMIElement,
|
} else if (this.stringMatches(CMIElement,
|
||||||
'cmi\\.student_data\\.attempt_records\\.\\d')) {
|
'cmi\\.student_data\\.attempt_records\\.\\d+')) {
|
||||||
newChild = new CMIAttemptRecordsObject();
|
newChild = new CMIAttemptRecordsObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ export default class BaseAPI {
|
|||||||
} else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
} else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
||||||
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
||||||
} else {
|
} else {
|
||||||
if (this.stringMatches(CMIElement, '\\.correct_responses\\.\\d')) {
|
if (this.stringMatches(CMIElement, '\\.correct_responses\\.\\d+')) {
|
||||||
this.validateCorrectResponse(CMIElement, value);
|
this.validateCorrectResponse(CMIElement, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,16 +171,16 @@ export default class Scorm12API extends BaseAPI {
|
|||||||
getChildElement(CMIElement, value, foundFirstIndex) {
|
getChildElement(CMIElement, value, foundFirstIndex) {
|
||||||
let newChild;
|
let newChild;
|
||||||
|
|
||||||
if (this.stringMatches(CMIElement, 'cmi\\.objectives\\.\\d')) {
|
if (this.stringMatches(CMIElement, 'cmi\\.objectives\\.\\d+')) {
|
||||||
newChild = new CMIObjectivesObject();
|
newChild = new CMIObjectivesObject();
|
||||||
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
||||||
'cmi\\.interactions\\.\\d\\.correct_responses\\.\\d')) {
|
'cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+')) {
|
||||||
newChild = new CMIInteractionsCorrectResponsesObject();
|
newChild = new CMIInteractionsCorrectResponsesObject();
|
||||||
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
||||||
'cmi\\.interactions\\.\\d\\.objectives\\.\\d')) {
|
'cmi\\.interactions\\.\\d+\\.objectives\\.\\d+')) {
|
||||||
newChild = new CMIInteractionsObjectivesObject();
|
newChild = new CMIInteractionsObjectivesObject();
|
||||||
} else if (!foundFirstIndex &&
|
} else if (!foundFirstIndex &&
|
||||||
this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d')) {
|
this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d+')) {
|
||||||
newChild = new CMIInteractionsObject();
|
newChild = new CMIInteractionsObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,10 +187,10 @@ export default class Scorm2004API extends BaseAPI {
|
|||||||
getChildElement(CMIElement, value, foundFirstIndex) {
|
getChildElement(CMIElement, value, foundFirstIndex) {
|
||||||
let newChild;
|
let newChild;
|
||||||
|
|
||||||
if (this.stringMatches(CMIElement, 'cmi\\.objectives\\.\\d')) {
|
if (this.stringMatches(CMIElement, 'cmi\\.objectives\\.\\d+')) {
|
||||||
newChild = new CMIObjectivesObject();
|
newChild = new CMIObjectivesObject();
|
||||||
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
||||||
'cmi\\.interactions\\.\\d\\.correct_responses\\.\\d')) {
|
'cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+')) {
|
||||||
const parts = CMIElement.split('.');
|
const parts = CMIElement.split('.');
|
||||||
const index = Number(parts[2]);
|
const index = Number(parts[2]);
|
||||||
const interaction = this.cmi.interactions.childArray[index];
|
const interaction = this.cmi.interactions.childArray[index];
|
||||||
@@ -233,16 +233,16 @@ export default class Scorm2004API extends BaseAPI {
|
|||||||
newChild = new CMIInteractionsCorrectResponsesObject();
|
newChild = new CMIInteractionsCorrectResponsesObject();
|
||||||
}
|
}
|
||||||
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
||||||
'cmi\\.interactions\\.\\d\\.objectives\\.\\d')) {
|
'cmi\\.interactions\\.\\d+\\.objectives\\.\\d+')) {
|
||||||
newChild = new CMIInteractionsObjectivesObject();
|
newChild = new CMIInteractionsObjectivesObject();
|
||||||
} else if (!foundFirstIndex &&
|
} else if (!foundFirstIndex &&
|
||||||
this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d')) {
|
this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d+')) {
|
||||||
newChild = new CMIInteractionsObject();
|
newChild = new CMIInteractionsObject();
|
||||||
} else if (this.stringMatches(CMIElement,
|
} else if (this.stringMatches(CMIElement,
|
||||||
'cmi\\.comments_from_learner\\.\\d')) {
|
'cmi\\.comments_from_learner\\.\\d+')) {
|
||||||
newChild = new CMICommentsObject();
|
newChild = new CMICommentsObject();
|
||||||
} else if (this.stringMatches(CMIElement,
|
} else if (this.stringMatches(CMIElement,
|
||||||
'cmi\\.comments_from_lms\\.\\d')) {
|
'cmi\\.comments_from_lms\\.\\d+')) {
|
||||||
newChild = new CMICommentsObject(true);
|
newChild = new CMICommentsObject(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,7 +282,12 @@ describe('SCORM 1.2 API Tests', () => {
|
|||||||
});
|
});
|
||||||
h.checkLMSSetValue({
|
h.checkLMSSetValue({
|
||||||
api: apiInitialized(),
|
api: apiInitialized(),
|
||||||
fieldName: 'cmi.interactions.0.correct_responses.0.pattern',
|
fieldName: 'cmi.interactions.0.objectives.0.id',
|
||||||
|
valueToTest: 'AAA',
|
||||||
|
});
|
||||||
|
h.checkLMSSetValue({
|
||||||
|
api: apiInitialized(),
|
||||||
|
fieldName: 'cmi.interactions.10.correct_responses.0.pattern',
|
||||||
valueToTest: 't',
|
valueToTest: 't',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -305,6 +305,15 @@ describe('SCORM 2004 API Tests', () => {
|
|||||||
String(scorm2004API.lmsGetLastError())
|
String(scorm2004API.lmsGetLastError())
|
||||||
).to.equal(String(0));
|
).to.equal(String(0));
|
||||||
});
|
});
|
||||||
|
it('should allow cmi.interactions.10.correct_responses.0.pattern to be set - T/F',
|
||||||
|
() => {
|
||||||
|
const scorm2004API = apiInitialized();
|
||||||
|
scorm2004API.setCMIValue('cmi.interactions.0.type', 'true-false');
|
||||||
|
scorm2004API.setCMIValue('cmi.interactions.0.correct_responses.0.pattern', 'true');
|
||||||
|
expect(
|
||||||
|
String(scorm2004API.lmsGetLastError())
|
||||||
|
).to.equal(String(0));
|
||||||
|
});
|
||||||
it('should allow cmi.interactions.0.correct_responses.0.pattern to be set - choice',
|
it('should allow cmi.interactions.0.correct_responses.0.pattern to be set - choice',
|
||||||
() => {
|
() => {
|
||||||
const scorm2004API = apiInitialized();
|
const scorm2004API = apiInitialized();
|
||||||
|
|||||||
Reference in New Issue
Block a user