Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

Unit tests for the Moodle XML format.

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

Defines 2 classes


Class: qformat_xml_test  - X-Ref

Unit tests for the matching question definition class.

assert_same_xml($expectedxml, $xml)   X-Ref
No description

make_test_question()   X-Ref
No description

remove_irrelevant_form_data_fields($expectedq)   X-Ref
The data the XML import format sends to save_question is not exactly
the same as the data returned from the editing form, so this method
makes necessary changes to the return value of
test_question_maker::get_question_form_data so that the tests can work.

param: object $expectedq as returned by get_question_form_data.
return: object one more likely to match the return value of import_...().

itemid_to_files($var)   X-Ref
Becuase XML import uses a files array instead of an itemid integer to
handle saving files with a question, we need to covert the output of
test_question_maker::get_question_form_data to match. This method recursively
replaces all array elements with key itemid with an array entry with
key files and value an empty array.

param: mixed $var any data structure.
return: mixed an equivalent structure with the relacements made.

test_xml_escape_simple_input_not_escaped()   X-Ref
No description

test_xml_escape_html_wrapped_in_cdata()   X-Ref
No description

test_xml_escape_script_tag_handled_ok()   X-Ref
No description

test_xml_escape_code_that_looks_like_cdata_end_ok()   X-Ref
No description

test_write_hint_basic()   X-Ref
No description

test_write_hint_with_parts()   X-Ref
No description

test_import_hints_no_parts()   X-Ref
No description

test_import_hints_with_parts()   X-Ref
No description

test_import_no_hints_no_error()   X-Ref
No description

test_import_description()   X-Ref
No description

test_export_description()   X-Ref
No description

test_import_essay_20()   X-Ref
No description

test_import_essay_21()   X-Ref
No description

test_export_essay()   X-Ref
No description

test_import_match_19()   X-Ref
No description

test_export_match()   X-Ref
No description

test_import_multichoice_19()   X-Ref
No description

test_export_multichoice()   X-Ref
No description

test_import_numerical_19()   X-Ref
No description

test_export_numerical()   X-Ref
No description

test_import_shortanswer_19()   X-Ref
No description

test_export_shortanswer()   X-Ref
No description

test_import_truefalse_19()   X-Ref
No description

test_import_truefalse_with_idnumber()   X-Ref
No description

test_export_truefalse()   X-Ref
No description

test_export_truefalse_with_idnumber()   X-Ref
No description

test_import_multianswer()   X-Ref
No description

test_export_multianswer()   X-Ref
No description

test_export_multianswer_withdollars()   X-Ref
No description

test_import_files_as_draft()   X-Ref
No description

test_import_truefalse_wih_files()   X-Ref
No description

test_create_dummy_question()   X-Ref
No description

Class: mock_qformat_xml  - X-Ref

Class mock_qformat_xml exists only to enable testing of the create dummy question category.

mock_create_dummy_question_representing_category(string $categoryname, $categoryinfo)   X-Ref
Make public an otherwise protected function.

param: string $categoryname the name of the category
param: object $categoryinfo description of the category