Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-27508 workshop::prepare_grading_report_data() accepts $groupid
Workshop grades reports in all three last phases were fixed to support
the group selection. They layout of the report has been unified to be
consistent across all phases.
  • Loading branch information
mudrd8mz committed Apr 27, 2012
1 parent 8741ebb commit dda42a1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
8 changes: 3 additions & 5 deletions mod/workshop/locallib.php
Expand Up @@ -1540,14 +1540,14 @@ public function set_peer_grade($assessmentid, $grade) {
* Prepares data object with all workshop grades to be rendered
*
* @param int $userid the user we are preparing the report for
* @param mixed $groups single group or array of groups - only show users who are in one of these group(s). Defaults to all
* @param int $groupid if non-zero, prepare the report for the given group only
* @param int $page the current page (for the pagination)
* @param int $perpage participants per page (for the pagination)
* @param string $sortby lastname|firstname|submissiontitle|submissiongrade|gradinggrade
* @param string $sorthow ASC|DESC
* @return stdclass data for the renderer
*/
public function prepare_grading_report_data($userid, $groups, $page, $perpage, $sortby, $sorthow) {
public function prepare_grading_report_data($userid, $groupid, $page, $perpage, $sortby, $sorthow) {
global $DB;

$canviewall = has_capability('mod/workshop:viewallassessments', $this->context, $userid);
Expand All @@ -1568,9 +1568,7 @@ public function prepare_grading_report_data($userid, $groups, $page, $perpage, $

// get the list of user ids to be displayed
if ($canviewall) {
// fetch the list of ids of all workshop participants - this may get really long so fetch just id
$participants = get_users_by_capability($this->context, array('mod/workshop:submit', 'mod/workshop:peerassess'),
'u.id', '', '', '', $groups, '', false, false, true);
$participants = $this->get_participants(false, $groupid);
} else {
// this is an ordinary workshop participant (aka student) - display the report just for him/her
$participants = array($userid => (object)array('id' => $userid));
Expand Down
37 changes: 25 additions & 12 deletions mod/workshop/view.php
Expand Up @@ -253,15 +253,15 @@

if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
$perpage = get_user_preferences('workshop_perpage', 10);
$groups = ''; // todo let the user choose the group
$PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious
$data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
$groupid = groups_get_activity_group($workshop->cm, true);
$data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow);
if ($data) {
$showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
$showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);

// prepare paging bar
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page');
$baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow));
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page');

// grading report display options
$reportopts = new stdclass();
Expand All @@ -272,10 +272,15 @@
$reportopts->showsubmissiongrade = false;
$reportopts->showgradinggrade = false;

print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'));
echo $output->box_start('generalbox gradesreport');
echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
echo $output->render($pagingbar);
echo $output->render(new workshop_grading_report($data, $reportopts));
echo $output->render($pagingbar);
echo $output->perpage_selector($perpage);
echo $output->box_end();
print_collapsible_region_end();
}
}
if (trim($workshop->instructreviewers)) {
Expand Down Expand Up @@ -383,9 +388,8 @@
case workshop::PHASE_EVALUATION:
if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
$perpage = get_user_preferences('workshop_perpage', 10);
$groups = ''; // todo let the user choose the group
$PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious
$data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
$groupid = groups_get_activity_group($workshop->cm, true);
$data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow);
if ($data) {
$showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
$showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);
Expand All @@ -399,7 +403,8 @@
}

// prepare paging bar
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page');
$baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow));
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page');

// grading report display options
$reportopts = new stdclass();
Expand All @@ -410,10 +415,15 @@
$reportopts->showsubmissiongrade = true;
$reportopts->showgradinggrade = true;

print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'));
echo $output->box_start('generalbox gradesreport');
echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
echo $output->render($pagingbar);
echo $output->render(new workshop_grading_report($data, $reportopts));
echo $output->render($pagingbar);
echo $output->perpage_selector($perpage);
echo $output->box_end();
print_collapsible_region_end();
}
}
if (has_capability('mod/workshop:overridegrades', $workshop->context)) {
Expand Down Expand Up @@ -489,15 +499,15 @@
case workshop::PHASE_CLOSED:
if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
$perpage = get_user_preferences('workshop_perpage', 10);
$groups = ''; // todo let the user choose the group
$PAGE->set_url($PAGE->url, compact('sortby', 'sorthow', 'page')); // TODO: this is suspicious
$data = $workshop->prepare_grading_report_data($USER->id, $groups, $page, $perpage, $sortby, $sorthow);
$groupid = groups_get_activity_group($workshop->cm, true);
$data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow);
if ($data) {
$showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
$showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);

// prepare paging bar
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page');
$baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow));
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page');

// grading report display options
$reportopts = new stdclass();
Expand All @@ -509,10 +519,13 @@
$reportopts->showgradinggrade = true;

print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop'));
echo $output->box_start('generalbox gradesreport');
echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget');
echo $output->render($pagingbar);
echo $output->render(new workshop_grading_report($data, $reportopts));
echo $output->render($pagingbar);
echo $output->perpage_selector($perpage);
echo $output->box_end();
print_collapsible_region_end();
}
}
Expand Down

0 comments on commit dda42a1

Please sign in to comment.