Merge pull request #3765 from alfonso-salces/MOBILE-4191

MOBILE-4191 scorm: Check scormstandard to change CMI_STRING_256
main
Dani Palou 2023-08-01 11:39:48 +02:00 committed by GitHub
commit 5ba622a999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -25,8 +25,8 @@ import {
} from '../services/scorm'; } from '../services/scorm';
// Standard Data Type Definition. // Standard Data Type Definition.
const CMI_STRING_256 = '^[\\u0000-\\uFFFF]{0,64000}$'; let CMI_STRING_256 = '^[\\u0000-\\uFFFF]{0,255}$';
const CMI_STRING_4096 = '^[\\u0000-\\uFFFF]{0,64000}$'; 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_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_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 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. * @param userData The user default data.
*/ */
protected init(userData: AddonModScormUserDataMap): void { 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. // Prepare the definition array containing the default values.
for (const scoId in userData) { for (const scoId in userData) {
const sco = userData[scoId]; const sco = userData[scoId];

View File

@ -1124,6 +1124,12 @@ export class AddonModScormProvider {
currentScorm.warningMessage = warning?.message; currentScorm.warningMessage = warning?.message;
} }
const scormOptions = CoreUtils.objectToKeyValueMap(response.options, 'name', 'value');
if (scormOptions.scormstandard) {
currentScorm.scormStandard = Number(scormOptions.scormstandard);
}
currentScorm.moduleurl = options.moduleUrl; currentScorm.moduleurl = options.moduleUrl;
return currentScorm; return currentScorm;
@ -1865,10 +1871,19 @@ export type AddonModScormGetScormsByCoursesWSParams = {
* Data returned by mod_scorm_get_scorms_by_courses WS. * Data returned by mod_scorm_get_scorms_by_courses WS.
*/ */
export type AddonModScormGetScormsByCoursesWSResponse = { export type AddonModScormGetScormsByCoursesWSResponse = {
options: AddonModScormOptions[];
scorms: AddonModScormScormWSData[]; scorms: AddonModScormScormWSData[];
warnings?: CoreWSExternalWarning[]; 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. * Scorm data returned by mod_scorm_get_scorms_by_courses WS.
*/ */
@ -1931,6 +1946,7 @@ export type AddonModScormScormWSData = {
export type AddonModScormScorm = AddonModScormScormWSData & { export type AddonModScormScorm = AddonModScormScormWSData & {
warningMessage?: string; warningMessage?: string;
moduleurl?: string; moduleurl?: string;
scormStandard?: number;
}; };
/** /**