Skip to content

Commit

Permalink
Block now works as it intuitively should in separate groups mode as w…
Browse files Browse the repository at this point in the history
…ell.

For editing teachers, it shows separategroups as visiblegroups.
  • Loading branch information
defacer committed Jan 27, 2005
1 parent 84bbe7f commit b35bc4d
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions blocks/quiz_results/block_quiz_results.php
Expand Up @@ -76,10 +76,14 @@ function get_content() {
// The actual groupmode for the quiz is now known to be $groupmode
}

if($groupmode != NOGROUPS) {
// Group mode
if(isteacheredit($courseid) && $groupmode == SEPARATEGROUPS) {
// We 'll make an exception in this case
$groupmode = VISIBLEGROUPS;
}

// Pull out the course groups
switch($groupmode) {
case VISIBLEGROUPS:
// Display group-mode results
$groups = get_groups($courseid);

if(empty($groups)) {
Expand Down Expand Up @@ -192,10 +196,33 @@ function get_content() {
}
$this->content->text .= '</tbody></table>';
}
}
break;


else {
case SEPARATEGROUPS:
// This is going to be just like no-groups mode, only we 'll filter
// out the grades from people not in our group.
if(empty($USER) || empty($USER->id)) {
// Not logged in, so show nothing
return $this->content;
}

$mygroups = get_groups($courseid, $USER->id);
if(empty($mygroups)) {
// Not member of a group, show nothing
return $this->content;
}

$mygroupsusers = get_records_list('groups_members', 'groupid', implode(',', array_keys($mygroups)), '', 'userid, id');
// There should be at least one user there, ourselves. So no more tests.

// Just filter out the grades belonging to other users, and proceed as if there were no groups
$strallowedusers = implode(',', array_keys($mygroupsusers));
$grades = array_filter($grades, create_function('$el', '$allowed = explode(",", "'.$strallowedusers.'"); return in_array($el->userid, $allowed);'));

// NO break; HERE, JUST GO AHEAD
default:
case NOGROUPS:
// Single user mode
$numbest = empty($this->config->showbest) ? 0 : min($this->config->showbest, count($grades));
$numworst = empty($this->config->showworst) ? 0 : min($this->config->showworst, count($grades) - $numbest);
Expand Down Expand Up @@ -274,10 +301,9 @@ function get_content() {
}
$this->content->text .= '</tbody></table>';
}

break;
}


return $this->content;
}

Expand Down

0 comments on commit b35bc4d

Please sign in to comment.