Permalink
Browse files

allow negative score and weighting in hotpot_responses table

  • Loading branch information...
1 parent 008060c commit c9441e34ca6a3453d572e471f6dd512d9c7aebc9 gbateson committed Apr 28, 2006
Showing with 14 additions and 9 deletions.
  1. +1 −1 mod/hotpot/db/mysql.php
  2. +2 −2 mod/hotpot/db/mysql.sql
  3. +1 −1 mod/hotpot/db/postgres7.php
  4. +9 −4 mod/hotpot/db/update_to_v2.php
  5. +1 −1 mod/hotpot/version.php
View
@@ -33,7 +33,7 @@ function hotpot_upgrade($oldversion) {
require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_17();
}
- if ($oldversion < 2006042802) {
+ if ($oldversion < 2006042803) {
require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_18();
}
View
@@ -77,8 +77,8 @@ CREATE TABLE prefix_hotpot_responses (
id int(10) unsigned NOT NULL auto_increment,
attempt int(10) unsigned NOT NULL default '0',
question int(10) unsigned NOT NULL default '0',
- score smallint(6) unsigned NOT NULL default '0',
- weighting smallint(6) unsigned NOT NULL default '0',
+ score smallint(6) NOT NULL default '0',
+ weighting smallint(6) NOT NULL default '0',
correct varchar(255) NOT NULL default '',
wrong varchar(255) NOT NULL default '',
ignored varchar(255) NOT NULL default '',
@@ -37,7 +37,7 @@ function hotpot_upgrade($oldversion) {
require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_17();
}
- if ($oldversion < 2006042802) {
+ if ($oldversion < 2006042803) {
require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_18();
}
@@ -10,6 +10,11 @@ function hotpot_update_to_v2_1_18() {
$ok = $ok && hotpot_remove_orphans('hotpot_responses', 'question', 'hotpot_questions');
$ok = $ok && hotpot_remove_orphans('hotpot_details', 'attempt', 'hotpot_attempts');
+ // allow negative weighting and scores
+
+ $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'weighting', '6', false);
+ $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'score', '6', false);
+
return $ok;
}
function hotpot_remove_orphans($secondarytable, $secondarykeyfield, $primarytable, $primarykeyfield='id') {
@@ -58,19 +63,19 @@ function hotpot_update_to_v2_1_17() {
$ok = $ok && hotpot_denull_int_field('hotpot_questions', 'type', '4');
$ok = $ok && hotpot_denull_int_field('hotpot_questions', 'text', '10');
- $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'weighting', '6');
- $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'score', '6');
+ $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'weighting', '6', false);
+ $ok = $ok && hotpot_denull_int_field('hotpot_responses', 'score', '6', false);
$ok = $ok && hotpot_denull_int_field('hotpot_responses', 'hints', '6');
$ok = $ok && hotpot_denull_int_field('hotpot_responses', 'clues', '6');
$ok = $ok && hotpot_denull_int_field('hotpot_responses', 'checks', '6');
return $ok;
}
-function hotpot_denull_int_field($table, $field, $size) {
+function hotpot_denull_int_field($table, $field, $size, $unsigned=true) {
global $CFG;
$ok = true;
$ok = $ok && execute_sql("UPDATE {$CFG->prefix}$table SET $field=0 WHERE $field IS NULL", false);
- $ok = $ok && hotpot_db_update_field_type($table, $field, $field, 'INTEGER', $size, 'UNSIGNED', 'NOT NULL', 0);
+ $ok = $ok && hotpot_db_update_field_type($table, $field, $field, 'INTEGER', $size, $unsigned, 'NOT NULL', 0);
return $ok;
}
View
@@ -3,7 +3,7 @@
/// Code fragment to define the version of hotpot
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006042802; // release date of this version (see note below)
+$module->version = 2006042803; // release date of this version (see note below)
$module->release = 'v2.1.18'; // human-friendly version name (used in mod/hotpot/lib.php)
$module->cron = 0; // period for cron to check this module (secs)
// interpretation of YYYYMMDDXY version numbers

0 comments on commit c9441e3

Please sign in to comment.