Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.10, 2.3.6, 2.4.2, 2.5
    • Fix Version/s: 2.3.7, 2.4.4
    • Component/s: Questions
    • Labels:
      None
    • Testing Instructions:
      Hide

      Before applying the solution
      Create a calculatedsimple question, save it
      Edit the question and make a copy.
      If you preview the second question there a message of double record although the question seems OK

      If you look at the question_dataset_definitions there should be double records.
      After doing the modification

      If you preview the second question there should be no message of double record.
      If you look at the question_dataset_definitions there should be no double records.

      Show
      Before applying the solution Create a calculatedsimple question, save it Edit the question and make a copy. If you preview the second question there a message of double record although the question seems OK If you look at the question_dataset_definitions there should be double records. After doing the modification If you preview the second question there should be no message of double record. If you look at the question_dataset_definitions there should be no double records.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull 2.4 Branch:
    • Pull Master Branch:
    • Rank:
      48398

      Description

      When saving as new a calculatedsimple question the datasets are copy twice leading to double records.

        Activity

        Hide
        Pierre Pichet added a comment - - edited

        In calculatedsimple all the question data including the datasets are on the form so we should be able
        to save the question as a regular one.

        In calculated the code begin by

         
        public function save_question($question, $form) {
                global $DB;
                if ($this->wizardpagesnumber() == 1) {
                        $question = parent::save_question($question, $form);
                    return $question;
                }
        

        replacing

        if ($this->wizardpagesnumber() == 1)

        by

        ($this->wizardpagesnumber() == 1 || $question->qtype == 'calculatedsimple')

        On testing with echo $this->wizardpagesnumber() return 3 which is the value for calculated ???

        This solve the problem as verify when looking at database after a "Make copy" of an existing question.

        This affect all versions 2.0 ...

        Show
        Pierre Pichet added a comment - - edited In calculatedsimple all the question data including the datasets are on the form so we should be able to save the question as a regular one. In calculated the code begin by public function save_question($question, $form) { global $DB; if ($this->wizardpagesnumber() == 1) { $question = parent::save_question($question, $form); return $question; } replacing if ($this->wizardpagesnumber() == 1) by ($this->wizardpagesnumber() == 1 || $question->qtype == 'calculatedsimple') On testing with echo $this->wizardpagesnumber() return 3 which is the value for calculated ??? This solve the problem as verify when looking at database after a "Make copy" of an existing question. This affect all versions 2.0 ...
        Hide
        Tim Hunt added a comment -

        That looks good. Please can you create branches for the 23 and 24 stabler branches, then we can submit this for integration.

        Show
        Tim Hunt added a comment - That looks good. Please can you create branches for the 23 and 24 stabler branches, then we can submit this for integration.
        Hide
        Pierre Pichet added a comment -

        This should be done in the weekend.

        Show
        Pierre Pichet added a comment - This should be done in the weekend.
        Hide
        Pierre Pichet added a comment -

        Done.
        Could you take a look at MDL-31680 .If OK I will create the branches.

        Show
        Pierre Pichet added a comment - Done. Could you take a look at MDL-31680 .If OK I will create the branches.
        Hide
        Tim Hunt added a comment -

        Thanks Pierre.

        Show
        Tim Hunt added a comment - Thanks Pierre.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated (23, 24 and master), thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated (23, 24 and master), thanks!
        Hide
        Andrew Davis added a comment -

        I think this is working as it should. Passing.

        Show
        Andrew Davis added a comment - I think this is working as it should. Passing.
        Hide
        Damyon Wiese added a comment -

        This issue has been integrated upstream and is now available via git (and in some hours, via mirrors and downloads).

        Thanks for your contributions!

        Show
        Damyon Wiese added a comment - This issue has been integrated upstream and is now available via git (and in some hours, via mirrors and downloads). Thanks for your contributions!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: