Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 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 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

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: 874 lines (36 kb)
Included or required:0 times
Referenced: 0 times
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

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,