Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48342

In question format default formatnotimplemented is broken

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.3, 2.8.1
    • Fix Version/s: 2.7.4, 2.8.2
    • Component/s: Lesson, Questions
    • Labels:
    • Testing Instructions:
      Hide

      First step

      Install the attached plugin qformat_silly plugin.

      Testing import in the question bank

      Go to the question bank and try to import a file (any .txt file will do in fact its content will not be imported as qformat_silly is missing the code to do that ) selection the "Silly format" file format.
      Verify that you get something like:
      Coding error detected, it must be fixed by a programmer: Question format plugin is missing important code: readquestion.
      More information about this error
      Debug info:
      Error code: codingerror
      Stack trace:

      line 700 of \question\format.php: coding_exception thrown
      line 582 of \question\format.php: call to qformat_default->readquestion()
      line 303 of \question\format.php: call to qformat_default->readquestions()
      line 119 of \question\import.php: call to qformat_default->importprocess()

      testing export in the question bank

      Create some questions
      Try to export these questions using "Silly format" and verify that you get something like:
      Coding error detected, it must be fixed by a programmer: Question format plugin is missing important code: writequestion.
      Debug info:
      Error code: codingerror
      Stack trace:

      line 932 of \question\format.php: coding_exception thrown
      line 814 of \question\format.php: call to qformat_default->writequestion()
      line 1926 of \lib\questionlib.php: call to qformat_default->exportprocess()
      line 4535 of \lib\filelib.php: call to question_pluginfile()
      line 37 of \pluginfile.php: call to file_pluginfile()

      Testing import in lesson

      In a course create a lesson, then choose "Import questions" and choose the "Silly format" file format and try to import any .txt file
      Verify that you get something like:
      Coding error detected, it must be fixed by a programmer: Question format plugin is missing important code: readquestion.

      More information about this error
      Debug info:
      Error code: codingerror
      Stack trace:

      line 591 of \mod\lesson\format.php: coding_exception thrown
      line 565 of \mod\lesson\format.php: call to qformat_default->readquestion()
      line 372 of \mod\lesson\format.php: call to qformat_default->readquestions()
      line 92 of \mod\lesson\import.php: call to qformat_default->importprocess()

      Show
      First step Install the attached plugin qformat_silly plugin. Testing import in the question bank Go to the question bank and try to import a file (any .txt file will do in fact its content will not be imported as qformat_silly is missing the code to do that ) selection the "Silly format" file format. Verify that you get something like: Coding error detected, it must be fixed by a programmer: Question format plugin is missing important code: readquestion. More information about this error Debug info: Error code: codingerror Stack trace: line 700 of \question\format.php: coding_exception thrown line 582 of \question\format.php: call to qformat_default->readquestion() line 303 of \question\format.php: call to qformat_default->readquestions() line 119 of \question\import.php: call to qformat_default->importprocess() testing export in the question bank Create some questions Try to export these questions using "Silly format" and verify that you get something like: Coding error detected, it must be fixed by a programmer: Question format plugin is missing important code: writequestion. Debug info: Error code: codingerror Stack trace: line 932 of \question\format.php: coding_exception thrown line 814 of \question\format.php: call to qformat_default->writequestion() line 1926 of \lib\questionlib.php: call to qformat_default->exportprocess() line 4535 of \lib\filelib.php: call to question_pluginfile() line 37 of \pluginfile.php: call to file_pluginfile() Testing import in lesson In a course create a lesson, then choose "Import questions" and choose the "Silly format" file format and try to import any .txt file Verify that you get something like: Coding error detected, it must be fixed by a programmer: Question format plugin is missing important code: readquestion. More information about this error Debug info: Error code: codingerror Stack trace: line 591 of \mod\lesson\format.php: coding_exception thrown line 565 of \mod\lesson\format.php: call to qformat_default->readquestion() line 372 of \mod\lesson\format.php: call to qformat_default->readquestions() line 92 of \mod\lesson\import.php: call to qformat_default->importprocess()
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      If a question import format don't overwrite the default readquestions function, it must absolutely overwrite the readquestion function.
      Currently the default readquestion function is

       protected function readquestion($lines) {
       
              $formatnotimplemented = get_string('formatnotimplemented', 'question');
              echo "<p>{$formatnotimplemented}</p>";
       
              return null;
          }
      

      There are several problems here:

      • I think this is wrong, the format is broken and we should throw a coding exception
      • but additionally the 'formatnotimplemented' string is defined in the quiz component, not in the question component !

      So if the qformat plugin is broken the user will in fact see

      Invalid get_string() identifier: 'formatnotimplemented' or component 'question'. Perhaps you are missing $string['formatnotimplemented'] = ''; in lang/en/question.php?
      

      I discovered this mess when working in the lesson module that of course "borrows" the qformats plugins but implement it's own default class and believe it or not the default readquestion function in lesson is even more weird than the quiz one ! See:

      protected function readquestion($lines) {
          /// Given an array of lines known to define a question in
          /// this format, this function converts it into a question
          /// object suitable for processing and insertion into Moodle.
       
              echo "<p>This flash question format has not yet been completed!</p>";
       
              return null;
          }
      

      You see: why is there a mention of flash here ?? Is this sentence understandable by any Moodle user ? No !
      This is of course a very minor problem, but I don't like to see things like this in Moodle, so my proposal is I assign this issue to myself

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Jan/15