Permalink
Browse files

MDL-28649 SCORM start new attempt if set when skipview used.

  • Loading branch information...
1 parent 9d228de commit 0dd1a7cb66a8076f51f11ce3272e4df6dc8d3f89 @danmarsden danmarsden committed Aug 12, 2011
Showing with 13 additions and 8 deletions.
  1. +12 −7 mod/scorm/locallib.php
  2. +1 −1 mod/scorm/view.php
View
@@ -797,7 +797,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
}
}
-function scorm_simple_play($scorm,$user, $context) {
+function scorm_simple_play($scorm,$user, $context, $cmid) {
global $DB;
$result = false;
@@ -823,12 +823,17 @@ function scorm_simple_play($scorm,$user, $context) {
if ($scorm->skipview >= 1) {
$sco = current($scoes);
- if (scorm_get_tracks($sco->id,$user->id) === false) {
- header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id.'&currentorg='.$orgidentifier);
- $result = true;
- } else if ($scorm->skipview == 2) {
- header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id.'&currentorg='.$orgidentifier);
- $result = true;
+ $url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id,
+ 'currentorg'=>$orgidentifier,
+ 'scoid'=>$sco->id));
+ if ($scorm->skipview == 2 || scorm_get_tracks($sco->id, $user->id) === false) {
+ if (!empty($scorm->forcenewattempt)) {
+ $result = scorm_get_toc($user, $scorm, $cmid, TOCFULLURL, $orgidentifier);
+ if ($result->incomplete === false) {
+ $url->param('newattempt','on');
+ }
+ }
+ redirect($url);
}
}
}
View
@@ -57,7 +57,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)) && scorm_simple_play($scorm,$USER, $contextmodule)) {
+ if ((has_capability('mod/scorm:skipview', $contextmodule)) && scorm_simple_play($scorm,$USER, $contextmodule,$cm->id)) {
exit;
}

0 comments on commit 0dd1a7c

Please sign in to comment.