Moodle

allow manual quiz grading to sort by groups

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9.2
  • Component/s: Quiz
  • Labels:
    None
  • Environment:
    latest CVS from head this morning
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

It would be nice to be able to sort by groups when manually grading quizzes. In our environment at least there are quizzes taken at different times, so only 1 group might be left to grade. It's a pain to see all the users.

I have included the patch that fixes it.

//print activity group selector - Line 38 of /mod/quiz/report/grading/report.php

$userid = optional_param('userid', -1, PARAM_INT); //keeps it off of the grading page for one user
if($userid<0){
$reporturl = $CFG->wwwroot.'/mod/quiz/report.php?mode=grading';
$reporturlwithoptions = $reporturl . '&q=' . $quiz->id . '&action='.$action.'&questionid=' . $questionid;

/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);

if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used groups_print_activity_menu($cm, $reporturlwithoptions); }
}

//get users of specified group if group set or isn't all participants - Line 198 of /mod/quiz/report/grading/report.php (just before $userids = implode(',', array_keys($users)); )
$groupid = optional_param('group', -1, PARAM_INT);
if($groupid>0){ $users = groups_get_members($groupid, $fields='u.id', $sort='firstname ASC'); }

Issue Links

Activity

Hide
Tim Hunt added a comment -

Thank you very much for the proposed fix. I am really busy right now, so I probably won't have time to look at it until after Christmas, but it was already on my list of things to worry about, as you can see from the duplicate bug.

Show
Tim Hunt added a comment - Thank you very much for the proposed fix. I am really busy right now, so I probably won't have time to look at it until after Christmas, but it was already on my list of things to worry about, as you can see from the duplicate bug.
Hide
Karlene Clapp added a comment -

A bug was found with paging because there was no group variable being passed. I added this patch to my patch. There's probably an easier way, but this was my quick fix.

//pass group variable in URL for paging Line 216 - /mod/quiz/report/grading/report.php
$groupid = optional_param('group', -1, PARAM_INT);
if($groupid>0){ $table->define_baseurl($CFG->wwwroot.'/mod/quiz/report.php?mode=grading&q='.$quiz->id.'&action=viewquestion&questionid='.$question->id. '&group='.$groupid); }

//only difference from other baseurl previously set is the group variable at the end

Show
Karlene Clapp added a comment - A bug was found with paging because there was no group variable being passed. I added this patch to my patch. There's probably an easier way, but this was my quick fix. //pass group variable in URL for paging Line 216 - /mod/quiz/report/grading/report.php $groupid = optional_param('group', -1, PARAM_INT); if($groupid>0){ $table->define_baseurl($CFG->wwwroot.'/mod/quiz/report.php?mode=grading&q='.$quiz->id.'&action=viewquestion&questionid='.$question->id. '&group='.$groupid); } //only difference from other baseurl previously set is the group variable at the end
Hide
Karlene Clapp added a comment -

for this one:
//get users of specified group if group set or isn't all participants - Line 198 of /mod/quiz/report/grading/report.php (just before $userids = implode(',', array_keys($users)); )
$groupid = optional_param('group', -1, PARAM_INT);
if($groupid>0){
$users = groups_get_members($groupid, $fields='u.id', $sort='firstname ASC');
}

You need to find a way to check current group (for that activity) so that the group holds from Overview to Manual Grading as the selector already does. Without checking current group the selector holds, but all the users are shown until the selector is toggled again.

I am using a patcher so I added a class variable $this->currentgroup to my patcher method class to hold it but I will let you decide how to do it for core. Replace $this->currentgroup with whatever variable has the current group.

$groupid = optional_param('group', -1, PARAM_INT);
if($groupid>0)
$this->currentgroup=$groupid;

if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); }

Show
Karlene Clapp added a comment - for this one: //get users of specified group if group set or isn't all participants - Line 198 of /mod/quiz/report/grading/report.php (just before $userids = implode(',', array_keys($users)); ) $groupid = optional_param('group', -1, PARAM_INT); if($groupid>0){ $users = groups_get_members($groupid, $fields='u.id', $sort='firstname ASC'); } You need to find a way to check current group (for that activity) so that the group holds from Overview to Manual Grading as the selector already does. Without checking current group the selector holds, but all the users are shown until the selector is toggled again. I am using a patcher so I added a class variable $this->currentgroup to my patcher method class to hold it but I will let you decide how to do it for core. Replace $this->currentgroup with whatever variable has the current group. $groupid = optional_param('group', -1, PARAM_INT); if($groupid>0) $this->currentgroup=$groupid; if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); }
Hide
Karlene Clapp added a comment -

I added a couple more patches to get it to work with the Grade All link. This is the entire patch of the file /mod/quiz/report/grading/report.php

========================================================

function display if (!empty($questionid)) {

//prints the selector menu
$userid = optional_param('userid', -1, PARAM_INT); //keeps it off of the grading page for one user

if($userid<0){
$reporturl = $CFG->wwwroot.'/mod/quiz/report.php?mode=grading';
$reporturlwithoptions = $reporturl . '&q=' . $quiz->id . '&action='.$action.'&questionid=' . $questionid;

$gradeall = optional_param('gradeall', 0, PARAM_INT);
if($gradeall>0)
$reporturlwithoptions .= '&gradeall=1';

/// find out current groups mode

$this->currentgroup = groups_get_activity_group($cm, true); //$currentgroup should be a class variable added. will use again later

if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used groups_print_activity_menu($cm, $reporturlwithoptions); }
}

========================================================

function view_questions - before if($attempts = get_record_select.......
//sets up the users based on the active group. If active group is all (0) or not set, shows all participants.
$groupid = optional_param('group', -1, PARAM_INT);

if($groupid>0)
$this->currentgroup=$groupid;

if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); }

========================================================

function view_question - just before $usercount = count($users)
//same code as previous one, sets up users again based on group
$groupid = optional_param('group', -1, PARAM_INT);
$groupslink='';
if($groupid>0)
$this->currentgroup=$groupid;

if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); $groupslink = '&group=$this->currentgroup'; }

=================================
function view_question - replace $table->define_baseurl($CFG->wwwroot.'/mod/quiz/report.php?mode=grading&q='.$quiz->id.'&action=viewquestion&questionid='.$question->id);

with

$table->define_baseurl($CFG->wwwroot.'/mod/quiz/report.php?mode=grading&q='.$quiz->id.'&action=viewquestion&questionid='.$question->id$groupslink);

===================================

function view_question replace
$links = "<div class=\"boxaligncenter\"><a href=\"report.php?mode=grading&action=grade&q=$quiz->id&questionid=$question->id&gradeall=1\">".get_string('gradeall', 'quiz').'</a> | '.

with

$links = "<div class=\"boxaligncenter\"><a href=\"report.php?mode=grading&action=grade&q=$quiz->id&questionid=$question->id$groupslink&gradeall=1\">".get_string('gradeall', 'quiz').'</a> | '.



==============================================

function print_questions_and_form - before first $select =

//setup users again - same code (should probably be a function b/c it's used a lot) - implement groupslink when needed, but otherwise the same code
$groupid = optional_param('group', -1, PARAM_INT);

if($groupid>0)
$this->currentgroup=$groupid;

if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); }
}

========================================================

I hope this patch helps move along the process of groups in quizzes. Let me know if you have any questions. I had to modify some of my patch code to fit core, as I'm using a patcher written by Gary Anderson to patch our local version, so if something's off or doesn't work let me know.

Thanks,

Karlene

Show
Karlene Clapp added a comment - I added a couple more patches to get it to work with the Grade All link. This is the entire patch of the file /mod/quiz/report/grading/report.php ======================================================== function display if (!empty($questionid)) { //prints the selector menu $userid = optional_param('userid', -1, PARAM_INT); //keeps it off of the grading page for one user if($userid<0){ $reporturl = $CFG->wwwroot.'/mod/quiz/report.php?mode=grading'; $reporturlwithoptions = $reporturl . '&q=' . $quiz->id . '&action='.$action.'&questionid=' . $questionid; $gradeall = optional_param('gradeall', 0, PARAM_INT); if($gradeall>0) $reporturlwithoptions .= '&gradeall=1'; /// find out current groups mode $this->currentgroup = groups_get_activity_group($cm, true); //$currentgroup should be a class variable added. will use again later if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used groups_print_activity_menu($cm, $reporturlwithoptions); } } ======================================================== function view_questions - before if($attempts = get_record_select....... //sets up the users based on the active group. If active group is all (0) or not set, shows all participants. $groupid = optional_param('group', -1, PARAM_INT); if($groupid>0) $this->currentgroup=$groupid; if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); } ======================================================== function view_question - just before $usercount = count($users) //same code as previous one, sets up users again based on group $groupid = optional_param('group', -1, PARAM_INT); $groupslink=''; if($groupid>0) $this->currentgroup=$groupid; if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); $groupslink = '&group=$this->currentgroup'; } ================================= function view_question - replace $table->define_baseurl($CFG->wwwroot.'/mod/quiz/report.php?mode=grading&q='.$quiz->id.'&action=viewquestion&questionid='.$question->id); with $table->define_baseurl($CFG->wwwroot.'/mod/quiz/report.php?mode=grading&q='.$quiz->id.'&action=viewquestion&questionid='.$question->id$groupslink); =================================== function view_question replace $links = "<div class=\"boxaligncenter\"><a href=\"report.php?mode=grading&action=grade&q=$quiz->id&questionid=$question->id&gradeall=1\">".get_string('gradeall', 'quiz').'</a> | '. with $links = "<div class=\"boxaligncenter\"><a href=\"report.php?mode=grading&action=grade&q=$quiz->id&questionid=$question->id$groupslink&gradeall=1\">".get_string('gradeall', 'quiz').'</a> | '. ============================================== function print_questions_and_form - before first $select = //setup users again - same code (should probably be a function b/c it's used a lot) - implement groupslink when needed, but otherwise the same code $groupid = optional_param('group', -1, PARAM_INT); if($groupid>0) $this->currentgroup=$groupid; if($this->currentgroup>0){ $users = groups_get_members($this->currentgroup, $fields='u.id', $sort='firstname ASC'); $userids = implode(',', array_keys($users)); } } ======================================================== I hope this patch helps move along the process of groups in quizzes. Let me know if you have any questions. I had to modify some of my patch code to fit core, as I'm using a patcher written by Gary Anderson to patch our local version, so if something's off or doesn't work let me know. Thanks, Karlene
Hide
Tim Hunt added a comment -

It would make my life easier if you could make a proper patch file of these changes. http://docs.moodle.org/en/Development:How_to_create_a_patch explains how.

Show
Tim Hunt added a comment - It would make my life easier if you could make a proper patch file of these changes. http://docs.moodle.org/en/Development:How_to_create_a_patch explains how.
Hide
Karlene Clapp added a comment -

Here you go.

Show
Karlene Clapp added a comment - Here you go.
Hide
Tim Hunt added a comment -

Assigning quiz report issues mentioned in http://docs.moodle.org/en/Development:Quiz_report_enhancements to Jamie.

Show
Tim Hunt added a comment - Assigning quiz report issues mentioned in http://docs.moodle.org/en/Development:Quiz_report_enhancements to Jamie.
Hide
Martin Dougiamas added a comment -

I've not tested functionality, but some problems with the new code include :

tabs instead of spaces
not using correct bracketing and spacing (see Coding guide in Moodle docs)

Jamie, any chance we could get this tested and checked into HEAD and 1.9.1+ relatively soon?

Show
Martin Dougiamas added a comment - I've not tested functionality, but some problems with the new code include : tabs instead of spaces not using correct bracketing and spacing (see Coding guide in Moodle docs) Jamie, any chance we could get this tested and checked into HEAD and 1.9.1+ relatively soon?
Hide
Jamie Pratt added a comment -

Taking a look at the patch now.

Show
Jamie Pratt added a comment - Taking a look at the patch now.
Hide
Jamie Pratt added a comment -

Committed a patch for this. I didn't use Karlene's code. Used standard groups code as used in the rest of Moodle.

Show
Jamie Pratt added a comment - Committed a patch for this. I didn't use Karlene's code. Used standard groups code as used in the rest of Moodle.

People

Vote (1)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: