Skip to content
Browse files

MDL-33755 SCORM only auto-skipview for users with skipview cap that c…

…an't see reports

also don't generate unrequired content when scorm will be launched automatically.
  • Loading branch information...
1 parent 35cfa9e commit 81f460b1e287489589ca1f04f3b67a742d388f90 @danmarsden danmarsden committed Sep 4, 2012
Showing with 13 additions and 10 deletions.
  1. +1 −1 mod/scorm/player.php
  2. +1 −1 mod/scorm/view.js
  3. +11 −8 mod/scorm/view.php
View
2 mod/scorm/player.php
@@ -180,7 +180,7 @@
$PAGE->set_button($exitlink);
}
-$PAGE->requires->data_for_js('scormplayerdata', Array('launch' => 0,
+$PAGE->requires->data_for_js('scormplayerdata', Array('launch' => false,
'currentorg' => '',
'sco' => 0,
'scorm' => 0,
View
2 mod/scorm/view.js
@@ -24,7 +24,7 @@ M.mod_scormform.init = function(Y) {
poptions = poptions+',width='+cwidth+',height='+cheight;
}
- if (launch != 0) {
+ if (launch != false) {
if (launch == 2) {
launch_url = launch_url+"&display=popup";
}
View
19 mod/scorm/view.php
@@ -58,11 +58,17 @@
require_login($course, false, $cm);
+$context = context_course::instance($course->id);
+$contextmodule = context_module::instance($cm->id);
+
+$launch = false; // Does this automatically trigger a launch based on skipview.
if (!empty($scorm->popup)) {
- $launch = 0;
$orgidentifier = '';
$scoid = 0;
- if ($scorm->skipview >= 1) {
+ if ($scorm->skipview >= 1 &&
+ has_capability('mod/scorm:skipview', $contextmodule) &&
+ !has_capability('mod/scorm:viewreport', $contextmodule)) { // Don't skip users with the capability to view reports.
+
// do we launch immediately and redirect the parent back ?
if ($scorm->skipview == 2 || (scorm_get_tracks($scoes[0]->id, $USER->id) === false)) {
$orgidentifier = '';
@@ -88,9 +94,6 @@
$PAGE->requires->js('/mod/scorm/view.js', true);
}
-$context = context_course::instance($course->id);
-$contextmodule = context_module::instance($cm->id);
-
if (isset($SESSION->scorm)) {
unset($SESSION->scorm);
}
@@ -103,7 +106,7 @@
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
-if ((has_capability('mod/scorm:skipview', $contextmodule))) {
+if (empty($launch) && (has_capability('mod/scorm:skipview', $contextmodule))) {
scorm_simple_play($scorm, $USER, $contextmodule, $cm->id);
}
@@ -134,7 +137,7 @@
// Print the main part of the page
echo $OUTPUT->heading(format_string($scorm->name));
$attemptstatus = '';
-if ($scorm->displayattemptstatus == 1) {
+if ($scorm->displayattemptstatus == 1 && empty($launch)) {
$attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
@@ -149,7 +152,7 @@
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
$scormopen = false;
}
-if ($scormopen) {
+if ($scormopen && empty($launch)) {
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
}
if (!empty($forcejs)) {

0 comments on commit 81f460b

Please sign in to comment.
Something went wrong with that request. Please try again.