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]

Upgrade library code for the calculated question type.

Copyright: 2011 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 302 lines (11 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: qtype_calculated_qe2_attempt_updater  - X-Ref

Class for converting attempt data for calculated questions when upgrading
attempts to the new question engine.

This class is used by the code in question/engine/upgrade/upgradelib.php.

question_summary()   X-Ref


right_answer()   X-Ref
No description

parse_response($state)   X-Ref
No description

response_summary($state)   X-Ref
No description

was_answered($state)   X-Ref
No description

set_first_step_data_elements($state, &$data)   X-Ref
No description

supply_missing_first_step_data(&$data)   X-Ref
No description

set_data_elements_for_step($state, &$data)   X-Ref
No description

load_dataset($selecteditem)   X-Ref
No description

format_float($x, $length = null, $format = null)   X-Ref
This function should be identical to
{@link qtype_calculated_variable_substituter::format_float()}. Except that
we do not try to do locale-aware replacement of the decimal point.

Having to copy it here is a pain, but it is the standard rule about not
using library code (which may change in future) in upgrade code, which
exists at a point in time.

Display a float properly formatted with a certain number of decimal places.
param: number $x the number to format
param: int $length restrict to this many decimal places or significant
param: int format 1 => decimalformat, 2 => significantfigures.
return: string formtted number.

calculate($expression)   X-Ref
Evaluate an expression using the variable values.

param: string $expression the expression. A PHP expression with placeholders
return: float the computed result.

calculate_raw($expression)   X-Ref
Evaluate an expression after the variable values have been substituted.

param: string $expression the expression. A PHP expression with placeholders
return: float the computed result.

substitute_values_for_eval($expression)   X-Ref
Substitute variable placehodlers like {a} with their value wrapped in ().

param: string $expression the expression. A PHP expression with placeholders
return: string the expression with each placeholder replaced by the

substitute_values_pretty($text)   X-Ref
Substitute variable placehodlers like {a} with their value without wrapping
the value in anything.

param: string $text some content with placeholders
return: string the expression with each placeholder replaced by the

replace_expressions_in_text($text, $length = null, $format = null)   X-Ref
Replace any embedded variables (like {a}) or formulae (like {={a} + {b}})
in some text with the corresponding values.

param: string $text the text to process.
return: string the text with values substituted.