Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-40264-m25-essay-zero' of git://github.com/ktemkin/m…

…oodle into MOODLE_25_STABLE
  • Loading branch information...
commit ffc480afbd60d4851cbeff1f69da8db5d3f7a0ab 2 parents 3d4a0f2 + 11f6680
@stronk7 stronk7 authored
View
2  question/type/essay/question.php
@@ -84,7 +84,7 @@ public function get_correct_response() {
}
public function is_complete_response(array $response) {
- return !empty($response['answer']);
+ return array_key_exists('answer', $response) && ($response['answer'] !== '');
}
public function is_same_response(array $prevresponse, array $newresponse) {
View
15 question/type/essay/tests/question_test.php
@@ -137,4 +137,19 @@ public function test_is_same_response_with_template() {
array('answer' => ''),
array('answer' => '0')));
}
+
+ public function test_is_complete_response() {
+
+ $essay = test_question_maker::make_an_essay_question();
+ $essay->start_attempt(new question_attempt_step(), 1);
+
+ // The empty string should be considered an empty response, as should a lack of a response.
+ $this->assertFalse($essay->is_complete_response(array('answer' => '')));
+ $this->assertFalse($essay->is_complete_response(array()));
+
+ // Any nonempty string should be considered a complete response.
+ $this->assertTrue($essay->is_complete_response(array('answer' => 'A student response.')));
+ $this->assertTrue($essay->is_complete_response(array('answer' => '0 times.')));
+ $this->assertTrue($essay->is_complete_response(array('answer' => '0')));
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.