mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-37401 mod_scorm : autocommit for scorm
This commit is contained in:
parent
14cb870f46
commit
6a6709ec51
@ -16,7 +16,7 @@
|
||||
//
|
||||
// SCORM 1.2 API Implementation
|
||||
//
|
||||
function AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, viewmode, currentorg, sesskey, cmid) {
|
||||
function AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, viewmode, currentorg, sesskey, cmid, autocommit) {
|
||||
|
||||
var prerequrl = cfgwwwroot + "/mod/scorm/prereqs.php?a="+scormid+"&scoid="+scoid+"&attempt="+attempt+"&mode="+viewmode+"¤torg="+currentorg+"&sesskey="+sesskey;
|
||||
var datamodelurl = cfgwwwroot + "/mod/scorm/datamodel.php";
|
||||
@ -336,6 +336,9 @@ function AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, vi
|
||||
}
|
||||
//Store data
|
||||
if (errorCode == "0") {
|
||||
if (autocommit && !(AICCapi.timeout)) {
|
||||
AICCapi.timeout = Y.later(60000, API, 'LMSCommit', [""], false);
|
||||
}
|
||||
if ((typeof eval('datamodel["'+scoid+'"]["'+elementmodel+'"].range')) != "undefined") {
|
||||
range = eval('datamodel["'+scoid+'"]["'+elementmodel+'"].range');
|
||||
ranges = range.split('#');
|
||||
@ -376,6 +379,10 @@ function AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, vi
|
||||
}
|
||||
|
||||
function LMSCommit (param) {
|
||||
if (AICCapi.timeout) {
|
||||
AICCapi.timeout.cancel();
|
||||
AICCapi.timeout = null;
|
||||
}
|
||||
errorCode = "0";
|
||||
if (param == "") {
|
||||
if (Initialized) {
|
||||
@ -544,6 +551,6 @@ function AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, vi
|
||||
|
||||
M.scorm_api = {};
|
||||
|
||||
M.scorm_api.init = function(Y, def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, viewmode, currentorg, sesskey, cmid) {
|
||||
window.API = new AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, viewmode, currentorg, sesskey, cmid);
|
||||
M.scorm_api.init = function(Y, def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, viewmode, currentorg, sesskey, cmid, autocommit) {
|
||||
window.API = new AICCapi(def, cmiobj, scormauto, cfgwwwroot, scormid, scoid, attempt, viewmode, currentorg, sesskey, cmid, autocommit);
|
||||
}
|
||||
|
@ -62,5 +62,5 @@ if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sort
|
||||
}
|
||||
|
||||
|
||||
$PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $scorm->auto, $CFG->wwwroot, $scorm->id, $scoid, $attempt,
|
||||
$mode, $currentorg, sesskey(), $id));
|
||||
$PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $scorm->auto, $CFG->wwwroot, $scorm->id, $scoid,
|
||||
$attempt, $mode, $currentorg, sesskey(), $id, $scorm->autocommit));
|
||||
|
@ -16,7 +16,7 @@
|
||||
//
|
||||
// SCORM 1.2 API Implementation
|
||||
//
|
||||
function SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg) {
|
||||
function SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit) {
|
||||
|
||||
var prerequrl = cfgwwwroot + "/mod/scorm/prereqs.php?a="+scormid+"&scoid="+scoid+"&attempt="+attempt+"&mode="+viewmode+"¤torg="+currentorg+"&sesskey="+sesskey;
|
||||
var datamodelurl = cfgwwwroot + "/mod/scorm/datamodel.php";
|
||||
@ -353,6 +353,9 @@ function SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebu
|
||||
}
|
||||
//Store data
|
||||
if (errorCode == "0") {
|
||||
if (autocommit && !(SCORMapi1_2.timeout)) {
|
||||
SCORMapi1_2.timeout = Y.later(60000, API, 'LMSCommit', [""], false);
|
||||
}
|
||||
if ((typeof eval('datamodel["'+scoid+'"]["'+elementmodel+'"].range')) != "undefined") {
|
||||
range = eval('datamodel["'+scoid+'"]["'+elementmodel+'"].range');
|
||||
ranges = range.split('#');
|
||||
@ -402,6 +405,10 @@ function SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebu
|
||||
}
|
||||
|
||||
function LMSCommit (param) {
|
||||
if (SCORMapi1_2.timeout) {
|
||||
SCORMapi1_2.timeout.cancel();
|
||||
SCORMapi1_2.timeout = null;
|
||||
}
|
||||
errorCode = "0";
|
||||
if (param == "") {
|
||||
if (Initialized) {
|
||||
@ -653,6 +660,6 @@ function SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebu
|
||||
|
||||
M.scorm_api = {};
|
||||
|
||||
M.scorm_api.init = function(Y, def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg) {
|
||||
window.API = new SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg);
|
||||
M.scorm_api.init = function(Y, def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit) {
|
||||
window.API = new SCORMapi1_2(def, cmiobj, cmiint, cmistring256, cmistring4096, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ if (intval(get_config("scorm", "scorm12standard"))) {
|
||||
|
||||
$PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $cmiint, $cmistring256, $cmistring4096,
|
||||
scorm_debugging($scorm), $scorm->auto, $scorm->id, $CFG->wwwroot,
|
||||
sesskey(), $scoid, $attempt, $mode, $id, $currentorg));
|
||||
sesskey(), $scoid, $attempt, $mode, $id, $currentorg, $scorm->autocommit));
|
||||
|
||||
// pull in the debugging utilities
|
||||
if (scorm_debugging($scorm)) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
//
|
||||
// SCORM 1.3 API Implementation
|
||||
//
|
||||
function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg) {
|
||||
function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit) {
|
||||
|
||||
var prerequrl = cfgwwwroot + "/mod/scorm/prereqs.php?a="+scormid+"&scoid="+scoid+"&attempt="+attempt+"&mode="+viewmode+"¤torg="+currentorg+"&sesskey="+sesskey;
|
||||
var datamodelurl = cfgwwwroot + "/mod/scorm/datamodel.php";
|
||||
@ -744,7 +744,9 @@ function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scorm
|
||||
}
|
||||
//Store data
|
||||
if (errorCode == "0") {
|
||||
|
||||
if (autocommit && !(SCORMapi1_3.timeout)) {
|
||||
SCORMapi1_3.timeout = Y.later(60000, API_1484_11, 'Commit', [""], false);
|
||||
}
|
||||
if ((typeof eval('datamodel["'+scoid+'"]["'+elementmodel+'"].range')) != "undefined") {
|
||||
range = eval('datamodel["'+scoid+'"]["'+elementmodel+'"].range');
|
||||
ranges = range.split('#');
|
||||
@ -912,6 +914,10 @@ function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scorm
|
||||
|
||||
|
||||
function Commit (param) {
|
||||
if (SCORMapi1_3.timeout) {
|
||||
SCORMapi1_3.timeout.cancel();
|
||||
SCORMapi1_3.timeout = null;
|
||||
}
|
||||
errorCode = "0";
|
||||
if (param == "") {
|
||||
if ((Initialized) && (!Terminated)) {
|
||||
@ -1244,6 +1250,6 @@ function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scorm
|
||||
|
||||
M.scorm_api = {};
|
||||
|
||||
M.scorm_api.init = function(Y, def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg) {
|
||||
window.API_1484_11 = new SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg);
|
||||
M.scorm_api.init = function(Y, def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit) {
|
||||
window.API_1484_11 = new SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit);
|
||||
}
|
||||
|
@ -47,10 +47,9 @@ if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sort
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $cmiint, $cmicommentsuser, $cmicommentslms,
|
||||
scorm_debugging($scorm), $scorm->auto, $scorm->id, $CFG->wwwroot,
|
||||
sesskey(), $scoid, $attempt, $mode, $id, $currentorg));
|
||||
sesskey(), $scoid, $attempt, $mode, $id, $currentorg, $scorm->autocommit));
|
||||
|
||||
|
||||
// Pull in the debugging utilities.
|
||||
|
3
mod/scorm/db/install.xml
Normal file → Executable file
3
mod/scorm/db/install.xml
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/scorm/db" VERSION="20140317" COMMENT="XMLDB file for Moodle mod/scorm"
|
||||
<XMLDB PATH="mod/scorm/db" VERSION="20140725" COMMENT="XMLDB file for Moodle mod/scorm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -45,6 +45,7 @@
|
||||
<FIELD NAME="completionstatusrequired" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="completionscorerequired" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="displayactivityname" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
|
||||
<FIELD NAME="autocommit" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
@ -279,6 +279,21 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014072500) {
|
||||
|
||||
// Define field autocommit to be added to scorm.
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('autocommit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayactivityname');
|
||||
|
||||
// Conditionally launch add field autocommit.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Scorm savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014072500, 'scorm');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,9 @@ $string['attemptsx'] = '{$a} attempts';
|
||||
$string['attemptsmanagement'] = 'Attempts management';
|
||||
$string['attempt1'] = '1 attempt';
|
||||
$string['attr_error'] = 'Bad value for attribute ({$a->attr}) in tag {$a->tag}.';
|
||||
$string['autocommit'] = 'Auto-commit';
|
||||
$string['autocommit_help'] = 'If enabled, SCORM data is automaticaly saved to the database. Useful for SCORM objects which do not save their data regularly.';
|
||||
$string['autocommitdesc'] = 'Automatically save SCORM data if the SCORM package does not save it.';
|
||||
$string['autocontinue'] = 'Auto-continue';
|
||||
$string['autocontinue_help'] = 'If enabled, subsequent learning objects are launched automatically, otherwise the Continue button must be used.';
|
||||
$string['autocontinuedesc'] = 'If enabled, subsequent learning objects are launched automatically, otherwise the Continue button must be used.';
|
||||
|
@ -256,6 +256,11 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$mform->addHelpButton('auto', 'autocontinue', 'scorm');
|
||||
$mform->setDefault('auto', $cfgscorm->auto);
|
||||
|
||||
// Autocommit.
|
||||
$mform->addElement('selectyesno', 'autocommit', get_string('autocommit', 'scorm'));
|
||||
$mform->addHelpButton('autocommit', 'autocommit', 'scorm');
|
||||
$mform->setDefault('autocommit', $cfgscorm->autocommit);
|
||||
|
||||
// Hidden Settings.
|
||||
$mform->addElement('hidden', 'datadir', null);
|
||||
$mform->setType('datadir', PARAM_RAW);
|
||||
|
@ -111,6 +111,9 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configselect('scorm/forcenewattempt',
|
||||
get_string('forcenewattempt', 'scorm'), get_string('forcenewattemptdesc', 'scorm'), 0, $yesno));
|
||||
|
||||
$settings->add(new admin_setting_configselect('scorm/autocommit',
|
||||
get_string('autocommit', 'scorm'), get_string('autocommitdesc', 'scorm'), 0, $yesno));
|
||||
|
||||
$settings->add(new admin_setting_configselect('scorm/lastattemptlock',
|
||||
get_string('lastattemptlock', 'scorm'), get_string('lastattemptlockdesc', 'scorm'), 0, $yesno));
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2014071500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2014072500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2014050800; // Requires this Moodle version.
|
||||
$plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).
|
||||
$plugin->cron = 300;
|
||||
|
Loading…
x
Reference in New Issue
Block a user