[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/type/numerical/ -> questiontype.php (summary)

Question type class for the numerical question type.

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 733 lines (27 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 2 classes

qtype_numerical:: (17 methods):
  get_question_options()
  get_numerical_units()
  get_default_numerical_unit()
  get_numerical_options()
  save_question_options()
  save_unit_options()
  save_units()
  initialise_question_instance()
  initialise_numerical_answers()
  make_answer_processor()
  delete_question()
  get_random_guess_score()
  add_unit()
  get_possible_responses()
  apply_unit()
  move_files()
  delete_files()

qtype_numerical_answer_processor:: (13 methods):
  __construct()
  set_characters()
  get_point()
  get_separator()
  contains_thousands_seaparator()
  build_regex()
  parse_response()
  apply_units()
  get_default_unit()
  add_unit()
  is_known_unit()
  are_units_before()
  get_unit_options()


Class: qtype_numerical  - X-Ref

The numerical question type class.

This class contains some special features in order to make the
question type embeddable within a multianswer (cloze) question

get_question_options($question)   X-Ref
No description

get_numerical_units(&$question)   X-Ref
No description

get_default_numerical_unit($question)   X-Ref
No description

get_numerical_options($question)   X-Ref
No description

save_question_options($question)   X-Ref
Save the units and the answers associated with this question.


save_unit_options($question)   X-Ref
The numerical options control the display and the grading of the unit
part of the numerical question and related types (calculateds)
Questions previous to 2.0 do not have this table as multianswer questions
in all versions including 2.0. The default values are set to give the same grade
as old question.


save_units($question)   X-Ref
No description

initialise_question_instance(question_definition $question, $questiondata)   X-Ref
No description

initialise_numerical_answers(question_definition $question, $questiondata)   X-Ref
No description

make_answer_processor($units, $unitsleft)   X-Ref
No description

delete_question($questionid, $contextid)   X-Ref
No description

get_random_guess_score($questiondata)   X-Ref
No description

add_unit($questiondata, $answer, $unit = null)   X-Ref
Add a unit to a response for display.

param: object $questiondata the data defining the quetsion.
param: string $answer a response.
param: object $unit a unit. If null, {@link get_default_numerical_unit()}

get_possible_responses($questiondata)   X-Ref
No description

apply_unit($rawresponse, $units, $unitsleft)   X-Ref
Checks if the $rawresponse has a unit and applys it if appropriate.

param: string $rawresponse  The response string to be converted to a float.
param: array $units         An array with the defined units, where the
return: float               The rawresponse with the unit taken into

move_files($questionid, $oldcontextid, $newcontextid)   X-Ref
No description

delete_files($questionid, $contextid)   X-Ref
No description

Class: qtype_numerical_answer_processor  - X-Ref

This class processes numbers with units.

__construct($units, $unitsbefore = false, $decsep = null,$thousandssep = null)   X-Ref
No description

set_characters($decsep, $thousandssep)   X-Ref
Set the decimal point and thousands separator character that should be used.

param: string $decsep
param: string $thousandssep

get_point()   X-Ref
No description

get_separator()   X-Ref
No description

contains_thousands_seaparator($value)   X-Ref

return: book If the student's response contains a '.' or a ',' that

build_regex()   X-Ref
Create the regular expression that {@link parse_response()} requires.

return: string

parse_response($response)   X-Ref
This method can be used for more locale-strict parsing of repsonses. At the
moment we don't use it, and instead use the more lax parsing in apply_units.
This is just a note that this funciton was used in the past, so if you are
intersted, look through version control history.

Take a string which is a number with or without a decimal point and exponent,
and possibly followed by one of the units, and split it into bits.
param: string $response a value, optionally with a unit.
return: array four strings (some of which may be blank) the digits before

apply_units($response, $separateunit = null)   X-Ref
Takes a number in almost any localised form, and possibly with a unit
after it. It separates off the unit, if present, and converts to the
default unit, by using the given unit multiplier.

param: string $response a value, optionally with a unit.
return: array(numeric, sting) the value with the unit stripped, and normalised

get_default_unit()   X-Ref

return: string the default unit.

add_unit($answer, $unit = null)   X-Ref

param: string $answer a response.
param: string $unit a unit.

is_known_unit($unit)   X-Ref
Is this unit recognised.

param: string $unit the unit
return: bool whether this is a unit we recognise.

are_units_before()   X-Ref
Whether the units go before or after the number.

return: true = before, false = after.

get_unit_options()   X-Ref
Get the units as an array suitably for passing to html_writer::select.

return: array of unit choices.



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1