From fb2491effb1a7d5d7abb0efba5b3929342990514 Mon Sep 17 00:00:00 2001 From: John Okely Date: Fri, 6 Nov 2015 13:42:10 +0800 Subject: [PATCH] MDL-51569 mod_choice: Prevent users from updating choices with curl --- mod/choice/lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 72404ebbab0..3fb0b80d7a2 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -928,6 +928,7 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) { * @return array status (available or not and possible warnings) */ function choice_get_availability_status($choice) { + global $DB, $USER; $available = true; $warnings = array(); @@ -942,6 +943,10 @@ function choice_get_availability_status($choice) { $warnings['expired'] = userdate($choice->timeclose); } } + if (!$choice->allowupdate && $DB->get_records('choice_answers', array('choiceid' => $choice->id, 'userid' => $USER->id))) { + $available = false; + $warnings['choicesaved'] = ''; + } // Choice is available. return array($available, $warnings);