diff --git a/mod/h5pactivity/classes/external/get_results.php b/mod/h5pactivity/classes/external/get_results.php index a37ab62afef..633631f7039 100644 --- a/mod/h5pactivity/classes/external/get_results.php +++ b/mod/h5pactivity/classes/external/get_results.php @@ -150,7 +150,7 @@ class get_results extends external_api { 'attempt' => $attemptdata->attempt, 'rawscore' => $attemptdata->rawscore, 'maxscore' => $attemptdata->maxscore, - 'duration' => (empty($attemptdata->duration)) ? 0 : $attemptdata->duration, + 'duration' => (empty($attemptdata->durationvalue)) ? 0 : $attemptdata->durationvalue, 'scaled' => (empty($attemptdata->scaled)) ? 0 : $attemptdata->scaled, 'results' => [], ]; @@ -257,7 +257,8 @@ class get_results extends external_api { 'subcontent' => new external_value(PARAM_NOTAGS, 'Subcontent identifier'), 'timecreated' => new external_value(PARAM_INT, 'Result creation'), 'interactiontype' => new external_value(PARAM_NOTAGS, 'Interaction type'), - 'description' => new external_value(PARAM_TEXT, 'Result description'), + 'description' => new external_value(PARAM_RAW, 'Result description'), + 'content' => new external_value(PARAM_RAW, 'Result extra content', VALUE_OPTIONAL), 'rawscore' => new external_value(PARAM_INT, 'Result score value'), 'maxscore' => new external_value(PARAM_INT, 'Result max score'), 'duration' => new external_value(PARAM_INT, 'Result duration in seconds', VALUE_OPTIONAL, 0), @@ -269,10 +270,10 @@ class get_results extends external_api { 'track' => new external_value(PARAM_BOOL, 'If the result has valid track information', VALUE_OPTIONAL), 'options' => new external_multiple_structure( new external_single_structure([ - 'description' => new external_value(PARAM_TEXT, 'Option description'), - 'id' => new external_value(PARAM_INT, 'Option identifier'), - 'correctanswer' => self::get_answer_returns('The option correct answer'), - 'useranswer' => self::get_answer_returns('The option user answer'), + 'description' => new external_value(PARAM_RAW, 'Option description', VALUE_OPTIONAL), + 'id' => new external_value(PARAM_TEXT, 'Option string identifier', VALUE_OPTIONAL), + 'correctanswer' => self::get_answer_returns('The option correct answer', VALUE_OPTIONAL), + 'useranswer' => self::get_answer_returns('The option user answer', VALUE_OPTIONAL), ]), 'The statement options', VALUE_OPTIONAL ), @@ -284,9 +285,10 @@ class get_results extends external_api { * Return the external structure of an answer or correctanswer * * @param string $description the return description + * @param int $required the return required value * @return external_single_structure */ - private static function get_answer_returns(string $description): external_single_structure { + private static function get_answer_returns(string $description, int $required = VALUE_REQUIRED): external_single_structure { $result = new external_single_structure([ 'answer' => new external_value(PARAM_NOTAGS, 'Option text value', VALUE_OPTIONAL), @@ -297,7 +299,7 @@ class get_results extends external_api { 'unchecked' => new external_value(PARAM_BOOL, 'If has to be displayed as a unchecked option', VALUE_OPTIONAL), 'pass' => new external_value(PARAM_BOOL, 'If has to be displayed as passed', VALUE_OPTIONAL), 'fail' => new external_value(PARAM_BOOL, 'If has to be displayed as failed', VALUE_OPTIONAL), - ], $description); + ], $description, $required); return $result; } } diff --git a/mod/h5pactivity/classes/output/attempt.php b/mod/h5pactivity/classes/output/attempt.php index ac433b44886..6168e969924 100644 --- a/mod/h5pactivity/classes/output/attempt.php +++ b/mod/h5pactivity/classes/output/attempt.php @@ -96,7 +96,8 @@ class attempt implements renderable, templatable { ]), ]; if ($attempt->get_duration() !== null) { - $duration = $this->extract_duration($attempt->get_duration()); + $data->durationvalue = $attempt->get_duration(); + $duration = $this->extract_duration($data->durationvalue); $data->duration = $this->format_duration($duration); $data->durationcompact = $this->format_duration_short($duration); } diff --git a/mod/h5pactivity/classes/output/result/sequencing.php b/mod/h5pactivity/classes/output/result/sequencing.php index 286d1ed10f2..f31aec11f9b 100644 --- a/mod/h5pactivity/classes/output/result/sequencing.php +++ b/mod/h5pactivity/classes/output/result/sequencing.php @@ -63,7 +63,7 @@ class sequencing extends result { continue; } $option = (object)[ - 'id' => true, + 'id' => 'true', 'description' => get_string('result_sequencing_position', 'mod_h5pactivity', $num), 'correctanswer' => $this->get_answer(parent::TEXT, $choices[$pattern]->description), 'correctanswerid' => 'item_'.$key, diff --git a/mod/h5pactivity/classes/output/result/truefalse.php b/mod/h5pactivity/classes/output/result/truefalse.php index a16cf1a5a35..aee3b8dc3ec 100644 --- a/mod/h5pactivity/classes/output/result/truefalse.php +++ b/mod/h5pactivity/classes/output/result/truefalse.php @@ -47,16 +47,18 @@ class truefalse extends result { // This interaction type have only one entry which is the correct option. $correctpattern = reset($this->correctpattern); $correctpattern = filter_var(reset($correctpattern), FILTER_VALIDATE_BOOLEAN); + $correctpattern = $correctpattern ? 'true' : 'false'; $response = filter_var(reset($this->response), FILTER_VALIDATE_BOOLEAN); + $response = $response ? 'true' : 'false'; $options = [ (object)[ - 'id' => true, + 'id' => 'true', 'description' => get_string('true', 'mod_h5pactivity'), ], (object)[ - 'id' => false, + 'id' => 'false', 'description' => get_string('false', 'mod_h5pactivity'), ], ]; diff --git a/mod/h5pactivity/version.php b/mod/h5pactivity/version.php index 6bfe3b6bf81..308fe0da0d9 100644 --- a/mod/h5pactivity/version.php +++ b/mod/h5pactivity/version.php @@ -25,5 +25,5 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_h5pactivity'; -$plugin->version = 2020052100; +$plugin->version = 2020052900; $plugin->requires = 2020013000;