Skip to content

Commit

Permalink
Merge branch 'MDL-29336-numerrors-mapping-20_STABLE' of git://github.…
Browse files Browse the repository at this point in the history
…com/mudrd8mz/moodle into MOODLE_20_STABLE
  • Loading branch information
Sam Hemelryk committed Sep 25, 2011
2 parents 3603e08 + c418df9 commit 5ea58ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mod/workshop/form/numerrors/lib.php
Expand Up @@ -164,6 +164,7 @@ public function save_edit_strategy_form(stdclass $data) {
$records = $data->numerrors; // data to be saved into {workshopform_numerrors} $records = $data->numerrors; // data to be saved into {workshopform_numerrors}
$mappings = $data->mappings; // data to be saved into {workshopform_numerrors_map} $mappings = $data->mappings; // data to be saved into {workshopform_numerrors_map}
$todelete = array(); // dimension ids to be deleted $todelete = array(); // dimension ids to be deleted
$maxnonegative = 0; // maximum number of (weighted) negative responses


for ($i=0; $i < $norepeats; $i++) { for ($i=0; $i < $norepeats; $i++) {
$record = $records[$i]; $record = $records[$i];
Expand All @@ -181,6 +182,7 @@ public function save_edit_strategy_form(stdclass $data) {
// exiting field // exiting field
$DB->update_record('workshopform_numerrors', $record); $DB->update_record('workshopform_numerrors', $record);
} }
$maxnonegative += $record->weight;
// re-save with correct path to embeded media files // re-save with correct path to embeded media files
$record = file_postupdate_standard_editor($record, 'description', $this->descriptionopts, $PAGE->context, $record = file_postupdate_standard_editor($record, 'description', $this->descriptionopts, $PAGE->context,
'workshopform_numerrors', 'description', $record->id); 'workshopform_numerrors', 'description', $record->id);
Expand Down Expand Up @@ -212,8 +214,8 @@ public function save_edit_strategy_form(stdclass $data) {
$insql = ''; $insql = '';
} }
$sql = "DELETE FROM {workshopform_numerrors_map} $sql = "DELETE FROM {workshopform_numerrors_map}
WHERE (($insql nonegative > :nodimensions) AND (workshopid = :workshopid))"; WHERE (($insql nonegative > :maxnonegative) AND (workshopid = :workshopid))";
$params['nodimensions'] = $norepeats; $params['maxnonegative'] = $maxnonegative;
$params['workshopid'] = $this->workshop->id; $params['workshopid'] = $this->workshop->id;
$DB->execute($sql, $params); $DB->execute($sql, $params);
} }
Expand Down

0 comments on commit 5ea58ff

Please sign in to comment.