From cea2542bfe03165a9bb12e0ccecdd02896fed7cd Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 17 Jul 2007 07:24:35 +0000 Subject: [PATCH] MDL-10111 aggragationcof for weighted categories and extra items in old gradebook --- lib/db/install.xml | 14 ++++++++------ lib/db/upgrade.php | 30 ++++++++++++++++++++++++++++++ lib/grade/grade_item.php | 6 ++++++ version.php | 2 +- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index a46c8fa884..992d6d707b 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1332,8 +1332,9 @@ - - + + + @@ -1471,8 +1472,9 @@ - - + + + @@ -1607,4 +1609,4 @@ - + \ No newline at end of file diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 18bd856a2c..d66bc082fe 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -954,6 +954,7 @@ function xmldb_main_upgrade($oldversion=0) { $table->addFieldInfo('gradepass', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('multfactor', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '1.0'); $table->addFieldInfo('plusfactor', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('aggregationcoef', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('hidden', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); @@ -1133,6 +1134,7 @@ function xmldb_main_upgrade($oldversion=0) { $table->addFieldInfo('gradepass', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('multfactor', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '1.0'); $table->addFieldInfo('plusfactor', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('aggregationcoef', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('hidden', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0'); @@ -1492,6 +1494,34 @@ function xmldb_main_upgrade($oldversion=0) { $result = $result && question_remove_rqp_qtype_config_string(); } + if ($result && $oldversion < 2007071700) { + + /// Define field aggregationcoef to be added to grade_items + $table = new XMLDBTable('grade_items'); + $field = new XMLDBField('aggregationcoef'); + $field->setAttributes(XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0', 'plusfactor'); + + /// Launch add field aggregationcoef + + /// Launch add field overridden + if (!field_exists($table, $field)) { + $result = $result && add_field($table, $field); + } + + /// Define field aggregationcoef to be added to grade_items + $table = new XMLDBTable('grade_items_history'); + $field = new XMLDBField('aggregationcoef'); + $field->setAttributes(XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0', 'plusfactor'); + + /// Launch add field aggregationcoef + + /// Launch add field overridden + if (!field_exists($table, $field)) { + $result = $result && add_field($table, $field); + } + + } + return $result; } ?> diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index 85383cf8f4..c86c1ca36f 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -186,6 +186,12 @@ class grade_item extends grade_object { */ var $plusfactor = 0; + /** + * Aggregation coeficient used for weighted averages + * @var float $aggregationcoef + */ + var $aggregationcoef = 0; + /** * Sorting order of the columns. * @var int $sortorder diff --git a/version.php b/version.php index d8dcd8544c..10948f14a6 100644 --- a/version.php +++ b/version.php @@ -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 = 2007071601; // YYYYMMDD = date + $version = 2007071700; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name -- 2.39.5