Skip to content

Commit

Permalink
MDL-14431
Browse files Browse the repository at this point in the history
Changing import/export help to be properly pluggable.
  • Loading branch information
thepurpleblob committed Jul 9, 2008
1 parent 08b82a5 commit 79e3dd8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 54 deletions.
51 changes: 3 additions & 48 deletions lang/en_utf8/help/quiz/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,9 @@ <h1>Exporting questions from a Category</h1>
You are advised to check exported data before using
it in a production environment.</p>

<p>The format(s) currently supported are:</p>

<h2>GIFT format</h2>

<p>GIFT is the most comprehensive import/export format available for exporting
Moodle quiz questions to a text file. It was designed to be an easy
method for teachers writing questions as a text file. It supports Multiple-Choice,
True-False, Short Answer, Matching and Numerical questions, as well as insertion
of a _____ for the "missing word" format. Note that Cloze questions are not
currently supported. Various question-types can be
mixed in a single text file, and the format also supports line comments, question names,
feedback and percentage-weight grades. Below are some examples:</p>
<pre>
Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}

Grant is {~buried =entombed ~living} in Grant's tomb.

Grant is buried in Grant's tomb.{FALSE}

Who's buried in Grant's tomb?{=no one =nobody}

When was Ulysses S. Grant born?{#1822}
</pre>

<p class="moreinfo"><a href="help.php?file=formatgift.html&amp;module=quiz">More info about the "GIFT" format</a></p>


<h2>Moodle XML format</h2>

<p>This Moodle specific format exports quiz questions in a simple XML format. They
can then be imported into another quiz category or used in some other process such as
an XSLT transformation. The XML format will export images attached to questions (encoded
base64).</p>


<h2>IMS QTI 2.0</h2>

<p>Exports in the standard IMS QTI (version 2.0) format. Note that this generates a group of files within
a single 'zip' file.</p>
<p class="moreinfo"><a href="http://www.imsglobal.org/question/" target="_qti">More information on the IMS QTI site</a>
(external site in new window)</p>


<h2>XHTML</h2>

<p>Exports the category as a single page of 'strict' XHTML. Each question is clearly placed in its own
&lt;div&gt; tag. If you want to use this page as-is, you will need to at least edit the &lt;form&gt; tag at the
start of the &lt;body&gt; section to provide a suitable action (eg, a 'mailto').</p>
<p>A number of file formats are supported. See in the individual help files
and the <a href="http://docs.moodle.org/en/question/import">Moodle Docs</a>
for details.</p>


<p>Import and Export formats are a pluggable resource. Other optional formats may be available in the
Expand Down
6 changes: 6 additions & 0 deletions lang/en_utf8/help/quiz/formatqti2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>IMS QTI 2.0</h1>

<p>Exports in the standard IMS QTI (version 2.0) format. Note that this generates a group of files within
a single 'zip' file.</p>
<p class="moreinfo"><a href="http://www.imsglobal.org/question/" target="_qti">More information on the IMS QTI site</a>
(external site in new window)</p>
6 changes: 6 additions & 0 deletions lang/en_utf8/help/quiz/formatxhtml.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>XHTML</h1>

<p>Exports the category as a single page of 'strict' XHTML. Each question is clearly placed in its own
&lt;div&gt; tag. If you want to use this page as-is, you will need to at least edit the &lt;form&gt; tag at the
start of the &lt;body&gt; section to provide a suitable action (eg, a 'mailto').</p>

9 changes: 7 additions & 2 deletions question/export_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ function definition() {
$fileformatnames = get_import_export_formats('export');
$radioarray = array();
foreach ($fileformatnames as $id => $fileformatname) {
$radioarray[] = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id);
$radioelement = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id);
$radioelement->setHelpButton(array("format{$id}",$fileformatname,'quiz'));
$radioarray[] = $radioelement;
}
$mform->addGroup($radioarray,'format','',array('<br />'),false);
$mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz'));
$mform->addRule('format',null,'required',null,'client');

//--------------------------------------------------------------------------------
Expand Down Expand Up @@ -46,6 +47,10 @@ function definition() {
$mform->setDefault('exportfilename', $defaultfilename);
$mform->setType('exportfilename', PARAM_CLEANFILE);

// set a template for the format select elements
$renderer =& $mform->defaultRenderer();
$template = "{help} {element}\n";
$renderer->setGroupElementTemplate($template, 'format');

//--------------------------------------------------------------------------------
$this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
Expand Down
13 changes: 9 additions & 4 deletions question/import_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ function definition() {
$fileformatnames = get_import_export_formats('import');
$radioarray = array();
foreach ($fileformatnames as $id => $fileformatname) {
$radioarray[] = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id );
$radioelement = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id );
$radioelement->setHelpButton(array("format{$id}",$fileformatname,'quiz'));
$radioarray[] = $radioelement;
}
$mform->addGroup($radioarray,'format', '', array('<br />'), false);
$mform->addGroup($radioarray,'format', '', array('<br />'), false);
$mform->addRule('format', null, 'required', null, 'client' );
$mform->setHelpButton('format', array('import', get_string('importquestions', 'quiz'), 'quiz'));

//--------------------------------------------------------------------------------
$mform->addElement('header','general', get_string('general', 'form'));

Expand Down Expand Up @@ -68,6 +68,11 @@ function definition() {
//--------------------------------------------------------------------------------
$mform->addElement('static', 'dummy', '');
$mform->closeHeaderBefore('dummy');

// set a template for the format select elements
$renderer =& $mform->defaultRenderer();
$template = "{help} {element}\n";
$renderer->setGroupElementTemplate($template, 'format');
}
function get_importfile_name(){
if ($this->is_submitted() and $this->is_validated()) {
Expand Down

0 comments on commit 79e3dd8

Please sign in to comment.