diff --git a/src/addons/mod/scorm/classes/data-model-12.ts b/src/addons/mod/scorm/classes/data-model-12.ts index 97268ff4d..13d6121b0 100644 --- a/src/addons/mod/scorm/classes/data-model-12.ts +++ b/src/addons/mod/scorm/classes/data-model-12.ts @@ -25,8 +25,8 @@ import { } from '../services/scorm'; // Standard Data Type Definition. -const CMI_STRING_256 = '^[\\u0000-\\uFFFF]{0,64000}$'; -const CMI_STRING_4096 = '^[\\u0000-\\uFFFF]{0,64000}$'; +let CMI_STRING_256 = '^[\\u0000-\\uFFFF]{0,255}$'; +let CMI_STRING_4096 = '^[\\u0000-\\uFFFF]{0,4096}$'; const CMI_TIME = '^([0-2]{1}[0-9]{1}):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})(.[0-9]{1,2})?$'; const CMI_TIMESPAN = '^([0-9]{2,4}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$'; const CMI_INTEGER = '^\\d+$'; // eslint-disable-line @typescript-eslint/no-unused-vars @@ -255,6 +255,11 @@ export class AddonModScormDataModel12 { * @param userData The user default data. */ protected init(userData: AddonModScormUserDataMap): void { + if (!this.scorm.scormStandard) { + CMI_STRING_256 = '^[\\u0000-\\uFFFF]{0,64000}$'; + CMI_STRING_4096 = CMI_STRING_256; + } + // Prepare the definition array containing the default values. for (const scoId in userData) { const sco = userData[scoId]; diff --git a/src/addons/mod/scorm/services/scorm.ts b/src/addons/mod/scorm/services/scorm.ts index 93e79b536..8be00d55d 100644 --- a/src/addons/mod/scorm/services/scorm.ts +++ b/src/addons/mod/scorm/services/scorm.ts @@ -1124,6 +1124,12 @@ export class AddonModScormProvider { currentScorm.warningMessage = warning?.message; } + const scormOptions = CoreUtils.objectToKeyValueMap(response.options, 'name', 'value'); + + if (scormOptions.scormstandard) { + currentScorm.scormStandard = Number(scormOptions.scormstandard); + } + currentScorm.moduleurl = options.moduleUrl; return currentScorm; @@ -1865,10 +1871,19 @@ export type AddonModScormGetScormsByCoursesWSParams = { * Data returned by mod_scorm_get_scorms_by_courses WS. */ export type AddonModScormGetScormsByCoursesWSResponse = { + options: AddonModScormOptions[]; scorms: AddonModScormScormWSData[]; warnings?: CoreWSExternalWarning[]; }; +/** + * Scorm options returned by mod_scorm_get_scorms_by_courses WS. + */ +export type AddonModScormOptions = { + name: string; + value: string; +}; + /** * Scorm data returned by mod_scorm_get_scorms_by_courses WS. */ @@ -1931,6 +1946,7 @@ export type AddonModScormScormWSData = { export type AddonModScormScorm = AddonModScormScormWSData & { warningMessage?: string; moduleurl?: string; + scormStandard?: number; }; /**