Moodle
  1. Moodle
  2. MDL-22386

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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

          Activity

          Hide
          Michael de Raadt added a comment -

          Thanks for reporting this issue.

          We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

          Michael d;

          lqjjLKA0p6

          Show
          Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
          Hide
          Pierre Pichet added a comment - - edited

          Tim,
          This has been fixed 2 years ago, just forgot to close.
          How should I proceed to close it?

          Show
          Pierre Pichet added a comment - - edited Tim, This has been fixed 2 years ago, just forgot to close. How should I proceed to close it?
          Hide
          Tim Hunt added a comment -

          As per the last comment, this has been fixed for a long time. Closing.

          Show
          Tim Hunt added a comment - As per the last comment, this has been fixed for a long time. Closing.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: