Merge branch 'MDL-43929' of git://github.com/timhunt/moodle

This commit is contained in:
Sam Hemelryk 2014-02-11 08:27:35 +13:00
commit 39a0509b68
3 changed files with 23 additions and 2 deletions

View File

@ -192,7 +192,7 @@ abstract class question_behaviour {
return array();
}
$vars = array('comment' => PARAM_RAW);
$vars = array('comment' => PARAM_RAW, 'commentformat' => PARAM_INT);
if ($this->qa->get_max_mark()) {
$vars['mark'] = question_attempt::PARAM_MARK;
$vars['maxmark'] = PARAM_FLOAT;

View File

@ -71,7 +71,7 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
public function manual_comment_fields(question_attempt $qa, question_display_options $options) {
$inputname = $qa->get_behaviour_field_name('comment');
$id = $inputname . '_id';
list($commenttext, $commentformat) = $qa->get_manual_comment();
list($commenttext, $commentformat) = $qa->get_current_manual_comment();
$editor = editors_get_preferred_editor($commentformat);
$strformats = format_text_menu();

View File

@ -1284,6 +1284,27 @@ class question_attempt {
return array(null, null);
}
/**
* This is used by the manual grading code, particularly in association with
* validation. If there is a comment submitted in the request, then use that,
* otherwise use the latest comment for this question.
* @return number the current mark for this question.
* {@link get_fraction()} * {@link get_max_mark()}.
*/
public function get_current_manual_comment() {
$comment = $this->get_submitted_var($this->get_behaviour_field_name('comment'), PARAM_RAW);
if (is_null($comment)) {
return $this->get_manual_comment();
} else {
$commentformat = $this->get_submitted_var(
$this->get_behaviour_field_name('commentformat'), PARAM_INT);
if ($commentformat === null) {
$commentformat = FORMAT_HTML;
}
return array($comment, $commentformat);
}
}
/**
* Break down a student response by sub part and classification.
* See also {@link question_type::get_possible_responses()}