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

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

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 2.1
    • Questions
    • MOODLE_21_STABLE
    • 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; }
    • 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

      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.

            timhunt Tim Hunt
            rezeau Joseph Rézeau
            Tim Hunt Tim Hunt
            Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.