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

Aiken format not generating the question name properly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.0.5, 2.1.2, 2.2
    • Component/s: Questions
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. Save the following in an text file:

      This question triggers a tricky bug by having an ' as the 50th character of its question text.
      A. Answer 1
      B. Answer 2
      ANSWER: A

      2. Import into the question bank as Aiken format, and verify it works.

      Show
      1. Save the following in an text file: This question triggers a tricky bug by having an ' as the 50th character of its question text. A. Answer 1 B. Answer 2 ANSWER: A 2. Import into the question bank as Aiken format, and verify it works.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Very nice bit of diagnosis of a tricky bug: http://moodle.org/mod/forum/discuss.php?d=182064

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks Tim this has been integrated now.

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks Tim this has been integrated now.
            Hide
            rajeshtaneja Rajesh Taneja added a comment - - edited

            Works well for 19, but in 2.x Aiken format is not importable. Throws following error on 2.x, hence can't be tested on 2.x.

            Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.1962 81157040 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:86 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 87 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.2801 81159032 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:86 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 87 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.3638 81211256 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:125 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 126 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.3641 81211552 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:128 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 129 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.3645 81211832 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:131 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 132 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 

            I am passing this as it do solve the purpose. Thanks for providing the fix Tim

            Show
            rajeshtaneja Rajesh Taneja added a comment - - edited Works well for 19, but in 2.x Aiken format is not importable. Throws following error on 2.x, hence can't be tested on 2.x. Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.1962 81157040 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:86 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 87 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.2801 81159032 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:86 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 87 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.3638 81211256 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:125 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 126 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.3641 81211552 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:128 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 129 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/questiontype.php on line 1685 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 1.3645 81211832 4. default_questiontype->import_or_save_files() /usr/local/www/moodle20/question/type/multichoice/questiontype.php:131 Notice: Uninitialized string offset: 0 in /usr/local/www/moodle20/question/type/multichoice/questiontype.php on line 132 Call Stack: 0.0007 724944 1. {main}() /usr/local/www/moodle20/question/import.php:0 1.0259 72701288 2. qformat_default->importprocess() /usr/local/www/moodle20/question/import.php:109 1.1626 81127560 3. question_multichoice_qtype->save_question_options() /usr/local/www/moodle20/question/format.php:368 I am passing this as it do solve the purpose. Thanks for providing the fix Tim
            Hide
            timhunt Tim Hunt added a comment -

            Ah, there is already another bug report about the problems with importing multiple choice questions. I must find time to fix that.

            Show
            timhunt Tim Hunt added a comment - Ah, there is already another bug report about the problems with importing multiple choice questions. I must find time to fix that.
            Hide
            ppichet Pierre Pichet added a comment -

            The Aiken format has not been modified to handle images in multiple choice.

                            if (preg_match('/^[A-Z][).][ \t]/', $nowline)) {
                                // A choice. Trim off the label and space, then save
                                $question->answer[] = htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES);
                                $question->fraction[] = 0;
                                $question->feedback[] = '';
                                continue;
                            }
                            if (preg_match('/^ANSWER:/', $nowline)) {
                                // The line that indicates the correct answer. This question is finised.
                                $ans = trim(substr($nowline, strpos($nowline, ':') + 1));
                                $ans = substr($ans, 0, 1);
                                // We want to map A to 0, B to 1, etc.
                                $rightans = ord($ans) - ord('A');
                                $question->fraction[$rightans] = 1;
                                $questions[] = $question;
             
                                // Clear array for next question set
                                $question = $this->defaultquestion();
                                continue;
                            } else {
                                // Must be the first line of a new question, since no recognised prefix.

            Show
            ppichet Pierre Pichet added a comment - The Aiken format has not been modified to handle images in multiple choice. if (preg_match('/^[A-Z][).][ \t]/', $nowline)) { // A choice. Trim off the label and space, then save $question->answer[] = htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES); $question->fraction[] = 0; $question->feedback[] = ''; continue; } if (preg_match('/^ANSWER:/', $nowline)) { // The line that indicates the correct answer. This question is finised. $ans = trim(substr($nowline, strpos($nowline, ':') + 1)); $ans = substr($ans, 0, 1); // We want to map A to 0, B to 1, etc. $rightans = ord($ans) - ord('A'); $question->fraction[$rightans] = 1; $questions[] = $question;   // Clear array for next question set $question = $this->defaultquestion(); continue; } else { // Must be the first line of a new question, since no recognised prefix.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Oct/11