From: skodak Date: Tue, 24 Apr 2007 20:09:01 +0000 (+0000) Subject: MDL-9568 Choice does not count correct; merged from MOODLE_18_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=aa4836f4382a2e0f827af8561c2ea542309d8147;p=moodle.git MDL-9568 Choice does not count correct; merged from MOODLE_18_STABLE --- diff --git a/mod/choice/lib.php b/mod/choice/lib.php index ebd1118071..abb885f83e 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -365,7 +365,9 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { echo ""; echo ""; $count = 0; + $columncount = array(); // number of votes in each column foreach ($useranswer as $optionid => $userlist) { + $columncount[$optionid] = 0; // init counters if ($optionid) { echo ""; if (has_capability('mod/choice:readresponses', $context) && $optionid!=0) { echo ''; @@ -423,18 +426,9 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { continue; } echo "
"; } else if ($choice->showunanswered) { @@ -398,6 +400,7 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') { // hide admin/editting teacher (users with editting privilages) // show users without? I could be wrong. if (!($optionid==0 && has_capability('mod/choice:readresponses', $context, $user->id))) { // make sure admins and hidden teachers are not shown in not answered yet column. + $columncount[$optionid] += 1; echo "
"; - $countanswers = get_records("choice_answers", "optionid", $optionid); - $countans = 0; - if (!empty($countanswers)) { - foreach ($countanswers as $ca) { //only return enrolled users. - if (has_capability('mod/choice:choose', get_context_instance(CONTEXT_MODULE, $cm->id))) { - $countans = $countans+1; - } - } - } if ($choice->limitanswers && !$optionid==0) { echo get_string("taken", "choice").":"; - echo $countans; + echo $columncount[$optionid]; echo "
"; echo get_string("limit", "choice").":"; $choice_option = get_record("choice_options", "id", $optionid);