mirror of
https://github.com/moodle/moodle.git
synced 2025-03-19 15:10:05 +01:00
MDL-79863 qtype_ordering: qtype_ordering return result from 'summarize_response' for use in 'Technical information' and Response report
This commit is contained in:
parent
b837d03eb0
commit
3b28181bf6
@ -217,7 +217,27 @@ class qtype_ordering_question extends question_graded_automatically {
|
||||
* @return string a plain text summary of that response, that could be used in reports.
|
||||
*/
|
||||
public function summarise_response(array $response) {
|
||||
return '';
|
||||
$name = $this->get_response_fieldname();
|
||||
if (array_key_exists($name, $response)) {
|
||||
$items = explode(',', $response[$name]);
|
||||
} else {
|
||||
$items = array(); // shouldn't happen !!
|
||||
}
|
||||
$answerids = array();
|
||||
foreach ($this->answers as $answer) {
|
||||
$answerids[$answer->md5key] = $answer->id;
|
||||
}
|
||||
foreach ($items as $i => $item) {
|
||||
if (array_key_exists($item, $answerids)) {
|
||||
$item = $this->answers[$answerids[$item]];
|
||||
$item = $this->html_to_text($item->answer, $item->answerformat);
|
||||
$item = shorten_text($item, 10, true); // force truncate at 10 chars
|
||||
$items[$i] = $item;
|
||||
} else {
|
||||
$items[$i] = ''; // shouldn't happen !!
|
||||
}
|
||||
}
|
||||
return implode('; ', array_filter($items));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -451,7 +471,7 @@ class qtype_ordering_question extends question_graded_automatically {
|
||||
*/
|
||||
public function update_current_response($response) {
|
||||
$name = $this->get_response_fieldname();
|
||||
if (isset($response[$name])) {
|
||||
if (array_key_exists($name, $response)) {
|
||||
$ids = explode(',', $response[$name]);
|
||||
foreach ($ids as $i => $id) {
|
||||
foreach ($this->answers as $answer) {
|
||||
|
@ -29,5 +29,5 @@ $plugin->cron = 0;
|
||||
$plugin->component = 'qtype_ordering';
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
$plugin->requires = 2010112400; // Moodle 2.0
|
||||
$plugin->version = 2017050859;
|
||||
$plugin->release = '2017-05-08 (59)';
|
||||
$plugin->version = 2017070160;
|
||||
$plugin->release = '2017-07-01 (60)';
|
||||
|
Loading…
x
Reference in New Issue
Block a user