]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8394 Allow students to remove their choice when they are allowed to update their...
authordanmarsden <danmarsden>
Thu, 3 May 2007 00:04:53 +0000 (00:04 +0000)
committerdanmarsden <danmarsden>
Thu, 3 May 2007 00:04:53 +0000 (00:04 +0000)
mod/choice/lib.php
mod/choice/view.php

index abb885f83e90bea2de44d252177ea464bdc2a559..b0217f4493beed9b4ab8d09102ce76788ce068c3 100644 (file)
@@ -224,6 +224,11 @@ function choice_show_form($choice, $user, $cm) {
     echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />";
     if (!isguest()) { //don't show save button if the logged in user is the guest user.
         echo "<input type=\"submit\" value=\"".get_string("savemychoice","choice")."\" />";
+        
+        if ($choice->allowupdate && $aaa = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id)) {
+            echo "<br /><a href='view.php?id=".$cm->id."&action=delchoice'>".get_string("removemychoice","choice")."</a>";
+        }
+        
     } else {
         print_string('havetologin', 'choice');
     }
index f047d52f6dbf23cfdf18f7303da57f3ba3534cb0..ba734978b9311c645fa919b853c9c566307d50f0 100644 (file)
         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