From c2d2eb6ea073a3155918312921c6addfe72f4741 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Wed, 7 Jul 2010 21:46:05 +0000 Subject: [PATCH] NOBUG workshop: added field evaluation for future usage The field holds the name of the grading evaluation method recently used for the workshop or the default one to be used. At the moment there are no alternatives but 'best' plugin. But I want to have the field there before 2.0 stable release and also want to include it in workshop backups. --- mod/workshop/db/install.xml | 7 ++++--- mod/workshop/db/upgrade.php | 20 ++++++++++++++++++++ mod/workshop/lib.php | 2 ++ mod/workshop/locallib.php | 6 +++--- mod/workshop/version.php | 4 ++-- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/mod/workshop/db/install.xml b/mod/workshop/db/install.xml index 99a4c959fd2..fb7a930ed8f 100644 --- a/mod/workshop/db/install.xml +++ b/mod/workshop/db/install.xml @@ -1,5 +1,5 @@ - @@ -22,8 +22,9 @@ - - + + + diff --git a/mod/workshop/db/upgrade.php b/mod/workshop/db/upgrade.php index 312404c8f65..b83430c0697 100644 --- a/mod/workshop/db/upgrade.php +++ b/mod/workshop/db/upgrade.php @@ -215,5 +215,25 @@ function xmldb_workshop_upgrade($oldversion) { upgrade_mod_savepoint(true, 2009121800, 'workshop'); } + /** + * Add 'evaluation' field into workshop + */ + if ($oldversion < 2010070700) { + $table = new xmldb_table('workshop'); + $field = new xmldb_field('evaluation', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, 'strategy'); + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + upgrade_mod_savepoint(true, 2010070700, 'workshop'); + } + + /** + * Set the value of the new 'evaluation' field to 'best', there is no alternative at the moment + */ + if ($oldversion < 2010070701) { + $DB->set_field('workshop', 'evaluation', 'best'); + upgrade_mod_savepoint(true, 2010070701, 'workshop'); + } + return true; } diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index c0361e872c5..3ac4667c6c4 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -72,6 +72,7 @@ function workshop_add_instance(stdclass $workshop) { $workshop->usepeerassessment = (int)!empty($workshop->usepeerassessment); // unticked checkbox hack $workshop->useselfassessment = (int)!empty($workshop->useselfassessment); // unticked checkbox hack $workshop->latesubmissions = (int)!empty($workshop->latesubmissions); // unticked checkbox hack + $workshop->evaluation = 'best'; // insert the new record so we get the id $workshop->id = $DB->insert_record('workshop', $workshop); @@ -121,6 +122,7 @@ function workshop_update_instance(stdclass $workshop) { $workshop->usepeerassessment = (int)!empty($workshop->usepeerassessment); // unticked checkbox hack $workshop->useselfassessment = (int)!empty($workshop->useselfassessment); // unticked checkbox hack $workshop->latesubmissions = (int)!empty($workshop->latesubmissions); // unticked checkbox hack + $workshop->evaluation = 'best'; // todo - if the grading strategy is being changed, we must replace all aggregated peer grades with nulls // todo - if maximum grades are being changed, we should probably recalculate or invalidate them diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 62cc8fe4d59..f6dcd62345b 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -115,6 +115,9 @@ class workshop { /** @var string type of the current grading strategy used in this workshop, for example 'accumulative' */ public $strategy; + /** @var string the name of the evaluation plugin to use for grading grades calculation */ + public $evaluation; + /** @var int number of digits that should be shown after the decimal point when displaying grades */ public $gradedecimals; @@ -142,9 +145,6 @@ class workshop { /** @var int if greater than 0 then the peer assessment is not allowed after this timestamp */ public $assessmentend; - /** @var string the name of the evaluation plugin to use for grading grades calculation */ - public $evaluation; - /** * @var workshop_strategy grading strategy instance * Do not use directly, get the instance using {@link workshop::grading_strategy_instance()} diff --git a/mod/workshop/version.php b/mod/workshop/version.php index 301d2fe61ab..40f9c9241a0 100644 --- a/mod/workshop/version.php +++ b/mod/workshop/version.php @@ -28,6 +28,6 @@ defined('MOODLE_INTERNAL') || die(); -$module->version = 2009121800; -$module->requires = 2009090400; // Requires this Moodle version +$module->version = 2010070701; +$module->requires = 2010070604; // Requires this Moodle version //$module->cron = 60;