From 243ac1feb4feccfd9858c670a8db75d97db33ca0 Mon Sep 17 00:00:00 2001 From: danmarsden Date: Thu, 3 May 2007 00:04:53 +0000 Subject: [PATCH] MDL-8394 Allow students to remove their choice when they are allowed to update their choice. --- mod/choice/lib.php | 5 +++++ mod/choice/view.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/mod/choice/lib.php b/mod/choice/lib.php index abb885f83e9..b0217f4493b 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 f047d52f6db..ba734978b93 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