diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 539bd6b0e46..b6bc07e7871 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -130,11 +130,17 @@ function choice_show_form($choice, $user, $cm) { $cdisplay = array(); $aid = 0; + $choicefull = false; + + if ($choice->limitanswers) { //set choicefull to true by default if limitanswers. + $choicefull = true; + } + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + foreach ($choice->option as $optionid => $text) { if (isset($text)) { //make sure there are no dud entries in the db with blank text values. $countanswers = (get_records("choice_answers", "optionid", $optionid)); $countans = 0; - $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!empty($countanswers)) { foreach ($countanswers as $ca) { //only return enrolled users. if (has_capability('mod/choice:choose', $context, $ca->userid, false)) { @@ -163,6 +169,9 @@ function choice_show_form($choice, $user, $cm) { $cdisplay[$aid]->disabled = ' disabled="disabled" '; } else { $cdisplay[$aid]->disabled = ''; + if ($choice->limitanswers && ($countans < $maxans)) { + $choicefull = false; //set $choicefull to false - as the above condition hasn't been set. + } } $aid++; } @@ -222,13 +231,16 @@ function choice_show_form($choice, $user, $cm) { //show save choice button echo '