SCORM MDL-21568 - use correct storing of grading method - remove old references to bad calls. - hope the upgrade script works cross-db - thanks to Bruce Cota for report/patch
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+3
-13
@@ -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;
|
||||
|
||||
@@ -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)?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user