Error on Gift Question Import

Error on Gift Question Import

- Evan Donovan の投稿
返信数: 4

I tried importing the attached file of questions into the Lesson module, which should be in the GIFT format (it was automatically generated), and I got the following error:

"Fatal error: Call to undefined method qformat_gift::error() in/document-root/moodle/question/format/gift/format.php on line 228

Should there be an error method defined in the qformat_gift class?

Evan Donovan への返信

Re: Error on Gift Question Import

- Joseph Rézeau の投稿
画像 Core developers 画像 Particularly helpful Moodlers 画像 Plugin developers 画像 Testers 画像 Translators

Evan "(it was automatically generated"

How was this gift file generated? did you export a set of questions previously created in the Moodle question bank? Which type of questions are they?

That gift file cannot be imported into the question bank nor in the Lesson activity.

Joseph

Joseph Rézeau への返信

Re: Error on Gift Question Import

- Jean-Michel Védrine の投稿

Hello Joseph,

You are right, this file can't be imported as it doesn't contains questions in a valid GIFT syntax. There is something wrong in the way it has been generated.

But as the same time as lesson is "stealing" question imports formats from the question component, it should define a proper error method so that errors are correctly reported to users, don't you think so ?

The problem is not in gift format it is in mod/lesson/format.php in the qformat_default  class where something like:

    /**
     * Handle parsing error
     */
    protected function error($message, $text='', $questionname='') {
        $importerrorquestion = get_string('importerrorquestion', 'question');

        echo "<div class=\"importerror\">\n";
        echo "<strong>$importerrorquestion $questionname</strong>";
        if (!empty($text)) {
            $text = s($text);
            echo "<blockquote>$text</blockquote>\n";
        }
        echo "<strong>$message</strong>\n";
        echo "</div>";
    }

should be added.