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 39 and 401]

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