Moodle
  1. Moodle
  2. MDL-30922

Stop question editor from automatically adding new answer fields upon re-editing question

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      Create a SHORTANSWER question.
      Check that the editing interface displays the default number (3) of Answer fields.
      Enter data for 2 Answer only.
      Save.
      Edit that question.
      Check that only the 2 Answer fields you entered previously are displayed, with no extra Answer field.
      Click the "Blanks for 3 more choices" button
      Enter data for Answer 3 only
      Save
      Edit question again
      Check that only the 3 Answer fields you entered previously are displayed, with no extra Answer field.

      Repeat test with MATCH and MULTICHOICE questions

      Show
      Create a SHORTANSWER question. Check that the editing interface displays the default number (3) of Answer fields. Enter data for 2 Answer only. Save. Edit that question. Check that only the 2 Answer fields you entered previously are displayed, with no extra Answer field. Click the "Blanks for 3 more choices" button Enter data for Answer 3 only Save Edit question again Check that only the 3 Answer fields you entered previously are displayed, with no extra Answer field. — Repeat test with MATCH and MULTICHOICE questions
    • Workaround:
      Hide

      Moodle 2.1 file question/type/edit_question_form.php line 323 and sq.

      replace

      if ($this->question->formoptions->repeatelements) {
          $repeatsatstart = max($minoptions, $countanswers + $addoptions);
      } else {
          $repeatsatstart = $countanswers;
      }
       

      with

      if ($this->question->formoptions->repeatelements) {
          if ($countanswers) {
              $repeatsatstart = $countanswers;
          } else {
              $repeatsatstart = $minoptions;
          }
      } else {
          $repeatsatstart = $countanswers;
      }
      Show
      Moodle 2.1 file question/type/edit_question_form.php line 323 and sq. replace if ($ this ->question->formoptions->repeatelements) { $repeatsatstart = max($minoptions, $countanswers + $addoptions); } else { $repeatsatstart = $countanswers; } with if ($ this ->question->formoptions->repeatelements) { if ($countanswers) { $repeatsatstart = $countanswers; } else { $repeatsatstart = $minoptions; } } else { $repeatsatstart = $countanswers; }
    • Affected Branches:
      MOODLE_21_STABLE
    • Rank:
      33930

      Description

      See this discussion: http://moodle.org/mod/forum/discuss.php?d=175290&parent=839414
      Whenever a question is re-edited, the editing interface systematically adds a number (usually 3) of new answer/choice boxes. This is not usually what the question creator wants, he may just want to fix a typo somewhere in the already entered answers, etc.
      And it's impossible to get rid of those unwanted Answer fields.
      See my suggested fix in the workaround below, and I will try to put that fix on my github once I get the MDL id for this bug report.

        Issue Links

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: