Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
mod_h5pactivity\output\result Class Reference

Class to display an attempt tesult in mod_h5pactivity. More...

Inheritance diagram for mod_h5pactivity\output\result:
renderable templatable mod_h5pactivity\output\result\choice mod_h5pactivity\output\result\fillin mod_h5pactivity\output\result\longfillin mod_h5pactivity\output\result\matching mod_h5pactivity\output\result\other mod_h5pactivity\output\result\sequencing mod_h5pactivity\output\result\truefalse

Public Member Functions

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

Static Public Member Functions

static create_from_record (stdClass $result)
 return the correct result output depending on the interactiontype More...
 

Public Attributes

const CHECKED = 3
 Checked answer state.
 
const CORRECT = 1
 Correct answer state.
 
const FAIL = 6
 Pass answer state.
 
const INCORRECT = 2
 Incorrect answer state.
 
const PASS = 5
 Pass answer state.
 
const TEXT = 8
 Text answer state.
 
const UNCHECKED = 4
 Unchecked answer state.
 
const UNKNOWN = 7
 Unkown answer state.
 

Protected Member Functions

 __construct (stdClass $result)
 Constructor. More...
 
 export_options ()
 Return the options data structure. More...
 
 get_answer (int $state, string $answer=null)
 Return an answer data to show results. More...
 
 get_answerlabel ()
 Return a label for result user attempt answer. More...
 
 get_correctlabel ()
 Return a label for result user correct answer. More...
 
 get_description (stdClass $data)
 Extract description from data element. More...
 
 get_descriptions (array $data)
 Extract descriptions from array. More...
 
 get_optionslabel ()
 Return a label for result user options/choices. More...
 

Protected Attributes

mixed $additionals
 additional decoded data
 
mixed $correctpattern = []
 correctpattern decoded data
 
mixed $response
 response decoded data
 
stdClass $result
 result record
 

Detailed Description

Class to display an attempt tesult in mod_h5pactivity.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

mod_h5pactivity\output\result::__construct ( stdClass  $result)
protected

Constructor.

Parameters
stdClass$resulta h5pactivity_attempts_results record

Member Function Documentation

◆ create_from_record()

static mod_h5pactivity\output\result::create_from_record ( stdClass  $result)
static

return the correct result output depending on the interactiontype

Parameters
stdClass$resulth5pactivity_attempts_results record
Return values
result|nullthe result output class if any

◆ export_for_template()

mod_h5pactivity\output\result::export_for_template ( renderer_base  $output)

Export this data so it can be used as the context for a mustache template.

Parameters
renderer_base$output
Return values
stdClass

Implements templatable.

Reimplemented in mod_h5pactivity\output\result\longfillin, and mod_h5pactivity\output\result\other.

◆ export_options()

mod_h5pactivity\output\result::export_options ( )
protected

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 values
arrayof options

Reimplemented in mod_h5pactivity\output\result\choice, mod_h5pactivity\output\result\fillin, mod_h5pactivity\output\result\matching, mod_h5pactivity\output\result\sequencing, and mod_h5pactivity\output\result\truefalse.

◆ get_answer()

mod_h5pactivity\output\result::get_answer ( int  $state,
string  $answer = null 
)
protected

Return an answer data to show results.

Parameters
int$statethe answer state
string$answerthe extra text to display (default null)
Return values
stdClasswith "answer" text and the state attribute to be displayed

◆ get_answerlabel()

mod_h5pactivity\output\result::get_answerlabel ( )
protected

Return a label for result user attempt answer.

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

Return values
stringto use in options table

◆ get_correctlabel()

mod_h5pactivity\output\result::get_correctlabel ( )
protected

Return a label for result user correct answer.

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

Return values
stringto use in options table

Reimplemented in mod_h5pactivity\output\result\sequencing.

◆ get_description()

mod_h5pactivity\output\result::get_description ( stdClass  $data)
protected

Extract description from data element.

Parameters
stdClass$dataadditional attribute to parse
Return values
stringthe resulting string

◆ get_descriptions()

mod_h5pactivity\output\result::get_descriptions ( array  $data)
protected

Extract descriptions from array.

Parameters
array$dataadditional attribute to parse
Return values
string[]the resulting strings

◆ get_optionslabel()

mod_h5pactivity\output\result::get_optionslabel ( )
protected

Return a label for result user options/choices.

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

Return values
stringto use in options table

Reimplemented in mod_h5pactivity\output\result\fillin, mod_h5pactivity\output\result\matching, and mod_h5pactivity\output\result\sequencing.


The documentation for this class was generated from the following file: