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] [Versions 400 and 401]

(no description)

File Size: 298 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.