Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

Contains class mod_h5pactivity\output\result

Copyright: 2020 Ferran Recio
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 300 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: result  - X-Ref

Class to display an attempt tesult in mod_h5pactivity.

__construct(stdClass $result)   X-Ref
Constructor.

param: stdClass $result a h5pactivity_attempts_results record

create_from_record(stdClass $result)   X-Ref
return the correct result output depending on the interactiontype

param: stdClass $result h5pactivity_attempts_results record
return: result|null the result output class if any

decode_response(string $value)   X-Ref
Return a decoded response structure.

param: string $value the current response structure
return: array an array of reponses

export_for_template(renderer_base $output)   X-Ref
Export this data so it can be used as the context for a mustache template.

param: renderer_base $output
return: stdClass

export_options()   X-Ref
Return the options data structure.

Result types have to override this method generate a specific options report.

An option is an object with:
- id: the option ID
- description: option description text
- useranswer (optional): what the user answer (see get_answer method)
- correctanswer (optional): the correct answer (see get_answer method)

return: array of options

get_optionslabel()   X-Ref
Return a label for result user options/choices.

Specific result types can override this method to customize
the result options table header.

return: string to use in options table

get_correctlabel()   X-Ref
Return a label for result user correct answer.

Specific result types can override this method to customize
the result options table header.

return: string to use in options table

get_answerlabel()   X-Ref
Return a label for result user attempt answer.

Specific result types can override this method to customize
the result options table header.

return: string to use in options table

get_descriptions(array $data)   X-Ref
Extract descriptions from array.

param: array $data additional attribute to parse
return: string[] the resulting strings

get_description(stdClass $data)   X-Ref
Extract description from data element.

param: stdClass $data additional attribute to parse
return: string the resulting string

get_answer(int $state, string $answer = null)   X-Ref
Return an answer data to show results.

param: int $state the answer state
param: string $answer the extra text to display (default null)
return: stdClass with "answer" text and the state attribute to be displayed