mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Renamed column question_sessions->comment at Eloy's request since comment is a DB reserved word.
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.
This commit is contained in:
parent
dd4a1bca28
commit
3e3e5a4030
11 changed files with 27 additions and 19 deletions
|
@ -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
|
// The question field must be listed first so that it is used as the
|
||||||
// array index in the array returned by get_records_sql
|
// 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
|
// Load the newest states for the questions
|
||||||
$sql = "SELECT $statefields".
|
$sql = "SELECT $statefields".
|
||||||
" FROM {$CFG->prefix}question_states s,".
|
" FROM {$CFG->prefix}question_states s,".
|
||||||
|
@ -652,7 +652,7 @@ function get_question_states(&$questions, $cmoptions, $attempt) {
|
||||||
$states[$i]->raw_grade = 0;
|
$states[$i]->raw_grade = 0;
|
||||||
$states[$i]->penalty = 0;
|
$states[$i]->penalty = 0;
|
||||||
$states[$i]->sumpenalty = 0;
|
$states[$i]->sumpenalty = 0;
|
||||||
$states[$i]->comment = '';
|
$states[$i]->manualcomment = '';
|
||||||
$states[$i]->responses = array('' => '');
|
$states[$i]->responses = array('' => '');
|
||||||
// Prevent further changes to the session from incrementing the
|
// Prevent further changes to the session from incrementing the
|
||||||
// sequence number
|
// sequence number
|
||||||
|
@ -685,7 +685,7 @@ function restore_question_state(&$question, &$state) {
|
||||||
// initialise response to the value in the answer field
|
// initialise response to the value in the answer field
|
||||||
$state->responses = array('' => addslashes($state->answer));
|
$state->responses = array('' => addslashes($state->answer));
|
||||||
unset($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
|
// Set the changed field to false; any code which changes the
|
||||||
// question session must set this to true and must increment
|
// 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.
|
// already even if there is no graded state yet.
|
||||||
$session->newgraded = $state->id;
|
$session->newgraded = $state->id;
|
||||||
$session->sumpenalty = $state->sumpenalty;
|
$session->sumpenalty = $state->sumpenalty;
|
||||||
$session->comment = $state->comment;
|
$session->manualcomment = $state->manualcomment;
|
||||||
if (!insert_record('question_sessions', $session)) {
|
if (!insert_record('question_sessions', $session)) {
|
||||||
error('Could not insert entry in question_sessions');
|
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
|
// this state is graded or newly opened, so it goes into the lastgraded field as well
|
||||||
$session->newgraded = $state->id;
|
$session->newgraded = $state->id;
|
||||||
$session->sumpenalty = $state->sumpenalty;
|
$session->sumpenalty = $state->sumpenalty;
|
||||||
$session->comment = $state->comment;
|
$session->manualcomment = $state->manualcomment;
|
||||||
} else {
|
} else {
|
||||||
$session->comment = addslashes($session->comment);
|
$session->manualcomment = addslashes($session->manualcomment);
|
||||||
}
|
}
|
||||||
update_record('question_sessions', $session);
|
update_record('question_sessions', $session);
|
||||||
}
|
}
|
||||||
|
@ -885,7 +885,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f
|
||||||
|
|
||||||
// Initialise the replaystate
|
// Initialise the replaystate
|
||||||
$state = clone($states[0]);
|
$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);
|
$attempt->uniqueid, 'questionid', $question->id);
|
||||||
restore_question_state($question, $state);
|
restore_question_state($question, $state);
|
||||||
$state->sumpenalty = 0.0;
|
$state->sumpenalty = 0.0;
|
||||||
|
@ -912,7 +912,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f
|
||||||
|
|
||||||
if ($action->event == QUESTION_EVENTMANUALGRADE) {
|
if ($action->event == QUESTION_EVENTMANUALGRADE) {
|
||||||
question_process_comment($question, $replaystate, $attempt,
|
question_process_comment($question, $replaystate, $attempt,
|
||||||
$replaystate->comment, $states[$j]->grade);
|
$replaystate->manualcomment, $states[$j]->grade);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Reprocess (regrade) responses
|
// 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) {
|
function question_process_comment($question, &$state, &$attempt, $comment, $grade) {
|
||||||
|
|
||||||
// Update the comment and save it in the database
|
// 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)) {
|
if (!set_field('question_sessions', 'comment', $comment, 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) {
|
||||||
error("Cannot save comment");
|
error("Cannot save comment");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
</TABLE>
|
</TABLE>
|
||||||
<TABLE name="question_sessions">
|
<TABLE name="question_sessions">
|
||||||
<FIELDS>
|
<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>
|
<SQL_DETECT_USER>
|
||||||
SELECT qa.userid
|
SELECT qa.userid
|
||||||
FROM {$CFG->prefix}question_sessions qs,
|
FROM {$CFG->prefix}question_sessions qs,
|
||||||
|
|
|
@ -1132,6 +1132,10 @@ function quiz_upgrade($oldversion) {
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($success && $oldversion < 2006082400) {
|
||||||
|
$success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
|
||||||
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ CREATE TABLE prefix_question_sessions (
|
||||||
newest 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 float NOT NULL default '0',
|
sumpenalty float NOT NULL default '0',
|
||||||
comment text NOT NULL default '',
|
manualcomment text NOT NULL default '',
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
UNIQUE KEY attemptid (attemptid,questionid)
|
UNIQUE KEY attemptid (attemptid,questionid)
|
||||||
) TYPE=MyISAM COMMENT='Gives ids of the newest open and newest graded states';
|
) TYPE=MyISAM COMMENT='Gives ids of the newest open and newest graded states';
|
||||||
|
|
|
@ -1454,6 +1454,10 @@ function quiz_upgrade($oldversion) {
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($success && $oldversion < 2006082400) {
|
||||||
|
$success = $success && table_column('question_sessions', 'comment', 'manualcomment', 'text', '', '', '');
|
||||||
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ CREATE TABLE prefix_question_sessions (
|
||||||
newest integer NOT NULL default '0',
|
newest integer NOT NULL default '0',
|
||||||
newgraded integer NOT NULL default '0',
|
newgraded integer NOT NULL default '0',
|
||||||
sumpenalty real 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);
|
CREATE UNIQUE INDEX prefix_question_sessions_attempt_idx ON prefix_question_sessions (attemptid,questionid);
|
||||||
|
|
||||||
|
|
|
@ -367,8 +367,8 @@ class quiz_report extends quiz_default_report {
|
||||||
|
|
||||||
$options = quiz_get_reviewoptions($quiz, $attempt, true);
|
$options = quiz_get_reviewoptions($quiz, $attempt, true);
|
||||||
unset($options->questioncommentlink);
|
unset($options->questioncommentlink);
|
||||||
$copy = $state->comment;
|
$copy = $state->manualcomment;
|
||||||
$state->comment = '';
|
$state->manualcomment = '';
|
||||||
|
|
||||||
$options->readonly = 1;
|
$options->readonly = 1;
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ class quiz_report extends quiz_default_report {
|
||||||
|
|
||||||
$prefix = "manualgrades[$attempt->uniqueid]";
|
$prefix = "manualgrades[$attempt->uniqueid]";
|
||||||
$grade = round($state->last_graded->grade, 3);
|
$grade = round($state->last_graded->grade, 3);
|
||||||
$state->comment = $copy;
|
$state->manualcomment = $copy;
|
||||||
|
|
||||||
include($CFG->dirroot . '/question/comment.html');
|
include($CFG->dirroot . '/question/comment.html');
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
|
|
||||||
$session = get_record('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id);
|
$session = get_record('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id);
|
||||||
$state->sumpenalty = $session->sumpenalty;
|
$state->sumpenalty = $session->sumpenalty;
|
||||||
$state->comment = $session->comment;
|
$state->manualcomment = $session->manualcomment;
|
||||||
restore_question_state($question, $state);
|
restore_question_state($question, $state);
|
||||||
$state->last_graded = $state;
|
$state->last_graded = $state;
|
||||||
|
|
||||||
|
|
|
@ -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 = 2006082300; // The (date) version of this module
|
$module->version = 2006082400; // The (date) version of this module
|
||||||
$module->requires = 2006080900; // Requires this Moodle version
|
$module->requires = 2006080900; // 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)?
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -533,7 +533,7 @@ class default_questiontype {
|
||||||
$grade .= $question->maxgrade;
|
$grade .= $question->maxgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment = stripslashes($state->comment);
|
$comment = stripslashes($state->manualcomment);
|
||||||
$commentlink = '';
|
$commentlink = '';
|
||||||
|
|
||||||
if (isset($options->questioncommentlink) && $context && has_capability('mod/quiz:grade', $context)) {
|
if (isset($options->questioncommentlink) && $context && has_capability('mod/quiz:grade', $context)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue