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

Deleting a calculated question delete datasetdefinitions shared by other question

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.8
    • Fix Version/s: 1.6.9, 1.7.7, 1.8.8, 1.9.4
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      the delete function delete all datasetdefiniton used by this question without testing if they are shared by other questions.
      if ($datasets = get_records('question_datasets', 'question', $questionid)) {
      foreach ($datasets as $dataset)

      { delete_records('question_dataset_definitions', 'id', $dataset->datasetdefinition); delete_records('question_dataset_items', 'definition', $dataset->datasetdefinition); }

      }

      changing this in HEAD to
      if ($datasets = $DB->get_records('question_datasets', array('question' => $questionid))) {
      foreach ($datasets as $dataset) {
      if (!$DB->get_records_select( // no other questions sharing this datasetdefinition
      'question_datasets',
      "question != ?
      AND datasetdefinition = ?;", array($questionid, $dataset->datasetdefinition)))

      { $DB->delete_records('question_dataset_definitions', array('id' => $dataset->datasetdefinition)); $DB->delete_records('question_dataset_items', array('definition' => $dataset->datasetdefinition)); }

      }
      }
      solve the problem.
      will merge down to 1.6
      We can conclude that either shared datasetdefinition are not so often used or that such calculated questions are too precious to be deleted ...

        Attachments

          Activity

            People

            Assignee:
            ppichet Pierre Pichet
            Reporter:
            ppichet Pierre Pichet
            Tester:
            Tim Hunt
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              28/Jan/09