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]

GIFT format question importer/exporter.

Copyright: 2003 Paul Tsuchido Shew
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 886 lines (36 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: qformat_gift  - X-Ref

The GIFT import filter was designed as an easy to use method
for teachers writing questions as a text file. It supports most
question types and the missing word format.

Multiple Choice / Missing Word
Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}
Grant is {~buried =entombed ~living} in Grant's tomb.
True-False:
Grant is buried in Grant's tomb.{FALSE}
Short-Answer.
Who's buried in Grant's tomb?{=no one =nobody}
Numerical
When was Ulysses S. Grant born?{#1822:5}
Matching
Match the following countries with their corresponding
capitals.{=Canada->Ottawa =Italy->Rome =Japan->Tokyo}

Comment lines start with a double backslash (//).
Optional question names are enclosed in double colon(::).
Answer feedback is indicated with hash mark (#).
Percentage answer weights immediately follow the tilde (for
multiple choice) or equal sign (for short answer and numerical),
and are enclosed in percent signs (% %). See docs and examples.txt for more.

This filter was written through the collaboration of numerous
members of the Moodle community. It was originally based on
the missingword format, which included code from Thomas Robb
and others. Paul Tsuchido Shew wrote this filter in December 2003.

provide_import()   X-Ref
No description

provide_export()   X-Ref
No description

export_file_extension()   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

answerweightparser(&$answer)   X-Ref
No description

commentparser($answer, $defaultformat)   X-Ref
No description

split_truefalse_comment($answer, $defaultformat)   X-Ref
No description

escapedchar_pre($string)   X-Ref
No description

escapedchar_post($string)   X-Ref
No description

check_answer_count($min, $answers, $text)   X-Ref
No description

parse_text_with_format($text, $defaultformat = FORMAT_MOODLE)   X-Ref
No description

readquestion($lines)   X-Ref
No description

repchar($text, $notused = 0)   X-Ref
No description

format_const_to_name($format)   X-Ref

param: int $format one of the FORMAT_ constants.
return: string the corresponding name.

format_name_to_const($format)   X-Ref

param: int $format one of the FORMAT_ constants.
return: string the corresponding name.

extract_idnumber_and_tags_from_comment(string $comment)   X-Ref
Extract any tags or idnumber declared in the question comment.

param: string $comment E.g. "// Line 1.\n//Line 2.\n".
return: array with two elements. string $idnumber (or '') and string[] of tags.

write_name($name)   X-Ref
No description

write_questiontext($text, $format, $defaultformat = FORMAT_MOODLE)   X-Ref
No description

write_general_feedback($question, $indent = "\t")   X-Ref
Outputs the general feedback for the question, if any. This needs to be the
last thing before the }.

param: object $question the question data.
param: string $indent to put before the general feedback. Defaults to a tab.

writequestion($question)   X-Ref
No description

write_idnumber_and_tags(stdClass $questiondata)   X-Ref
Prepare any question idnumber or tags for export.

param: stdClass $questiondata the question data we are exporting.
return: string a string that can be written as a line in the GIFT file,