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

qtype base class export_to_xml method leaves out feedback & answer formats

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1.2, 2.2
    • Fix Version/s: 2.0.6, 2.1.3
    • Component/s: Questions
    • Labels:
    • Database:
      Any
    • Testing Instructions:
      Hide

      Export a question to XML format using a type which does not override the base export_to_xml method, ensuring that the feedback blocks are in HTML format. Import the question from the XML file and then edit it. The feedback edit areas will now be standard text fields and not HTML editors.

      If that is not possible, just make sure that exporting to Moodle XML does not have any obvious regressions.

      Show
      Export a question to XML format using a type which does not override the base export_to_xml method, ensuring that the feedback blocks are in HTML format. Import the question from the XML file and then edit it. The feedback edit areas will now be standard text fields and not HTML editors. If that is not possible, just make sure that exporting to Moodle XML does not have any obvious regressions.
    • Workaround:
      Hide

      Patch for problem (relative to 2.0.3+) included in description. The only workaround without a patch would be to hand-edit the XML to add the attributes to the correct tags or to always correct the formats after the question is imported.

      Show
      Patch for problem (relative to 2.0.3+) included in description. The only workaround without a patch would be to hand-edit the XML to add the attributes to the correct tags or to always correct the formats after the question is imported.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      The base export_to_xml function in question/type/questiontype.php does not set the feedback (or answer) format values in the exported XML. When these questions are re-read the feedback blocks are converted to 'moodle-auto-format' from whatever they currently are (usually the default HTML). The standard XML import function already supports reading the format value from the attribute of the answer 'text' element and the feedback element. The patch below, when applied to 2.0.3+ should fix the issue.

      — questiontype.php 9 Mar 2011 08:20:51 -0000 1.173
      +++ questiontype.php 21 Jul 2011 18:29:19 -0000
      @@ -1608,10 +1608,12 @@
      //TODO export answers with any extra data
      } else {
      foreach ($question->options->answers as $answer) {
      + $ansformat=$format->get_format($answer->answerformat);
      + $fbformat=$format->get_format($answer->feedbackformat);
      $percent = 100 * $answer->fraction;

      • $expout .= " <answer fraction=\"$percent\">\n";
        + $expout .= " <answer fraction=\"$percent\" format=\"{$ansformat}\">\n";
        $expout .= $format->writetext($answer->answer, 3, false);
      • $expout .= " <feedback>\n";
        + $expout .= " <feedback format=\"{$fbformat}\">\n";
        $expout .= $format->writetext($answer->feedback, 4, false);
        $expout .= " </feedback>\n";
        $expout .= " </answer>\n";

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    28/Nov/11