Permalink
Browse files

MDL-17524 Merging from HEAD

Deleting a calculated question delete datasetdefinitions shared by other question
  • Loading branch information...
1 parent 56f31bc commit 3e31f4e2e2fc957ba7eff4232cc992c265d16cd9 pichetp committed Dec 4, 2008
Showing with 7 additions and 2 deletions.
  1. +7 −2 question/type/calculated/questiontype.php
View
9 question/type/calculated/questiontype.php
@@ -465,8 +465,13 @@ function delete_question($questionid) {
delete_records("question_numerical_units", "question", $questionid);
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);
+ if (! get_records_select(
+ 'question_datasets',
+ "question != $questionid
+ AND datasetdefinition = $dataset->datasetdefinition;")){
+ delete_records('question_dataset_definitions', 'id', $dataset->datasetdefinition);
+ delete_records('question_dataset_items', 'definition', $dataset->datasetdefinition);
+ }
}
}
delete_records("question_datasets", "question", $questionid);

0 comments on commit 3e31f4e

Please sign in to comment.