Commit 02d8c8ca authored by John Okely's avatar John Okely Committed by Andrew Nicols
Browse files

MDL-51569 mod_choice: Prevent users from updating choices with curl

parent 11d4f442
...@@ -852,6 +852,7 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) { ...@@ -852,6 +852,7 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) {
* @return array status (available or not and possible warnings) * @return array status (available or not and possible warnings)
*/ */
function choice_get_availability_status($choice) { function choice_get_availability_status($choice) {
global $DB, $USER;
$available = true; $available = true;
$warnings = array(); $warnings = array();
...@@ -866,6 +867,10 @@ function choice_get_availability_status($choice) { ...@@ -866,6 +867,10 @@ function choice_get_availability_status($choice) {
$warnings['expired'] = userdate($choice->timeclose); $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. // Choice is available.
return array($available, $warnings); return array($available, $warnings);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment