]> git.mjollnir.org Git - moodle.git/commitdiff
Renamed column question_sessions->comment at Eloy's request since comment is a DB...
authortjhunt <tjhunt>
Thu, 24 Aug 2006 16:44:15 +0000 (16:44 +0000)
committertjhunt <tjhunt>
Thu, 24 Aug 2006 16:44:15 +0000 (16:44 +0000)
I have not been able to test this fully, because I cannot assign roles (e.g. Student and Teacher) in 1.7dev at the moment to test a student answering an essay question then a teacher grading it. However, I have tested as much as possible as admin and cannot get any errors.

lib/questionlib.php
mod/quiz/db/migrate2utf8.xml
mod/quiz/db/mysql.php
mod/quiz/db/mysql.sql
mod/quiz/db/postgres7.php
mod/quiz/db/postgres7.sql
mod/quiz/report/grading/report.php
mod/quiz/reviewquestion.php
mod/quiz/version.php
question/comment.html
question/type/questiontype.php

index b7fc1dae22a151e8e0540e07eec2f21e2ede46d2..ded7b23810da25b606c6186eebbff1c057af7327 100644 (file)
@@ -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");
     }
index 7bf9fbdbe8bd985e2583526798dfc2eac0064740..4e672aa095cf4212359fddfdfdf6d7fb6a902cc1 100755 (executable)
@@ -54,7 +54,7 @@
     </TABLE>
     <TABLE name="question_sessions">
       <FIELDS>
-        <FIELD name="comment" method="PLAIN_SQL_UPDATE" type="text" length="0">
+        <FIELD name="manualcomment" method="PLAIN_SQL_UPDATE" type="text" length="0">
           <SQL_DETECT_USER>
            SELECT qa.userid
            FROM {$CFG->prefix}question_sessions qs,
index dec47e95f75190f08eab81aa15460dcbba03b458..e65a8a4301212aa92375e9b3c66ced8674605b59 100644 (file)
@@ -1132,6 +1132,10 @@ function quiz_upgrade($oldversion) {
         ");
     }
 
+    if ($success && $oldversion < 2006082400) {
+        $success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
+    }
+
     return $success;
 }
 
index 6d3ad22ad6702cca66f68860829ef2cd3dab2ccb..e4c0c6f3c98f0e47f14b3b6345a57c9191987934 100644 (file)
@@ -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';
index aeb160af8d6583c4045efd2cfd44be1da0ac70d8..bc98cba5549c04e20e4966642efef94d29074815 100644 (file)
@@ -1454,6 +1454,10 @@ function quiz_upgrade($oldversion) {
         ");
     }
     
+    if ($success && $oldversion < 2006082400) {
+        $success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
+    }
+
     return $success;
 }
 
index 5f43a8fa263e9c73ea5cb59ce831c8b25b86d9a3..e89bc0289601b45c2cfa53e35b79c12cdc189558 100644 (file)
@@ -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);
 
index db83cfd270a2ad748c243ad63218beaca93c379e..9400bbf52071eb68a76d13d0329dac86021d2a26 100644 (file)
@@ -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');
 
index 0eefb6e37f03b17ce95fd3d2cb83148b5cb21e45..24cda7a7e8ba4c6e9dd557e339b8c76f3c5b5ecf 100644 (file)
 
     $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;
 
index 90c2a77c98403aa94f57764b78b72e506180210e..a9c4f46ea0f6be2778f638a2c3054da82d105136 100644 (file)
@@ -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)?
 
index 00d5d3dd21d057b2f5f60d99692af85b93837dc2..6e44071b48bddfa51bfaa17951f5bc15d378113f 100644 (file)
@@ -10,7 +10,7 @@
     </td>
     <td>
       <?php
-        print_textarea($usehtmleditor, 15, 60, 630, 300, $prefix.'[comment]', stripslashes($state->comment));
+        print_textarea($usehtmleditor, 15, 60, 630, 300, $prefix.'[comment]', stripslashes($state->manualcomment));
       ?>
     </td>
   </tr>
index ee2f8dfe784980e18a2945c9696ef8999249899a..bad2c62c553994fa3bb7d81af6c4d7700503ef07 100644 (file)
@@ -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)) {