Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]

Numerical

Copyright: 2009 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 501 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 classes

lesson_page_type_numerical:: (12 methods):
  get_typeid()
  get_typestring()
  get_idstring()
  display()
  create_answers()
  update()
  check_answer()
  display_answers()
  stats()
  report_answers()
  update_form_data()
  format_answer()

lesson_add_page_form_numerical:: (4 methods):
  custom_definition()
  get_data()
  get_submitted_data()
  set_data()

lesson_display_answer_form_numerical:: (1 method):
  definition()


Class: lesson_page_type_numerical  - X-Ref

get_typeid()   X-Ref
No description

get_typestring()   X-Ref
No description

get_idstring()   X-Ref
No description

display($renderer, $attempt)   X-Ref
No description

create_answers($properties)   X-Ref
Creates answers for this page type.

param: object $properties The answer properties.

update($properties, $context = null, $maxbytes = null)   X-Ref
Update the answers for this page type.

param: object $properties The answer properties.
param: context $context The context for this module.
param: int $maxbytes The maximum bytes for any uploades.

check_answer()   X-Ref
No description

display_answers(html_table $table)   X-Ref
No description

stats(array &$pagestats, $tries)   X-Ref
No description

report_answers($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n)   X-Ref
No description

update_form_data(stdClass $data)   X-Ref
Make updates to the form data if required. In this case to put the all other answer data into the write section of the form.

param: stdClass $data The form data to update.
return: stdClass The updated fom data.

format_answer($answer, $context, $answerformat, $options = [])   X-Ref
Custom formats the answer to display

param: string $answer
param: context $context
param: int $answerformat
param: array $options Optional param for additional options.
return: string Returns formatted string

Class: lesson_add_page_form_numerical  - X-Ref

custom_definition()   X-Ref
No description

get_data()   X-Ref
We call get data when storing the data into the db. Override to format the floats properly

return: object|void

get_submitted_data()   X-Ref
Return submitted data if properly submitted or returns NULL if validation fails or
if there is no submitted data with formatted numbers

return: object submitted data; NULL if not valid or not submitted or cancelled

set_data($defaults)   X-Ref
Load in existing data as form defaults. Usually new entry defaults are stored directly in
form definition (new entry form); this function is used to load in data where values
already exist and data is being edited (edit entry form) after formatting numbers

param: stdClass|array $defaults object or array of default values

Class: lesson_display_answer_form_numerical  - X-Ref

definition()   X-Ref
No description