diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php index 338460321b1..0e97fe6d8be 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -441,7 +441,12 @@ function xmldb_scorm_upgrade($oldversion) { /// scorm savepoint reached upgrade_mod_savepoint(true, 2009042002, 'scorm'); } - + if ($oldversion < 2010070800) { + /// fix bad usage of whatgrade/grading method. - I hope this works in all dbs + $DB->execute('UPDATE {scorm} SET grademethod = grademethod%10'); + /// scorm savepoint reached + upgrade_mod_savepoint(true, 2010070800, 'scorm'); + } return true; } diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 1d3702b2f5f..f5aa6252de0 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -72,7 +72,6 @@ function scorm_add_instance($scorm, $mform=null) { if (!isset($scorm->whatgrade)) { $scorm->whatgrade = 0; } - $scorm->grademethod = ($scorm->whatgrade * 10) + $scorm->grademethod; $id = $DB->insert_record('scorm', $scorm); @@ -191,7 +190,6 @@ function scorm_update_instance($scorm, $mform=null) { if (!isset($scorm->whatgrade)) { $scorm->whatgrade = 0; } - $scorm->grademethod = ($scorm->whatgrade * 10) + $scorm->grademethod; $DB->update_record('scorm', $scorm); diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 4f4c9161919..86d64f97e70 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -402,7 +402,6 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo if (strstr($element, '.score.raw') || (($element == 'cmi.core.lesson_status' || $element == 'cmi.completion_status') && ($track->value == 'completed' || $track->value == 'passed'))) { $scorm = $DB->get_record('scorm', array('id' => $scormid)); - $grademethod = $scorm->grademethod % 10; include_once($CFG->dirroot.'/mod/scorm/lib.php'); scorm_update_grades($scorm, $userid); } @@ -526,11 +525,6 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) { return NULL; } - // this treatment is necessary as the whatgrade field was not in the DB - // and so whatgrade and grademethod are combined in grademethod 10s are whatgrade - // and 1s are grademethod - $grademethod = $scorm->grademethod % 10; - foreach ($scoes as $sco) { if ($userdata=scorm_get_tracks($sco->id, $userid,$attempt)) { if (($userdata->status == 'completed') || ($userdata->status == 'passed')) { @@ -548,7 +542,7 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) { } } } - switch ($grademethod) { + switch ($scorm->grademethod) { case GRADEHIGHEST: $score = $attemptscore->max; break; @@ -581,18 +575,14 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) { } function scorm_grade_user($scorm, $userid, $time=false) { - // this treatment is necessary as the whatgrade field was not in the DB - // and so whatgrade and grademethod are combined in grademethod 10s are whatgrade - // and 1s are grademethod - $whatgrade = intval($scorm->grademethod / 10); - // insure we dont grade user beyond $scorm->maxattempt settings + // ensure we dont grade user beyond $scorm->maxattempt settings $lastattempt = scorm_get_last_attempt($scorm->id, $userid); if($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt){ $lastattempt = $scorm->maxattempt; } - switch ($whatgrade) { + switch ($scorm->whatgrade) { case FIRSTATTEMPT: return scorm_grade_user_attempt($scorm, $userid, 1, $time); break; diff --git a/mod/scorm/version.php b/mod/scorm/version.php index b336f4a808c..00de20b11ae 100755 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -6,11 +6,7 @@ ///////////////////////////////////////////////////////////////////////////////// -// NOTE The version below was accidentally set a month into the future! We need to -// catch up now, so until 27th October please only increment in very tiny steps -// in HEAD, until we get past that date.. - -$module->version = 2009042002; // The (date) version of this module +$module->version = 2010070800; // The (date) version of this module $module->requires = 2009041700; // The version of Moodle that is required $module->cron = 300; // How often should cron check this module (seconds)?