MDL-20601 fixed fatal SQL upgrade error, missing {} around table names
[moodle.git] / question / format / gift / format.php
CommitLineData
84769fd8 1<?php // $Id$
f1abd39f 2//
84769fd8 3///////////////////////////////////////////////////////////////
4// The GIFT import filter was designed as an easy to use method
5// for teachers writing questions as a text file. It supports most
6// question types and the missing word format.
7//
8// Multiple Choice / Missing Word
9// Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}
10// Grant is {~buried =entombed ~living} in Grant's tomb.
11// True-False:
12// Grant is buried in Grant's tomb.{FALSE}
13// Short-Answer.
14// Who's buried in Grant's tomb?{=no one =nobody}
15// Numerical
16// When was Ulysses S. Grant born?{#1822:5}
17// Matching
18// Match the following countries with their corresponding
19// capitals.{=Canada->Ottawa =Italy->Rome =Japan->Tokyo}
20//
21// Comment lines start with a double backslash (//).
22// Optional question names are enclosed in double colon(::).
23// Answer feedback is indicated with hash mark (#).
24// Percentage answer weights immediately follow the tilde (for
25// multiple choice) or equal sign (for short answer and numerical),
26// and are enclosed in percent signs (% %). See docs and examples.txt for more.
27//
28// This filter was written through the collaboration of numerous
29// members of the Moodle community. It was originally based on
30// the missingword format, which included code from Thomas Robb
31// and others. Paul Tsuchido Shew wrote this filter in December 2003.
32//////////////////////////////////////////////////////////////////////////
33// Based on default.php, included by ../import.php
41a89a07 34/**
35 * @package questionbank
36 * @subpackage importexport
37 */
f5565b69 38class qformat_gift extends qformat_default {
84769fd8 39
40 function provide_import() {
09db6da2 41 return true;
84769fd8 42 }
43
44 function provide_export() {
09db6da2 45 return true;
84769fd8 46 }
47
48 function answerweightparser(&$answer) {
49 $answer = substr($answer, 1); // removes initial %
50 $end_position = strpos($answer, "%");
51 $answer_weight = substr($answer, 0, $end_position); // gets weight as integer
52 $answer_weight = $answer_weight/100; // converts to percent
53 $answer = substr($answer, $end_position+1); // removes comment from answer
54 return $answer_weight;
55 }
56
57
58 function commentparser(&$answer) {
59 if (strpos($answer,"#") > 0){
60 $hashpos = strpos($answer,"#");
61 $comment = substr($answer, $hashpos+1);
294ce987 62 $comment = trim($this->escapedchar_post($comment));
84769fd8 63 $answer = substr($answer, 0, $hashpos);
64 } else {
65 $comment = " ";
66 }
67 return $comment;
68 }
69
70 function split_truefalse_comment($comment){
09db6da2 71 // splits up comment around # marks
72 // returns an array of true/false feedback
73 $bits = explode('#',$comment);
74 $feedback = array('wrong' => $bits[0]);
75 if (count($bits) >= 2) {
76 $feedback['right'] = $bits[1];
77 } else {
78 $feedback['right'] = '';
79 }
80 return $feedback;
84769fd8 81 }
82
83 function escapedchar_pre($string) {
84 //Replaces escaped control characters with a placeholder BEFORE processing
85
dfdce7fb 86 $escapedcharacters = array("\\:", "\\#", "\\=", "\\{", "\\}", "\\~", "\\n" ); //dlnsk
87 $placeholders = array("&&058;", "&&035;", "&&061;", "&&123;", "&&125;", "&&126;", "&&010" ); //dlnsk
84769fd8 88
89 $string = str_replace("\\\\", "&&092;", $string);
90 $string = str_replace($escapedcharacters, $placeholders, $string);
91 $string = str_replace("&&092;", "\\", $string);
92 return $string;
93 }
94
95 function escapedchar_post($string) {
96 //Replaces placeholders with corresponding character AFTER processing is done
dfdce7fb 97 $placeholders = array("&&058;", "&&035;", "&&061;", "&&123;", "&&125;", "&&126;", "&&010"); //dlnsk
98 $characters = array(":", "#", "=", "{", "}", "~", "\n" ); //dlnsk
84769fd8 99 $string = str_replace($placeholders, $characters, $string);
100 return $string;
101 }
102
103 function check_answer_count( $min, $answers, $text ) {
09db6da2 104 $countanswers = count($answers);
105 if ($countanswers < $min) {
f3701561 106 $importminerror = get_string( 'importminerror', 'quiz' );
107 $this->error( $importminerror, $text );
09db6da2 108 return false;
109 }
110
111 return true;
84769fd8 112 }
113
114
115 function readquestion($lines) {
116 // Given an array of lines known to define a question in this format, this function
117 // converts it into a question object suitable for processing and insertion into Moodle.
118
119 $question = $this->defaultquestion();
120 $comment = NULL;
121 // define replaced by simple assignment, stop redefine notices
6dbcacee 122 $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/";
84769fd8 123
124 // REMOVED COMMENTED LINES and IMPLODE
125 foreach ($lines as $key => $line) {
09db6da2 126 $line = trim($line);
127 if (substr($line, 0, 2) == "//") {
84769fd8 128 $lines[$key] = " ";
09db6da2 129 }
84769fd8 130 }
131
132 $text = trim(implode(" ", $lines));
133
134 if ($text == "") {
84769fd8 135 return false;
136 }
137
138 // Substitute escaped control characters with placeholders
139 $text = $this->escapedchar_pre($text);
140
b39c7aad 141 // Look for category modifier
6dbcacee 142 if (preg_match( '~^\$CATEGORY:~', $text)) {
5363b555 143 // $newcategory = $matches[1];
144 $newcategory = trim(substr( $text, 10 ));
b39c7aad 145
146 // build fake question to contain category
147 $question->qtype = 'category';
148 $question->category = $newcategory;
149 return $question;
150 }
5363b555 151
84769fd8 152 // QUESTION NAME parser
153 if (substr($text, 0, 2) == "::") {
154 $text = substr($text, 2);
155
156 $namefinish = strpos($text, "::");
157 if ($namefinish === false) {
158 $question->name = false;
159 // name will be assigned after processing question text below
09db6da2 160 } else {
84769fd8 161 $questionname = substr($text, 0, $namefinish);
294ce987 162 $question->name = trim($this->escapedchar_post($questionname));
84769fd8 163 $text = trim(substr($text, $namefinish+2)); // Remove name from text
164 }
165 } else {
166 $question->name = false;
167 }
168
169
170 // FIND ANSWER section
e8825e72 171 // no answer means its a description
84769fd8 172 $answerstart = strpos($text, "{");
84769fd8 173 $answerfinish = strpos($text, "}");
e8825e72 174
175 $description = false;
176 if (($answerstart === false) and ($answerfinish === false)) {
177 $description = true;
178 $answertext = '';
179 $answerlength = 0;
180 }
181 elseif (!(($answerstart !== false) and ($answerfinish !== false))) {
182 $this->error( get_string( 'braceerror', 'quiz' ), $text );
84769fd8 183 return false;
184 }
e8825e72 185 else {
186 $answerlength = $answerfinish - $answerstart;
187 $answertext = trim(substr($text, $answerstart + 1, $answerlength - 1));
188 }
84769fd8 189
190 // Format QUESTION TEXT without answer, inserting "_____" as necessary
e8825e72 191 if ($description) {
192 $questiontext = $text;
193 }
194 elseif (substr($text, -1) == "}") {
84769fd8 195 // no blank line if answers follow question, outside of closing punctuation
196 $questiontext = substr_replace($text, "", $answerstart, $answerlength+1);
197 } else {
198 // inserts blank line for missing word format
199 $questiontext = substr_replace($text, "_____", $answerstart, $answerlength+1);
200 }
201
202 // get questiontext format from questiontext
203 $oldquestiontext = $questiontext;
204 $questiontextformat = 0;
205 if (substr($questiontext,0,1)=='[') {
09db6da2 206 $questiontext = substr( $questiontext,1 );
207 $rh_brace = strpos( $questiontext, ']' );
208 $qtformat= substr( $questiontext, 0, $rh_brace );
209 $questiontext = substr( $questiontext, $rh_brace+1 );
210 if (!$questiontextformat = text_format_name( $qtformat )) {
211 $questiontext = $oldquestiontext;
212 }
84769fd8 213 }
214 $question->questiontextformat = $questiontextformat;
294ce987 215 $question->questiontext = trim($this->escapedchar_post($questiontext));
84769fd8 216
217 // set question name if not already set
218 if ($question->name === false) {
219 $question->name = $question->questiontext;
220 }
221
8daaaafc 222 // ensure name is not longer than 250 characters
0db7823c 223 $question->name = shorten_text( $question->name, 200 );
224 $question->name = strip_tags(substr( $question->name, 0, 250 ));
84769fd8 225
09db6da2 226 // determine QUESTION TYPE
84769fd8 227 $question->qtype = NULL;
228
4433fff5 229 // give plugins first try
230 // plugins must promise not to intercept standard qtypes
3ea69b8d 231 // MDL-12346, this could be called from lesson mod which has its own base class =(
232 if (method_exists($this, 'try_importing_using_qtypes') && ($try_question = $this->try_importing_using_qtypes( $lines, $question, $answertext ))) {
d510ec64 233 return $try_question;
4433fff5 234 }
235
e8825e72 236 if ($description) {
237 $question->qtype = DESCRIPTION;
238 }
239 elseif ($answertext == '') {
240 $question->qtype = ESSAY;
241 }
242 elseif ($answertext{0} == "#"){
84769fd8 243 $question->qtype = NUMERICAL;
244
245 } elseif (strpos($answertext, "~") !== false) {
246 // only Multiplechoice questions contain tilde ~
247 $question->qtype = MULTICHOICE;
248
249 } elseif (strpos($answertext, "=") !== false
09db6da2 250 && strpos($answertext, "->") !== false) {
251 // only Matching contains both = and ->
84769fd8 252 $question->qtype = MATCH;
253
254 } else { // either TRUEFALSE or SHORTANSWER
255
256 // TRUEFALSE question check
257 $truefalse_check = $answertext;
258 if (strpos($answertext,"#") > 0){
259 // strip comments to check for TrueFalse question
260 $truefalse_check = trim(substr($answertext, 0, strpos($answertext,"#")));
261 }
262
263 $valid_tf_answers = array("T", "TRUE", "F", "FALSE");
264 if (in_array($truefalse_check, $valid_tf_answers)) {
265 $question->qtype = TRUEFALSE;
266
267 } else { // Must be SHORTANSWER
268 $question->qtype = SHORTANSWER;
269 }
270 }
271
272 if (!isset($question->qtype)) {
532344b2 273 $giftqtypenotset = get_string('giftqtypenotset','quiz');
274 $this->error( $giftqtypenotset, $text );
84769fd8 275 return false;
276 }
277
278 switch ($question->qtype) {
e8825e72 279 case DESCRIPTION:
3f5633df 280 $question->defaultgrade = 0;
281 $question->length = 0;
e8825e72 282 return $question;
283 break;
284 case ESSAY:
285 $question->feedback = '';
286 $question->fraction = 0;
287 return $question;
288 break;
84769fd8 289 case MULTICHOICE:
290 if (strpos($answertext,"=") === false) {
291 $question->single = 0; // multiple answers are enabled if no single answer is 100% correct
292 } else {
293 $question->single = 1; // only one answer allowed (the default)
294 }
295
296 $answertext = str_replace("=", "~=", $answertext);
297 $answers = explode("~", $answertext);
298 if (isset($answers[0])) {
299 $answers[0] = trim($answers[0]);
300 }
301 if (empty($answers[0])) {
302 array_shift($answers);
303 }
304
305 $countanswers = count($answers);
306
2befe778 307 if (!$this->check_answer_count( 2,$answers,$text )) {
308 return false;
309 break;
84769fd8 310 }
311
312 foreach ($answers as $key => $answer) {
313 $answer = trim($answer);
314
315 // determine answer weight
316 if ($answer[0] == "=") {
317 $answer_weight = 1;
318 $answer = substr($answer, 1);
319
6dbcacee 320 } elseif (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
84769fd8 321 $answer_weight = $this->answerweightparser($answer);
322
323 } else { //default, i.e., wrong anwer
324 $answer_weight = 0;
325 }
326 $question->fraction[$key] = $answer_weight;
327 $question->feedback[$key] = $this->commentparser($answer); // commentparser also removes comment from $answer
294ce987 328 $question->answer[$key] = $this->escapedchar_post($answer);
172f6d95 329 $question->correctfeedback = '';
330 $question->partiallycorrectfeedback = '';
331 $question->incorrectfeedback = '';
84769fd8 332 } // end foreach answer
333
334 //$question->defaultgrade = 1;
335 //$question->image = ""; // No images with this format
336 return $question;
337 break;
338
339 case MATCH:
340 $answers = explode("=", $answertext);
341 if (isset($answers[0])) {
342 $answers[0] = trim($answers[0]);
343 }
344 if (empty($answers[0])) {
345 array_shift($answers);
346 }
347
2befe778 348 if (!$this->check_answer_count( 2,$answers,$text )) {
349 return false;
350 break;
84769fd8 351 }
352
353 foreach ($answers as $key => $answer) {
354 $answer = trim($answer);
87ee4968 355 if (strpos($answer, "->") === false) {
532344b2 356 $giftmatchingformat = get_string('giftmatchingformat','quiz');
357 $this->error($giftmatchingformat, $answer );
84769fd8 358 return false;
359 break 2;
360 }
361
362 $marker = strpos($answer,"->");
294ce987 363 $question->subquestions[$key] = trim($this->escapedchar_post(substr($answer, 0, $marker)));
364 $question->subanswers[$key] = trim($this->escapedchar_post(substr($answer, $marker+2)));
84769fd8 365
366 } // end foreach answer
367
84769fd8 368 return $question;
369 break;
370
371 case TRUEFALSE:
372 $answer = $answertext;
373 $comment = $this->commentparser($answer); // commentparser also removes comment from $answer
09db6da2 374 $feedback = $this->split_truefalse_comment($comment);
84769fd8 375
376 if ($answer == "T" OR $answer == "TRUE") {
377 $question->answer = 1;
09db6da2 378 $question->feedbacktrue = $feedback['right'];
379 $question->feedbackfalse = $feedback['wrong'];
84769fd8 380 } else {
381 $question->answer = 0;
09db6da2 382 $question->feedbackfalse = $feedback['right'];
383 $question->feedbacktrue = $feedback['wrong'];
84769fd8 384 }
385
0d4c63d7 386 $question->penalty = 1;
7939a4a0 387 $question->correctanswer = $question->answer;
388
84769fd8 389 return $question;
390 break;
391
392 case SHORTANSWER:
393 // SHORTANSWER Question
394 $answers = explode("=", $answertext);
395 if (isset($answers[0])) {
396 $answers[0] = trim($answers[0]);
397 }
398 if (empty($answers[0])) {
399 array_shift($answers);
400 }
401
2befe778 402 if (!$this->check_answer_count( 1,$answers,$text )) {
403 return false;
404 break;
84769fd8 405 }
406
407 foreach ($answers as $key => $answer) {
408 $answer = trim($answer);
409
410 // Answer Weight
6dbcacee 411 if (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
84769fd8 412 $answer_weight = $this->answerweightparser($answer);
413 } else { //default, i.e., full-credit anwer
414 $answer_weight = 1;
415 }
416 $question->fraction[$key] = $answer_weight;
417 $question->feedback[$key] = $this->commentparser($answer); //commentparser also removes comment from $answer
294ce987 418 $question->answer[$key] = $this->escapedchar_post($answer);
84769fd8 419 } // end foreach
420
421 //$question->usecase = 0; // Ignore case
422 //$question->defaultgrade = 1;
423 //$question->image = ""; // No images with this format
424 return $question;
425 break;
426
427 case NUMERICAL:
428 // Note similarities to ShortAnswer
429 $answertext = substr($answertext, 1); // remove leading "#"
430
1fe641f7 431 // If there is feedback for a wrong answer, store it for now.
432 if (($pos = strpos($answertext, '~')) !== false) {
433 $wrongfeedback = substr($answertext, $pos);
434 $answertext = substr($answertext, 0, $pos);
435 } else {
436 $wrongfeedback = '';
437 }
438
84769fd8 439 $answers = explode("=", $answertext);
440 if (isset($answers[0])) {
441 $answers[0] = trim($answers[0]);
442 }
443 if (empty($answers[0])) {
444 array_shift($answers);
445 }
446
447 if (count($answers) == 0) {
448 // invalid question
532344b2 449 $giftnonumericalanswers = get_string('giftnonumericalanswers','quiz');
450 $this->error( $giftnonumericalanswers, $text );
84769fd8 451 return false;
452 break;
453 }
454
455 foreach ($answers as $key => $answer) {
456 $answer = trim($answer);
457
458 // Answer weight
6dbcacee 459 if (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
84769fd8 460 $answer_weight = $this->answerweightparser($answer);
461 } else { //default, i.e., full-credit anwer
462 $answer_weight = 1;
463 }
464 $question->fraction[$key] = $answer_weight;
465 $question->feedback[$key] = $this->commentparser($answer); //commentparser also removes comment from $answer
466
467 //Calculate Answer and Min/Max values
468 if (strpos($answer,"..") > 0) { // optional [min]..[max] format
469 $marker = strpos($answer,"..");
470 $max = trim(substr($answer, $marker+2));
471 $min = trim(substr($answer, 0, $marker));
472 $ans = ($max + $min)/2;
473 $tol = $max - $ans;
474 } elseif (strpos($answer,":") > 0){ // standard [answer]:[errormargin] format
475 $marker = strpos($answer,":");
476 $tol = trim(substr($answer, $marker+1));
477 $ans = trim(substr($answer, 0, $marker));
478 } else { // only one valid answer (zero errormargin)
479 $tol = 0;
480 $ans = trim($answer);
481 }
482
09db6da2 483 if (!(is_numeric($ans) || $ans = '*') || !is_numeric($tol)) {
f3701561 484 $errornotnumbers = get_string( 'errornotnumbers' );
485 $this->error( $errornotnumbers, $text );
84769fd8 486 return false;
487 break;
488 }
489
490 // store results
491 $question->answer[$key] = $ans;
492 $question->tolerance[$key] = $tol;
493 } // end foreach
494
1fe641f7 495 if ($wrongfeedback) {
496 $key += 1;
497 $question->fraction[$key] = 0;
498 $question->feedback[$key] = $this->commentparser($wrongfeedback);
499 $question->answer[$key] = '';
500 $question->tolerance[$key] = '';
501 }
502
84769fd8 503 return $question;
504 break;
505
506 default:
532344b2 507 $giftnovalidquestion = get_string('giftnovalidquestion','quiz');
508 $this->error( $giftnovalidquestion, $text );
84769fd8 509 return false;
510 break;
511
512 } // end switch ($question->qtype)
513
514 } // end function readquestion($lines)
515
516function repchar( $text, $format=0 ) {
dfdce7fb 517 // escapes 'reserved' characters # = ~ { ) : and removes new lines
84769fd8 518 // also pushes text through format routine
dfdce7fb 519 $reserved = array( '#', '=', '~', '{', '}', ':', "\n","\r");
520 $escaped = array( '\#','\=','\~','\{','\}','\:','\n','' ); //dlnsk
84769fd8 521
522 $newtext = str_replace( $reserved, $escaped, $text );
523 $format = 0; // turn this off for now
524 if ($format) {
09db6da2 525 $newtext = format_text( $format );
84769fd8 526 }
527 return $newtext;
528 }
529
530function writequestion( $question ) {
fef8f84e 531 global $QTYPES, $OUTPUT;
84769fd8 532 // turns question into string
533 // question reflects database fields for general question and specific to type
534
535 // initial string;
536 $expout = "";
537
538 // add comment
539 $expout .= "// question: $question->id name: $question->name \n";
540
541 // get question text format
542 $textformat = $question->questiontextformat;
543 $tfname = "";
544 if ($textformat!=FORMAT_MOODLE) {
09db6da2 545 $tfname = text_format_name( (int)$textformat );
546 $tfname = "[$tfname]";
84769fd8 547 }
548
549 // output depends on question type
550 switch($question->qtype) {
f1abd39f 551 case 'category':
552 // not a real question, used to insert category switch
553 $expout .= "\$CATEGORY: $question->category\n";
554 break;
e8825e72 555 case DESCRIPTION:
556 $expout .= '::'.$this->repchar($question->name).'::';
557 $expout .= $tfname;
558 $expout .= $this->repchar( $question->questiontext, $textformat);
559 break;
560 case ESSAY:
561 $expout .= '::'.$this->repchar($question->name).'::';
562 $expout .= $tfname;
563 $expout .= $this->repchar( $question->questiontext, $textformat);
564 $expout .= "{}\n";
565 break;
84769fd8 566 case TRUEFALSE:
09db6da2 567 $trueanswer = $question->options->answers[$question->options->trueanswer];
568 $falseanswer = $question->options->answers[$question->options->falseanswer];
569 if ($trueanswer->fraction == 1) {
570 $answertext = 'TRUE';
571 $right_feedback = $trueanswer->feedback;
572 $wrong_feedback = $falseanswer->feedback;
573 } else {
574 $answertext = 'FALSE';
575 $right_feedback = $falseanswer->feedback;
576 $wrong_feedback = $trueanswer->feedback;
84769fd8 577 }
36e2232e 578
09db6da2 579 $wrong_feedback = $this->repchar($wrong_feedback);
580 $right_feedback = $this->repchar($right_feedback);
581 $expout .= "::".$this->repchar($question->name)."::".$tfname.$this->repchar( $question->questiontext,$textformat )."{".$this->repchar( $answertext );
582 if ($wrong_feedback) {
583 $expout .= "#" . $wrong_feedback;
584 } else if ($right_feedback) {
585 $expout .= "#";
84769fd8 586 }
09db6da2 587 if ($right_feedback) {
588 $expout .= "#" . $right_feedback;
84769fd8 589 }
590 $expout .= "}\n";
591 break;
592 case MULTICHOICE:
dfdce7fb 593 $expout .= "::".$this->repchar($question->name)."::".$tfname.$this->repchar( $question->questiontext, $textformat )."{\n";
84769fd8 594 foreach($question->options->answers as $answer) {
595 if ($answer->fraction==1) {
596 $answertext = '=';
597 }
598 elseif ($answer->fraction==0) {
599 $answertext = '~';
600 }
601 else {
09db6da2 602 $export_weight = $answer->fraction*100;
603 $answertext = "~%$export_weight%";
84769fd8 604 }
605 $expout .= "\t".$answertext.$this->repchar( $answer->answer );
606 if ($answer->feedback!="") {
607 $expout .= "#".$this->repchar( $answer->feedback );
608 }
609 $expout .= "\n";
610 }
611 $expout .= "}\n";
612 break;
613 case SHORTANSWER:
dfdce7fb 614 $expout .= "::".$this->repchar($question->name)."::".$tfname.$this->repchar( $question->questiontext, $textformat )."{\n";
84769fd8 615 foreach($question->options->answers as $answer) {
616 $weight = 100 * $answer->fraction;
617 $expout .= "\t=%".$weight."%".$this->repchar( $answer->answer )."#".$this->repchar( $answer->feedback )."\n";
618 }
619 $expout .= "}\n";
620 break;
621 case NUMERICAL:
dfdce7fb 622 $expout .= "::".$this->repchar($question->name)."::".$tfname.$this->repchar( $question->questiontext, $textformat )."{#\n";
1fe641f7 623 foreach ($question->options->answers as $answer) {
1fe641f7 624 if ($answer->answer != '') {
13e88db4 625 $percentage = '';
626 if ($answer->fraction < 1) {
627 $pval = $answer->fraction * 100;
628 $percentage = "%$pval%";
629 }
630 $expout .= "\t=$percentage".$answer->answer.":".(float)$answer->tolerance."#".$this->repchar( $answer->feedback )."\n";
1fe641f7 631 } else {
632 $expout .= "\t~#".$this->repchar( $answer->feedback )."\n";
633 }
634 }
84769fd8 635 $expout .= "}\n";
636 break;
637 case MATCH:
dfdce7fb 638 $expout .= "::".$this->repchar($question->name)."::".$tfname.$this->repchar( $question->questiontext, $textformat )."{\n";
84769fd8 639 foreach($question->options->subquestions as $subquestion) {
640 $expout .= "\t=".$this->repchar( $subquestion->questiontext )." -> ".$this->repchar( $subquestion->answertext )."\n";
641 }
642 $expout .= "}\n";
643 break;
84769fd8 644 default:
64de04fb 645 // check for plugins
646 if ($out = $this->try_exporting_using_qtypes( $question->qtype, $question )) {
647 $expout .= $out;
648 }
649 else {
c0587850 650 $expout .= "Question type $question->qtype is not supported\n";
fef8f84e 651 echo $OUTPUT->notification( get_string('nohandler', 'qformat_gift', $QTYPES[$question->qtype]->local_name()) );
64de04fb 652 }
84769fd8 653 }
654 // add empty line to delimit questions
655 $expout .= "\n";
656 return $expout;
657}
658}
659?>