From: danmarsden Date: Thu, 3 May 2007 00:04:53 +0000 (+0000) Subject: MDL-8394 Allow students to remove their choice when they are allowed to update their... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=243ac1feb4feccfd9858c670a8db75d97db33ca0;p=moodle.git MDL-8394 Allow students to remove their choice when they are allowed to update their choice. --- diff --git a/mod/choice/lib.php b/mod/choice/lib.php index abb885f83e..b0217f4493 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -224,6 +224,11 @@ function choice_show_form($choice, $user, $cm) { echo "id\" />"; if (!isguest()) { //don't show save button if the logged in user is the guest user. echo ""; + + if ($choice->allowupdate && $aaa = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id)) { + echo "
".get_string("removemychoice","choice").""; + } + } else { print_string('havetologin', 'choice'); } diff --git a/mod/choice/view.php b/mod/choice/view.php index f047d52f6d..ba734978b9 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -28,6 +28,12 @@ print_error('badcontext'); } +if ($action == 'delchoice') { + if ($answer = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $USER->id)) { + //print_object($answer); + delete_records('choice_answers', 'id', $answer->id); + } +} /// Submit any new data if there is any