Commit ecdfab51 authored by Amy Groshek's avatar Amy Groshek
Browse files

MDL-60478 mod_scorm: Makes checknet alerts less obtrusive.

Alters checknet component to accept frequency,
timeout, and maxalerts arguments. Sets checknet
launched during SCORM session for 30 sec
frequency, 10 sec timeout, and 1 alert max.
parent 4275ea4a
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -34,6 +34,16 @@ function CheckNet() {
}
Y.extend(CheckNet, Y.Base, {
/**
* Zero-based count of alerts displayed.
*
* @property _alertCount
* @type Number
* @private
* @default 0
*/
_alertCount: 0,
/**
* A link to the warning dialogue.
*
......@@ -64,7 +74,6 @@ Y.extend(CheckNet, Y.Base, {
_scheduleCheck: function() {
// Schedule the next check after five seconds.
Y.later(this.get('frequency'), this, this._performCheck);
return this;
},
......@@ -116,11 +125,15 @@ Y.extend(CheckNet, Y.Base, {
} else {
this._alertDialogue.show();
}
this._alertCount++;
}
}
// Start the next check.
this._scheduleCheck();
// If max alert not modified in args, check indefinitely.
// Once max alert count iteration is reached, stop checking.
if (this.get('maxalerts') === -1 || (this.get('maxalerts') - 1) >= this._alertCount) {
// Start the next check.
this._scheduleCheck();
}
}
}
});
......@@ -180,6 +193,17 @@ Y.extend(CheckNet, Y.Base, {
'networkdropped',
'moodle'
]
},
/**
* Maxiumum count (not zero-based) of alerts to display for a single page load.
*
* @attribute maxalerts
* @type Number
* @value -1
*/
maxalerts: {
value: -1
}
}
});
......
......@@ -284,9 +284,14 @@ if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.php'))
// Add the checknet system to keep checking for a connection.
$PAGE->requires->string_for_js('networkdropped', 'mod_scorm');
$PAGE->requires->yui_module('moodle-core-checknet', 'M.core.checknet.init', array(array(
// Build arguments to send to checknet JS.
$args = array(
'message' => array('networkdropped', 'mod_scorm'),
)));
'frequency' => 30000, // Frequency of network check.
'timeout' => 10000, // Timeout of network check.
'maxalerts' => 1 // Max number of alerts to be thrown.
);
$PAGE->requires->yui_module('moodle-core-checknet', 'M.core.checknet.init', array($args));
echo $OUTPUT->footer();
// Set the start time of this SCO.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment