Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

Missing word question importer.

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

Defines 1 class

qformat_missingword:: (3 methods):
  provide_import()
  validate_file()
  readquestion()


Class: qformat_missingword  - X-Ref

Missing word question importer.

This Moodle class provides all functions necessary to import and export
one-correct-answer multiple choice questions in this format:

As soon as we begin to explore our body parts as infants
we become students of {=anatomy and physiology ~reflexology
~science ~experiment}, and in a sense we remain students for life.

Each answer is separated with a tilde ~, and the correct answer is
prefixed with an equals sign =

Percentage weights can be included by following the tilde with the
desired percent.  Comments can be included for each choice by following
the comment with a hash mark ("#") and the comment.  Example:

This is {=the best answer#comment on the best answer ~75%a good
answer#comment on the good answer ~a wrong one#comment on the bad answer}

provide_import()   X-Ref
No description

validate_file(stored_file $file)   X-Ref
Validate the given file.

For more expensive or detailed integrity checks.

param: stored_file $file the file to check
return: string the error message that occurred while validating the given file

readquestion($lines)   X-Ref
No description