diff --git a/lib/questionlib.php b/lib/questionlib.php index b7fc1dae22a..ded7b23810d 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -611,7 +611,7 @@ function get_question_states(&$questions, $cmoptions, $attempt) { // The question field must be listed first so that it is used as the // array index in the array returned by get_records_sql - $statefields = 'n.questionid as question, s.*, n.sumpenalty, n.comment'; + $statefields = 'n.questionid as question, s.*, n.sumpenalty, n.manualcomment'; // Load the newest states for the questions $sql = "SELECT $statefields". " FROM {$CFG->prefix}question_states s,". @@ -652,7 +652,7 @@ function get_question_states(&$questions, $cmoptions, $attempt) { $states[$i]->raw_grade = 0; $states[$i]->penalty = 0; $states[$i]->sumpenalty = 0; - $states[$i]->comment = ''; + $states[$i]->manualcomment = ''; $states[$i]->responses = array('' => ''); // Prevent further changes to the session from incrementing the // sequence number @@ -685,7 +685,7 @@ function restore_question_state(&$question, &$state) { // initialise response to the value in the answer field $state->responses = array('' => addslashes($state->answer)); unset($state->answer); - $state->comment = isset($state->comment) ? addslashes($state->comment) : ''; + $state->manualcomment = isset($state->manualcomment) ? addslashes($state->manualcomment) : ''; // Set the changed field to false; any code which changes the // question session must set this to true and must increment @@ -744,7 +744,7 @@ function save_question_session(&$question, &$state) { // already even if there is no graded state yet. $session->newgraded = $state->id; $session->sumpenalty = $state->sumpenalty; - $session->comment = $state->comment; + $session->manualcomment = $state->manualcomment; if (!insert_record('question_sessions', $session)) { error('Could not insert entry in question_sessions'); } @@ -754,9 +754,9 @@ function save_question_session(&$question, &$state) { // this state is graded or newly opened, so it goes into the lastgraded field as well $session->newgraded = $state->id; $session->sumpenalty = $state->sumpenalty; - $session->comment = $state->comment; + $session->manualcomment = $state->manualcomment; } else { - $session->comment = addslashes($session->comment); + $session->manualcomment = addslashes($session->manualcomment); } update_record('question_sessions', $session); } @@ -885,7 +885,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f // Initialise the replaystate $state = clone($states[0]); - $state->comment = get_field('question_sessions', 'comment', 'attemptid', + $state->manualcomment = get_field('question_sessions', 'manualcomment', 'attemptid', $attempt->uniqueid, 'questionid', $question->id); restore_question_state($question, $state); $state->sumpenalty = 0.0; @@ -912,7 +912,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f if ($action->event == QUESTION_EVENTMANUALGRADE) { question_process_comment($question, $replaystate, $attempt, - $replaystate->comment, $states[$j]->grade); + $replaystate->manualcomment, $states[$j]->grade); } else { // Reprocess (regrade) responses @@ -1187,7 +1187,7 @@ function question_print_comment_box($question, $state, $attempt, $url) { function question_process_comment($question, &$state, &$attempt, $comment, $grade) { // Update the comment and save it in the database - $state->comment = $comment; + $state->manualcomment = $comment; if (!set_field('question_sessions', 'comment', $comment, 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) { error("Cannot save comment"); } diff --git a/mod/quiz/db/migrate2utf8.xml b/mod/quiz/db/migrate2utf8.xml index 7bf9fbdbe8b..4e672aa095c 100755 --- a/mod/quiz/db/migrate2utf8.xml +++ b/mod/quiz/db/migrate2utf8.xml @@ -54,7 +54,7 @@ - + SELECT qa.userid FROM {$CFG->prefix}question_sessions qs, diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index dec47e95f75..e65a8a43012 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -1132,6 +1132,10 @@ function quiz_upgrade($oldversion) { "); } + if ($success && $oldversion < 2006082400) { + $success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', ''); + } + return $success; } diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 6d3ad22ad67..e4c0c6f3c98 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -211,7 +211,7 @@ CREATE TABLE prefix_question_sessions ( newest int(10) unsigned NOT NULL default '0', newgraded int(10) unsigned NOT NULL default '0', sumpenalty float NOT NULL default '0', - comment text NOT NULL default '', + manualcomment text NOT NULL default '', PRIMARY KEY (id), UNIQUE KEY attemptid (attemptid,questionid) ) TYPE=MyISAM COMMENT='Gives ids of the newest open and newest graded states'; diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index aeb160af8d6..bc98cba5549 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -1454,6 +1454,10 @@ function quiz_upgrade($oldversion) { "); } + if ($success && $oldversion < 2006082400) { + $success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', ''); + } + return $success; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index 5f43a8fa263..e89bc028960 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -198,7 +198,7 @@ CREATE TABLE prefix_question_sessions ( newest integer NOT NULL default '0', newgraded integer NOT NULL default '0', sumpenalty real NOT NULL default '0', - comment text NOT NULL default '' + manualcomment text NOT NULL default '' ); CREATE UNIQUE INDEX prefix_question_sessions_attempt_idx ON prefix_question_sessions (attemptid,questionid); diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index db83cfd270a..9400bbf5207 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -367,8 +367,8 @@ class quiz_report extends quiz_default_report { $options = quiz_get_reviewoptions($quiz, $attempt, true); unset($options->questioncommentlink); - $copy = $state->comment; - $state->comment = ''; + $copy = $state->manualcomment; + $state->manualcomment = ''; $options->readonly = 1; @@ -381,7 +381,7 @@ class quiz_report extends quiz_default_report { $prefix = "manualgrades[$attempt->uniqueid]"; $grade = round($state->last_graded->grade, 3); - $state->comment = $copy; + $state->manualcomment = $copy; include($CFG->dirroot . '/question/comment.html'); diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index 0eefb6e37f0..24cda7a7e8b 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -108,7 +108,7 @@ $session = get_record('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id); $state->sumpenalty = $session->sumpenalty; - $state->comment = $session->comment; + $state->manualcomment = $session->manualcomment; restore_question_state($question, $state); $state->last_graded = $state; diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 90c2a77c984..a9c4f46ea0f 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2006082300; // The (date) version of this module +$module->version = 2006082400; // The (date) version of this module $module->requires = 2006080900; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? diff --git a/question/comment.html b/question/comment.html index 00d5d3dd21d..6e44071b48b 100644 --- a/question/comment.html +++ b/question/comment.html @@ -10,7 +10,7 @@ diff --git a/question/type/questiontype.php b/question/type/questiontype.php index ee2f8dfe784..bad2c62c553 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -533,7 +533,7 @@ class default_questiontype { $grade .= $question->maxgrade; } - $comment = stripslashes($state->comment); + $comment = stripslashes($state->manualcomment); $commentlink = ''; if (isset($options->questioncommentlink) && $context && has_capability('mod/quiz:grade', $context)) {
comment)); + print_textarea($usehtmleditor, 15, 60, 630, 300, $prefix.'[comment]', stripslashes($state->manualcomment)); ?>