mirror of
https://github.com/moodle/moodle.git
synced 2025-02-19 15:45:59 +01:00
MDL-12890 - differing values for number of choice responses link to what is
displayed merged from MOODLE_19_STABLE
This commit is contained in:
parent
b26adbef4c
commit
5c88048813
@ -283,28 +283,27 @@ function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $
|
||||
}
|
||||
|
||||
|
||||
function choice_show_reportlink($choice, $courseid, $cmid, $groupmode) {
|
||||
//TODO: rewrite with SQL
|
||||
$currentgroup = get_current_group($courseid);
|
||||
if ($allanswers = get_records("choice_answers", "choiceid", $choice->id)) {
|
||||
$responsecount = 0;
|
||||
foreach ($allanswers as $aa) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cmid);
|
||||
if (has_capability('mod/choice:choose', $context, $aa->userid, false)) { //check to make sure user is enrolled/has this capability.
|
||||
if ($groupmode and $currentgroup) {
|
||||
if (groups_is_member($currentgroup, $aa->userid)) {
|
||||
$responsecount++;
|
||||
}
|
||||
} else {
|
||||
$responsecount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
function choice_show_reportlink($choice, $courseid, $cm, $groupmode) {
|
||||
|
||||
if ($groupmode > 0) {
|
||||
$currentgroup = groups_get_activity_group($cm);
|
||||
} else {
|
||||
$responsecount = 0;
|
||||
$currentgroup = 0;
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$availableusers = get_users_by_capability($context, 'mod/choice:choose', 'u.id', '','','',$currentgroup, '', false, true);
|
||||
|
||||
$responsecount = 0;
|
||||
|
||||
if(!empty($availableusers)){
|
||||
// flatten the users to get a list of userids
|
||||
$userids = implode( ', ', array_keys($availableusers));
|
||||
$responsecount = count_records_select('choice_answers', "choiceid = {$choice->id} AND userid IN ( $userids );");
|
||||
}
|
||||
|
||||
echo '<div class="reportlink">';
|
||||
echo "<a href=\"report.php?id=$cmid\">".get_string("viewallresponses", "choice", $responsecount)."</a>";
|
||||
echo "<a href=\"report.php?id=$cm->id\">".get_string("viewallresponses", "choice", $responsecount)."</a>";
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ if ($action == 'delchoice') {
|
||||
groups_print_activity_menu($cm, 'view.php?id='.$id);
|
||||
|
||||
if (has_capability('mod/choice:readresponses', $context)) {
|
||||
choice_show_reportlink($choice, $course->id, $cm->id, $groupmode);
|
||||
choice_show_reportlink($choice, $course->id, $cm, $groupmode);
|
||||
}
|
||||
|
||||
echo '<div class="clearer"></div>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user