mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-8394 Allow students to remove their choice when they are allowed to update their choice.
This commit is contained in:
parent
8f8210b3e8
commit
243ac1feb4
@ -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');
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user