Skip to content

Commit

Permalink
Merge branch 'MDL-38311' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Mar 6, 2013
2 parents ab1e921 + 53b8e25 commit 9f4da03
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion question/behaviour/adaptive/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function test_adaptive_multichoice() {
$this->get_contains_correct_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 1);
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function test_multichoice() {
$this->get_contains_correct_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 1);
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down
2 changes: 1 addition & 1 deletion question/behaviour/deferredcbm/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function test_deferred_cbm_truefalse_high_certainty() {
$this->get_contains_correct_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 1);
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function test_deferredfeedback_feedback_truefalse() {
$this->quba->get_response_summary($this->slot));

// Process a manual comment.
$this->manual_grade('Not good enough!', 1);
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);

$this->check_current_state(question_state::$mangrpartial);
$this->check_current_mark(1);
Expand Down
4 changes: 2 additions & 2 deletions question/behaviour/immediatecbm/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function test_immediatecbm_feedback_multichoice_right() {
$this->get_contains_correct_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 0.5);
$this->manual_grade('Not good enough!', 0.5, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down Expand Up @@ -176,7 +176,7 @@ public function test_immediatecbm_feedback_multichoice_try_to_submit_blank() {
$this->get_contains_mc_radio_expectation(2, false, false));

// Process a manual comment.
$this->manual_grade('Not good enough!', 0.5);
$this->manual_grade('Not good enough!', 0.5, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function test_immediatefeedback_feedback_multichoice_right() {
$this->get_contains_correct_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 0.5);
$this->manual_grade('Not good enough!', 0.5, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down Expand Up @@ -185,7 +185,7 @@ public function test_immediatefeedback_feedback_multichoice_try_to_submit_blank(
$this->get_contains_mc_radio_expectation(2, false, false));

// Process a manual comment.
$this->manual_grade('Not good enough!', 0.5);
$this->manual_grade('Not good enough!', 0.5, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down
4 changes: 2 additions & 2 deletions question/behaviour/informationitem/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function test_informationitem_feedback_description() {
$this->get_contains_general_feedback_expectation($description));

// Process a manual comment.
$this->manual_grade('Not good enough!', null);
$this->manual_grade('Not good enough!', null, FORMAT_HTML);

$this->check_current_state(question_state::$manfinished);
$this->check_current_mark(null);
Expand All @@ -83,6 +83,6 @@ public function test_informationitem_feedback_description() {

// Check that trying to process a manual comment with a grade causes an exception.
$this->setExpectedException('moodle_exception');
$this->manual_grade('Not good enough!', 1);
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);
}
}
2 changes: 1 addition & 1 deletion question/behaviour/interactive/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function test_interactive_feedback_multichoice_right() {
$this->get_no_hint_visible_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 0.5);
$this->manual_grade('Not good enough!', 0.5, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrpartial);
Expand Down
16 changes: 8 additions & 8 deletions question/behaviour/manualgraded/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function test_manual_graded_essay() {
$this->quba->get_response_summary($this->slot));

// Process a manual comment.
$this->manual_grade('Not good enough!', 10);
$this->manual_grade('Not good enough!', 10, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrright);
Expand Down Expand Up @@ -182,7 +182,7 @@ public function test_manual_graded_truefalse() {
$this->get_does_not_contain_specific_feedback_expectation());

// Process a manual comment.
$this->manual_grade('Not good enough!', 1);
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);

$this->check_current_state(question_state::$mangrpartial);
$this->check_current_mark(1);
Expand Down Expand Up @@ -223,14 +223,14 @@ public function test_manual_graded_ignore_repeat_sumbission() {

// Process a blank manual comment. Ensure it does not change the state.
$numsteps = $this->get_step_count();
$this->manual_grade('', '');
$this->manual_grade('', '', FORMAT_HTML);
$this->check_step_count($numsteps);
$this->check_current_state(question_state::$needsgrading);
$this->check_current_mark(null);

// Process a comment, but with the mark blank. Should be recorded, but
// not change the mark.
$this->manual_grade('I am not sure what grade to award.', '');
$this->manual_grade('I am not sure what grade to award.', '', FORMAT_HTML);
$this->check_step_count($numsteps + 1);
$this->check_current_state(question_state::$needsgrading);
$this->check_current_mark(null);
Expand All @@ -239,21 +239,21 @@ public function test_manual_graded_ignore_repeat_sumbission() {
preg_quote('I am not sure what grade to award.', '/') . '/'));

// Now grade it.
$this->manual_grade('Pretty good!', '9.00000');
$this->manual_grade('Pretty good!', '9.00000', FORMAT_HTML);
$this->check_step_count($numsteps + 2);
$this->check_current_state(question_state::$mangrpartial);
$this->check_current_mark(9);
$this->check_current_output(
new question_pattern_expectation('/' . preg_quote('Pretty good!', '/') . '/'));

// Process the same data again, and make sure it does not add a step.
$this->manual_grade('Pretty good!', '9.00000');
$this->manual_grade('Pretty good!', '9.00000', FORMAT_HTML);
$this->check_step_count($numsteps + 2);
$this->check_current_state(question_state::$mangrpartial);
$this->check_current_mark(9);

// Now set the mark back to blank.
$this->manual_grade('Actually, I am not sure any more.', '');
$this->manual_grade('Actually, I am not sure any more.', '', FORMAT_HTML);
$this->check_step_count($numsteps + 3);
$this->check_current_state(question_state::$needsgrading);
$this->check_current_mark(null);
Expand Down Expand Up @@ -303,7 +303,7 @@ public function test_manual_graded_essay_can_grade_0() {
$this->quba->get_response_summary($this->slot));

// Process a blank comment and a grade of 0.
$this->manual_grade('', 0);
$this->manual_grade('', 0, FORMAT_HTML);

// Verify.
$this->check_current_state(question_state::$mangrwrong);
Expand Down
13 changes: 9 additions & 4 deletions question/engine/questionattempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,14 +1114,19 @@ public function regrade(question_attempt $oldqa, $finished) {

/**
* Perform a manual grading action on this attempt.
* @param $comment the comment being added.
* @param $mark the new mark. (Optional, if not given, then only a comment is added.)
* @param string $comment the comment being added.
* @param float $mark the new mark. If null, then only a comment is added.
* @param int $commentformat the FORMAT_... for $comment. Must be given.
* @param int $timestamp the time to record for the action. (If not given, use now.)
* @param int $userid the user to attribute the aciton to. (If not given, use the current user.)
* @return unknown_type
*/
public function manual_grade($comment, $mark, $timestamp = null, $userid = null) {
public function manual_grade($comment, $mark, $commentformat = null, $timestamp = null, $userid = null) {
$submitteddata = array('-comment' => $comment);
if (is_null($commentformat)) {
debugging('You should pass $commentformat to manual_grade.', DEBUG_DEVELOPER);
$commentformat = FORMAT_HTML;
}
$submitteddata['-commentformat'] = $commentformat;
if (!is_null($mark)) {
$submitteddata['-mark'] = $mark;
$submitteddata['-maxmark'] = $this->maxmark;
Expand Down
4 changes: 2 additions & 2 deletions question/engine/questionusage.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,9 @@ public function finish_all_questions($timestamp = null) {
* @param number $mark the mark that is being assigned. Can be null to just
* add a comment.
*/
public function manual_grade($slot, $comment, $mark) {
public function manual_grade($slot, $comment, $mark, $commentformat = null) {
$qa = $this->get_question_attempt($slot);
$qa->manual_grade($comment, $mark);
$qa->manual_grade($comment, $mark, $commentformat);
$this->observer->notify_attempt_modified($qa);
}

Expand Down
4 changes: 2 additions & 2 deletions question/engine/tests/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ protected function process_submission($data) {
$this->quba->process_action($this->slot, $data);
}

protected function manual_grade($comment, $mark) {
$this->quba->manual_grade($this->slot, $comment, $mark);
protected function manual_grade($comment, $mark, $commentformat = null) {
$this->quba->manual_grade($this->slot, $comment, $mark, $commentformat);
}

protected function check_current_state($state) {
Expand Down
2 changes: 1 addition & 1 deletion question/engine/tests/unitofwork_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function test_add_and_start_question() {

public function test_process_action() {

$this->quba->manual_grade($this->slot, 'Acutally, that is not quite right', 0.5);
$this->quba->manual_grade($this->slot, 'Acutally, that is not quite right', 0.5, FORMAT_HTML);

// Here, however, were we are adding a step to an existing qa, we do need to track that.
$this->assertEquals(0, count($this->observer->get_attempts_added()));
Expand Down

0 comments on commit 9f4da03

Please sign in to comment.