X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=blobdiff_plain;f=mod%2Fchoice%2Flib.php;h=5d221128b485c257658eadebf6794242741906b4;hp=4e799c8908b0386018ac880885858e31ff66654b;hb=4a5bbd9cda1058cbe1e34dd129ee5c810e2dbef8;hpb=4a132893e0136feb38331d223a322728a4f8beb4 diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 4e799c8908b..5d221128b48 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -180,8 +180,11 @@ function choice_update_instance($choice) { $option->id=$choice->optionid[$key]; if (isset($value) && $value <> '') { $DB->update_record("choice_options", $option); - } else { //empty old option - needs to be deleted. - $DB->delete_records("choice_options", array("id"=>$option->id)); + } else { + // Remove the empty (unused) option. + $DB->delete_records("choice_options", array("id" => $option->id)); + // Delete any answers associated with this option. + $DB->delete_records("choice_answers", array("choiceid" => $choice->id, "optionid" => $option->id)); } } else { if (isset($value) && $value <> '') {