Merge branch 'openbadges-fixes' of https://github.com/danpoltawski/moodle
authorDamyon Wiese <damyon@moodle.com>
Fri, 5 Apr 2013 09:10:14 +0000 (17:10 +0800)
committerDamyon Wiese <damyon@moodle.com>
Fri, 5 Apr 2013 09:10:14 +0000 (17:10 +0800)
mod/assign/locallib.php
mod/scorm/datamodels/debug.js.php
mod/scorm/loadSCO.php

index 04c8219..1c44529 100644 (file)
@@ -2499,6 +2499,18 @@ class assign {
         }
 
         $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid);
+        if ($attemptnumber < 0) {
+            // Make sure this grade matches the latest submission attempt.
+            if ($this->get_instance()->teamsubmission) {
+                $submission = $this->get_group_submission($userid, 0, false);
+            } else {
+                $submission = $this->get_user_submission($userid, false);
+            }
+            if ($submission) {
+                $attemptnumber = $submission->attemptnumber;
+            }
+        }
+
         if ($attemptnumber >= 0) {
             $params['attemptnumber'] = $attemptnumber;
         }
@@ -3288,7 +3300,7 @@ class assign {
             if ($teamsubmission && ($teamsubmission->status != ASSIGN_SUBMISSION_STATUS_DRAFT)) {
                 $showsubmit = false;
             }
-            if ($submission && ($submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
+            if ($submission && ($submission->status != ASSIGN_SUBMISSION_STATUS_DRAFT)) {
                 $showsubmit = false;
             }
             if (!$this->get_instance()->submissiondrafts) {
@@ -5507,8 +5519,19 @@ class assign {
                     $gradingitem = $gradinginfo->items[0];
                     $gradebookgrade = $gradingitem->grades[$userid];
                 }
-                if ($gradebookgrade && !$gradebookgrade->is_passed($gradingitem)) {
+
+                if ($gradebookgrade) {
+                    // TODO: This code should call grade_grade->is_passed().
                     $shouldreopen = true;
+                    if (is_null($gradebookgrade->grade)) {
+                        $shouldreopen = false;
+                    }
+                    if (empty($gradingitem->gradepass) || $gradingitem->gradepass == $gradingitem->grademin) {
+                        $shouldreopen = false;
+                    }
+                    if ($gradebookgrade->grade >= $gradingitem->gradepass) {
+                        $shouldreopen = false;
+                    }
                 }
             }
             if ($instance->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL &&
index 9011ab9..1ef9d1a 100644 (file)
@@ -737,14 +737,6 @@ function LogAPICall(func, nam, val, rc) {
     }
     s += ' => ' + String(rc);
     AppendToLog(s, rc);
-<?php
-if (scorm_debugging($scorm) && ($sco->scormtype == 'asset')) {
-?>
-    hint = 'Item <?php echo $sco->identifier; ?> has been defined as an Asset: it should never call the SCORM API';
-    AppendToLog(hint, 101);
-<?php
-}
-?>
 }
 
 
index a1924b9..dd569c1 100644 (file)
@@ -161,19 +161,11 @@ if (scorm_external_link($sco->launch)) {
 
 add_to_log($course->id, 'scorm', 'launch', 'view.php?id='.$cm->id, $result, $cm->id);
 
-header('Content-Type: text/html; charset=UTF-8');
-
-if ($sco->scormtype == 'asset') {
-    // HTTP 302 Found => Moved Temporarily.
-    header('Location: ' . $result);
-    // Provide a short feedback in case of slow network connection.
-    echo '<html><body><p>' . get_string('activitypleasewait', 'scorm'). '</p></body></html>';
-    exit;
-}
-
-// We expect a SCO: select which API are we looking for.
+// which API are we looking for
 $LMS_api = (scorm_version_check($scorm->version, SCORM_12) || empty($scorm->version)) ? 'API' : 'API_1484_11';
 
+header('Content-Type: text/html; charset=UTF-8');
+
 ?>
 <html>
     <head>