Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31306 question preview: disable 'Fill correct' for qtypes that can't

  • Loading branch information...
commit 5d2dce09b3d76ab05df8cc717d714656041a41e0 1 parent d0c82a5
Mahmoud Kassaei mkassaei authored samhemelryk committed
8 question/engine/questionattempt.php
@@ -987,11 +987,15 @@ public function get_submitted_data($postdata = null) {
987 987
988 988 /**
989 989 * Get a set of response data for this question attempt that would get the
990   - * best possible mark.
991   - * @return array name => value pairs that could be passed to {@link process_action()}.
  990 + * best possible mark. If it is not possible to compute a correct
  991 + * response, this method should return null.
  992 + * @return array|null name => value pairs that could be passed to {@link process_action()}.
992 993 */
993 994 public function get_correct_response() {
994 995 $response = $this->question->get_correct_response();
  996 + if (is_null($response)) {
  997 + return null;
  998 + }
995 999 $imvars = $this->behaviour->get_correct_response();
996 1000 foreach ($imvars as $name => $value) {
997 1001 $response['-' . $name] = $value;
1  question/engine/questionusage.php
@@ -582,6 +582,7 @@ public function update_question_flags($postdata = null) {
582 582 /**
583 583 * Get the correct response to a particular question. Passing the results of
584 584 * this method to {@link process_action()} will probably result in full marks.
  585 + * If it is not possible to compute a correct response, this method should return null.
585 586 * @param int $slot the number used to identify this question within this usage.
586 587 * @return array that constitutes a correct response to this question.
587 588 */
4 question/preview.php
@@ -211,7 +211,9 @@
211 211 if ($quba->get_question_state($slot)->is_finished()) {
212 212 $finishdisabled = ' disabled="disabled"';
213 213 $filldisabled = ' disabled="disabled"';
214   -} else if (is_null($quba->get_correct_response($slot))) {
  214 +}
  215 +// If question type cannot give us a correct response, disable this button.
  216 +if (is_null($quba->get_correct_response($slot))) {
215 217 $filldisabled = ' disabled="disabled"';
216 218 }
217 219 if (!$previewid) {
5 question/type/questionbase.php
@@ -262,9 +262,10 @@ public function get_renderer(moodle_page $page) {
262 262 /**
263 263 * What data would need to be submitted to get this question correct.
264 264 * If there is more than one correct answer, this method should just
265   - * return one possibility.
  265 + * return one possibility. If it is not possible to compute a correct
  266 + * response, this method should return null.
266 267 *
267   - * @return array parameter name => value.
  268 + * @return array|null parameter name => value.
268 269 */
269 270 public abstract function get_correct_response();
270 271

0 comments on commit 5d2dce0

Please sign in to comment.
Something went wrong with that request. Please try again.