Skip to content

Commit

Permalink
Update: Added a new maxCharLimitOverride property to allow override o… (
Browse files Browse the repository at this point in the history
#287)

* Update: Added a new maxCharLimitOverride property to allow override of the hardcoded SCORM default limits

* Better input check

* Fixed typo
  • Loading branch information
cahirodoherty-learningpool authored Aug 23, 2023
1 parent bc76191 commit 68e7064
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 5 additions & 1 deletion js/scorm/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ScormWrapper {
this.finishCalled = false;
this.logger = Logger.getInstance();
this.scorm = pipwerks.SCORM;
this.maxCharLimitOverride = null
/**
* Prevent the Pipwerks SCORM API wrapper's handling of the exit status
*/
Expand Down Expand Up @@ -146,6 +147,9 @@ class ScormWrapper {
if (_.isBoolean(settings._setCompletedWhenFailed)) {
this.setCompletedWhenFailed = settings._setCompletedWhenFailed;
}
if (!_.isNaN(settings._maxCharLimitOverride) && settings._maxCharLimitOverride > 0) {
this.maxCharLimitOverride = settings._maxCharLimitOverride;
}
}

this.logger.debug('ScormWrapper::initialize');
Expand Down Expand Up @@ -679,7 +683,7 @@ class ScormWrapper {

recordInteractionFillIn(id, response, correct, latency, type) {

const maxLength = this.isSCORM2004() ? 250 : 255;
const maxLength = this.maxCharLimitOverride ?? this.isSCORM2004() ? 250 : 255;

if (response.length > maxLength) {
response = response.substr(0, maxLength);
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@
"validators": [],
"help": "If enabled, `cmi.completion_status` will be set to \"completed\" if the assessment is \"failed\". Only valid for SCORM 2004, where the logic for completion and success is separate."
},
"_maxCharLimitOverride": {
"type": "number",
"required": false,
"default": "0",
"title": "Override value for maximum character limit on fill-in type answers",
"inputType": "Number",
"validators": ["number"],
"help": "If your LMS allows it, you may set a value to override the default character limit for fill-in answers (250 for SCORM2004, 255 for SCORM1.2)."
},
"_connectionTest": {
"type": "object",
"required": true,
Expand Down
25 changes: 9 additions & 16 deletions schema/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@
"title": "SCORM version",
"description": "The SCORM standard to use - SCORM 1.2 or SCORM 2004 4th Edition",
"default": "1.2",
"enum": [
"1.2",
"2004"
],
"enum": ["1.2", "2004"],
"_backboneForms": "Select"
},
"_showDebugWindow": {
Expand Down Expand Up @@ -159,24 +156,14 @@
"type": "string",
"title": "Incomplete course exit status",
"default": "auto",
"enum": [
"auto",
"suspend",
"normal",
""
],
"enum": ["auto", "suspend", "normal", ""],
"_backboneForms": "Select"
},
"_exitStateIfComplete": {
"type": "string",
"title": "Complete course exit status",
"default": "auto",
"enum": [
"auto",
"suspend",
"normal",
""
],
"enum": ["auto", "suspend", "normal", ""],
"_backboneForms": "Select"
},
"_setCompletedWhenFailed": {
Expand All @@ -185,6 +172,12 @@
"description": "If enabled, `cmi.completion_status` will be set to \"completed\" if the assessment is \"failed\". Only valid for SCORM 2004, where the logic for completion and success is separate.",
"default": true
},
"_maxCharLimitOverride": {
"type": "number",
"title": "Override value for maximum character limit on fill-in type answers",
"description": "If your LMS allows it, you may set a value to override the default character limit for fill-in answers (250 for SCORM2004, 255 for SCORM1.2).",
"default": 0
},
"_connectionTest": {
"type": "object",
"title": "Connection Test",
Expand Down

0 comments on commit 68e7064

Please sign in to comment.