Permalink
Browse files

MDL-18961, MDL-12942, MDL-18960 - added better extra credit upgrade, …

…fixed potential problem with bogus coefs value for simple mean in current installs + finally fixed long standing "no course total" bug
  • Loading branch information...
1 parent f2c7967 commit fa297173a78fd142c10d774c1d4fe5df188dbb68 skodak committed Apr 24, 2009
Showing with 24 additions and 8 deletions.
  1. +20 −2 lib/db/upgrade.php
  2. +3 −5 lib/db/upgradelib.php
  3. +1 −1 version.php
View
@@ -2041,11 +2041,11 @@ function xmldb_main_upgrade($oldversion=0) {
execute_sql($sql, true);
/// convert old aggregation constants if needed
- for ($i=0; $i<=12; $i=$i+2) {
+ /*for ($i=0; $i<=12; $i=$i+2) {
$j = $i+1;
$sql = "UPDATE {$CFG->prefix}grade_categories SET aggregation = $i, aggregateonlygraded = 1 WHERE aggregation = $j";
execute_sql($sql, true);
- }
+ }*/ // not needed anymore - breaks upgrade now
upgrade_main_savepoint($result, 2007090503);
}
@@ -3113,6 +3113,24 @@ function xmldb_main_upgrade($oldversion=0) {
upgrade_main_savepoint($result, 2007101545.01);
}
+ if ($result && $oldversion < 2007101546.02) {
+ if (empty($CFG->gradebook_latest195_upgrade)) {
+ require_once($CFG->libdir.'/gradelib.php'); // we need constants only
+ // reset current coef for simple mean items - it may contain some rubbish ;-)
+ $sql = "UPDATE {$CFG->prefix}grade_items
+ SET aggregationcoef = 0
+ WHERE categoryid IN (SELECT gc.id
+ FROM {$CFG->prefix}grade_categories gc
+ WHERE gc.aggregation = ".GRADE_AGGREGATE_WEIGHTED_MEAN2.")";
+ $result = execute_sql($sql);
+ } else {
+ // direct upgrade from 1.8.x - no need to reset coef, because it is already ok
+ unset_config('gradebook_latest195_upgrade');
+ }
+
+ upgrade_main_savepoint($result, 2007101546.02);
+ }
+
return $result;
}
View
@@ -242,11 +242,6 @@ function upgrade_18_gradebook($courseid) {
}
$newitems[$olditem->id] = $item;
-
- if ($olditem->extra_credit and $categories[$olditem->category]->aggregation != GRADE_AGGREGATE_EXTRACREDIT_MEAN) {
- $categories[$olditem->category]->aggregation = GRADE_AGGREGATE_EXTRACREDIT_MEAN;
- update_record('grade_categories', $categories[$olditem->category]);
- }
}
unset($olditems);
@@ -265,6 +260,9 @@ function upgrade_18_gradebook($courseid) {
}
}
+ // flag indicating new 1.9.5 upgrade routine
+ set_config('gradebook_latest195_upgrade', 1);
+
return true;
}
View
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007101546.01; // YYYYMMDD = date of the 1.9 branch (don't change)
+ $version = 2007101546.02; // YYYYMMDD = date of the 1.9 branch (don't change)
// X = release number 1.9.[0,1,2,3,4,5...]
// Y.YY = micro-increments between releases

0 comments on commit fa29717

Please sign in to comment.