Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-19210 eliminate the generation of multiple dataitems having the s…

…ame item number

merge from HEAD
  • Loading branch information...
commit be88a9db22f344bdd9b615d0b4c4736c877af9a7 1 parent 9e8e843
pichetp authored
Showing with 13 additions and 2 deletions.
  1. +13 −2 question/type/calculated/questiontype.php
View
15 question/type/calculated/questiontype.php
@@ -668,8 +668,19 @@ function save_dataset_items($question, $fromform){
}
// echo "<pre>"; print_r($datasetdefs[$defid]->items);
for ($numberadded =$maxnumber+1 ; $numberadded <= $maxnumber+$numbertoadd ; $numberadded++){
- if (isset($datasetdefs[$defid]->items[$numberadded]) && ! $regenerate ){
- // echo "<p>Reuse an previously used record".$numberadded."id".$datasetdef->id."</p>";
+ if (isset($datasetdefs[$defid]->items[$numberadded]) ){
+ // in case of regenerate it modifies the already existing record
+ if ( $regenerate ) {
+ $datasetitem = new stdClass;
+ $datasetitem->id = $datasetdefs[$defid]->items[$numberadded]->id;
+ $datasetitem->definition = $datasetdef->id ;
+ $datasetitem->itemnumber = $numberadded;
+ $datasetitem->value = $this->generate_dataset_item($datasetdef->options);
+ if (!update_record('question_dataset_items', $datasetitem)) {
+ error("Error: Unable to update dataset item");
+ }
+ }
+ //if not regenerate do nothing as there is already a record
} else {
$datasetitem = new stdClass;
$datasetitem->definition = $datasetdef->id ;
Please sign in to comment.
Something went wrong with that request. Please try again.