mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-31306 question preview: disable 'Fill correct' for qtypes that can't
This commit is contained in:
parent
1bc47427f0
commit
da22c0127b
4 changed files with 13 additions and 5 deletions
|
@ -987,11 +987,15 @@ class question_attempt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a set of response data for this question attempt that would get the
|
* Get a set of response data for this question attempt that would get the
|
||||||
* best possible mark.
|
* best possible mark. If it is not possible to compute a correct
|
||||||
* @return array name => value pairs that could be passed to {@link process_action()}.
|
* response, this method should return null.
|
||||||
|
* @return array|null name => value pairs that could be passed to {@link process_action()}.
|
||||||
*/
|
*/
|
||||||
public function get_correct_response() {
|
public function get_correct_response() {
|
||||||
$response = $this->question->get_correct_response();
|
$response = $this->question->get_correct_response();
|
||||||
|
if (is_null($response)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$imvars = $this->behaviour->get_correct_response();
|
$imvars = $this->behaviour->get_correct_response();
|
||||||
foreach ($imvars as $name => $value) {
|
foreach ($imvars as $name => $value) {
|
||||||
$response['-' . $name] = $value;
|
$response['-' . $name] = $value;
|
||||||
|
|
|
@ -582,6 +582,7 @@ class question_usage_by_activity {
|
||||||
/**
|
/**
|
||||||
* Get the correct response to a particular question. Passing the results of
|
* Get the correct response to a particular question. Passing the results of
|
||||||
* this method to {@link process_action()} will probably result in full marks.
|
* this method to {@link process_action()} will probably result in full marks.
|
||||||
|
* If it is not possible to compute a correct response, this method should return null.
|
||||||
* @param int $slot the number used to identify this question within this usage.
|
* @param int $slot the number used to identify this question within this usage.
|
||||||
* @return array that constitutes a correct response to this question.
|
* @return array that constitutes a correct response to this question.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -211,7 +211,9 @@ $filldisabled = '';
|
||||||
if ($quba->get_question_state($slot)->is_finished()) {
|
if ($quba->get_question_state($slot)->is_finished()) {
|
||||||
$finishdisabled = ' disabled="disabled"';
|
$finishdisabled = ' disabled="disabled"';
|
||||||
$filldisabled = ' disabled="disabled"';
|
$filldisabled = ' disabled="disabled"';
|
||||||
} else if (is_null($quba->get_correct_response($slot))) {
|
}
|
||||||
|
// If question type cannot give us a correct response, disable this button.
|
||||||
|
if (is_null($quba->get_correct_response($slot))) {
|
||||||
$filldisabled = ' disabled="disabled"';
|
$filldisabled = ' disabled="disabled"';
|
||||||
}
|
}
|
||||||
if (!$previewid) {
|
if (!$previewid) {
|
||||||
|
|
|
@ -262,9 +262,10 @@ abstract class question_definition {
|
||||||
/**
|
/**
|
||||||
* What data would need to be submitted to get this question correct.
|
* What data would need to be submitted to get this question correct.
|
||||||
* If there is more than one correct answer, this method should just
|
* If there is more than one correct answer, this method should just
|
||||||
* return one possibility.
|
* return one possibility. If it is not possible to compute a correct
|
||||||
|
* response, this method should return null.
|
||||||
*
|
*
|
||||||
* @return array parameter name => value.
|
* @return array|null parameter name => value.
|
||||||
*/
|
*/
|
||||||
public abstract function get_correct_response();
|
public abstract function get_correct_response();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue