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

The number of dataitem is not set correctly when duplicating a calculated question

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.9.8
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      When a calculated (also calculatedsimple and calculatedmulti) is duplicate (save as a new question) the itemcount is set to the max number of item.
      It should be save to the original itemcount.
      If when editing the initial question you first create say 30 dataitems, then you delete the last 20 to use only the first 10 dataitems.
      When you "delete" lthe last 20 , they are not really deleted, the code only set the itemcount from 30 to 10.

      In the actual code the itemcount is set to the maximum item number i.e. 30.
      It should be set to olditemcount i.e. 10 in the given example.
      this resolves the problem

      RCS file: /cvsroot/moodle/moodle/question/type/calculated/questiontype.php,v
      retrieving revision 1.86
      diff -u -r1.86 questiontype.php
      — questiontype.php 29 Apr 2010 10:41:55 -0000 1.86
      +++ questiontype.php 7 May 2010 21:14:36 -0000
      @@ -1592,8 +1592,13 @@
      $DB->insert_record('question_dataset_items', $item);
      $itemcount++;
      }

      • //update item count
      • $datasetdef->itemcount =$itemcount;
        + //update item count to olditemcount if
        + // at least this number of items has been recover from the database
        + if( $olditemcount <= $itemcount ) { + $datasetdef->itemcount = $olditemcount; + }

        else

        { + $datasetdef->itemcount = $itemcount ; + }

        $DB->update_record('question_dataset_definitions', $datasetdef);
        } // end of copy the dataitems
        }// end of copy the datasetdef

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: