Changed table field name 'new' to 'newest' for postgres compatibility

This commit is contained in:
gustav_delius 2005-05-08 10:35:47 +00:00
parent 61563cd7fa
commit 3e34b1dc14
6 changed files with 14 additions and 9 deletions

View File

@ -301,7 +301,7 @@
// Find all the questions for this attempt for which the newest // Find all the questions for this attempt for which the newest
// state is not also the newest graded state // state is not also the newest graded state
if ($closequestions = get_records_select('quiz_newest_states', if ($closequestions = get_records_select('quiz_newest_states',
"attemptid = $attempt->id AND new != newgraded", '', 'questionid, questionid')) { "attemptid = $attempt->id AND newest != newgraded", '', 'questionid, questionid')) {
// load all the questions // load all the questions
$closequestionlist = implode(',', array_keys($closequestions)); $closequestionlist = implode(',', array_keys($closequestions));

View File

@ -638,6 +638,11 @@ function quiz_upgrade($oldversion) {
if ($oldversion < 2005050500) { if ($oldversion < 2005050500) {
table_column('quiz_questions', '', 'penalty', 'float', '', '', '0.1', 'not null', 'defaultgrade'); table_column('quiz_questions', '', 'penalty', 'float', '', '', '0.1', 'not null', 'defaultgrade');
} }
if ($oldversion < 2005050800) {
table_column('quiz_newest_states', 'new', 'newest', 'integer', '10', 'unsigned', '0', 'not null');
}
return true; return true;
} }

View File

@ -255,7 +255,7 @@ CREATE TABLE prefix_quiz_newest_states (
id int(10) unsigned NOT NULL auto_increment, id int(10) unsigned NOT NULL auto_increment,
attemptid int(10) unsigned NOT NULL default '0', attemptid int(10) unsigned NOT NULL default '0',
questionid int(10) unsigned NOT NULL default '0', questionid int(10) unsigned NOT NULL default '0',
new int(10) unsigned NOT NULL default '0', newest int(10) unsigned NOT NULL default '0',
newgraded int(10) unsigned NOT NULL default '0', newgraded int(10) unsigned NOT NULL default '0',
sumpenalty varchar(10) NOT NULL default '0.0', sumpenalty varchar(10) NOT NULL default '0.0',
PRIMARY KEY (id), PRIMARY KEY (id),

View File

@ -1140,7 +1140,7 @@ function quiz_restore_question_sessions(&$questions, $quiz, $attempt) {
$sql = "SELECT $statefields". $sql = "SELECT $statefields".
" FROM {$CFG->prefix}quiz_states s,". " FROM {$CFG->prefix}quiz_states s,".
" {$CFG->prefix}quiz_newest_states n". " {$CFG->prefix}quiz_newest_states n".
" WHERE s.id = n.new". " WHERE s.id = n.newest".
" AND n.attemptid = '$attempt->id'". " AND n.attemptid = '$attempt->id'".
" AND n.questionid IN ($questionlist)"; " AND n.questionid IN ($questionlist)";
$states = get_records_sql($sql); $states = get_records_sql($sql);
@ -1301,14 +1301,14 @@ function quiz_save_question_session(&$question, &$state) {
$state->attempt, 'questionid', $question->id)) { $state->attempt, 'questionid', $question->id)) {
$new->attemptid = $state->attempt; $new->attemptid = $state->attempt;
$new->questionid = $question->id; $new->questionid = $question->id;
$new->new = $state->id; $new->newest = $state->id;
$new->newgraded = $state->id; $new->newgraded = $state->id;
$new->sumpenalty = $state->sumpenalty; $new->sumpenalty = $state->sumpenalty;
if (!insert_record('quiz_newest_states', $new)) { if (!insert_record('quiz_newest_states', $new)) {
error('Could not insert entry in quiz_newest_states'); error('Could not insert entry in quiz_newest_states');
} }
} else { } else {
set_field('quiz_newest_states', 'new', $state->id, 'attemptid', set_field('quiz_newest_states', 'newest', $state->id, 'attemptid',
$state->attempt, 'questionid', $question->id); $state->attempt, 'questionid', $question->id);
} }
if (quiz_state_is_graded($state)) { if (quiz_state_is_graded($state)) {
@ -2496,7 +2496,7 @@ function quiz_upgrade_states($attempt) {
if ($states = get_records('quiz_states', 'attempt', $attempt->id)) { if ($states = get_records('quiz_states', 'attempt', $attempt->id)) {
foreach ($states as $state) { foreach ($states as $state) {
$newest->newgraded = $state->id; $newest->newgraded = $state->id;
$newest->new = $state->id; $newest->newest = $state->id;
$newest->questionid = $state->question; $newest->questionid = $state->question;
insert_record('quiz_newest_states', $newest, false); insert_record('quiz_newest_states', $newest, false);
} }

View File

@ -32,13 +32,13 @@
if (! $attempt = get_record('quiz_attempts', 'id', $attemptid)) { if (! $attempt = get_record('quiz_attempts', 'id', $attemptid)) {
error('No such attempt ID exists'); error('No such attempt ID exists');
} }
if (! $neweststate = get_field('quiz_newest_states', 'new', 'attemptid', $attemptid, 'questionid', $questionid)) { if (! $neweststate = get_field('quiz_newest_states', 'newest', 'attemptid', $attemptid, 'questionid', $questionid)) {
// newest_state not set, probably because this is an old attempt from the old quiz module code // newest_state not set, probably because this is an old attempt from the old quiz module code
if (! $state = get_record('quiz_states', 'question', $questionid, 'attempt', $attemptid)) { if (! $state = get_record('quiz_states', 'question', $questionid, 'attempt', $attemptid)) {
error('Invalid question id'); error('Invalid question id');
} }
} else { } else {
if (! $state = get_record('quiz_states', 'id', $neweststate->new)) { if (! $state = get_record('quiz_states', 'id', $neweststate->newest)) {
error('Invalid state id'); error('Invalid state id');
} }
} }

View File

@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php // This fragment is called by moodle_needs_upgrading() and /admin/index.php
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
$module->version = 2005050405; // The (date) version of this module $module->version = 2005050408; // The (date) version of this module
$module->requires = 2005021600; // Requires this Moodle version $module->requires = 2005021600; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)? $module->cron = 0; // How often should cron check this module (seconds)?