this block pasted below doesn't look right:
couple of things - $countanswers = get_records isn't in HEAD - it's the line you replace it with. $countanswers = $DB->get_records.
also - you've removed a few Carriage returns, and added extra spaces on empty lines which makes the patch a bit messy. - the cleaner and tidier the patch, the easier it is for other developers to see where your exact suggested changes are! - thanks for this! - it's great to see patches for frequently requested features! - it doesn't look like you're far off!
Dan
-
- $current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $userid);
+ global $DB;
+
+ $current = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $userid));
+ $current2 = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $userid,'optionid' => $formanswer));
$
context = get_context_instance(CONTEXT_MODULE, $cm->id);
- $countanswers = get_records("choice_answers", "optionid", $formanswer);
+ $countanswers = $DB->get_records("choice_answers", array('optionid'=> $formanswer));
if ($countanswers) {
+
$countans = 0;
foreach ($countanswers as $ca) { //only return enrolled users.
if (has_capability('mod/choice:choose', $context, $ca->userid, false)) {
$countans = $countans+1;
}
}
-