From: danmarsden Date: Fri, 18 Jan 2008 00:32:31 +0000 (+0000) Subject: fix for MDL-7128 - hide save button when options are all full. and tidy up of old... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3c56a7cc9346d4fc65f00f4081dd0573afdfb90a;p=moodle.git fix for MDL-7128 - hide save button when options are all full. and tidy up of old is_guest call --- diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 539bd6b0e4..b6bc07e787 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 '
'; echo "id\" />"; - if (!isguest()) { //don't show save button if the logged in user is the guest user. - echo ""; - + if (has_capability('mod/choice:choose', $context, $user->id, false)) { //don't show save button if the logged in user is the guest user. + if ($choicefull) { + print_string('choicefull', 'choice'); + echo "
"; + } else { + echo ""; + } if ($choice->allowupdate && $aaa = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id)) { echo "
".get_string("removemychoice","choice").""; } - } else { print_string('havetologin', 'choice'); }