mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-63185 core_question: add callback to some question types
Part of MDL-62610
This commit is contained in:
parent
3c4ff02e41
commit
71fc74cee5
@ -89,6 +89,14 @@ class qtype_essay_question extends question_with_responses {
|
||||
}
|
||||
}
|
||||
|
||||
public function un_summarise_response(string $summary) {
|
||||
if (!empty($summary)) {
|
||||
return ['answer' => $summary];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function get_correct_response() {
|
||||
return null;
|
||||
}
|
||||
|
@ -85,6 +85,20 @@ class qtype_numerical_question extends question_graded_automatically {
|
||||
return $resp;
|
||||
}
|
||||
|
||||
public function un_summarise_response(string $response) {
|
||||
if (!empty($response)) {
|
||||
$resp = $response;
|
||||
} else {
|
||||
$resp = null;
|
||||
}
|
||||
|
||||
if ($this->has_separate_unit_field() && !empty($response)) {
|
||||
$resp = $this->ap->add_unit($resp, $response);
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
public function is_gradable_response(array $response) {
|
||||
return array_key_exists('answer', $response) &&
|
||||
($response['answer'] || $response['answer'] === '0' || $response['answer'] === 0);
|
||||
|
@ -57,6 +57,14 @@ class qtype_shortanswer_question extends question_graded_by_strategy
|
||||
}
|
||||
}
|
||||
|
||||
public function un_summarise_response(string $summary) {
|
||||
if (!empty($summary)) {
|
||||
return ['answer' => $summary];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function is_complete_response(array $response) {
|
||||
return array_key_exists('answer', $response) &&
|
||||
($response['answer'] || $response['answer'] === '0');
|
||||
|
Loading…
x
Reference in New Issue
Block a user