Skip to content

Commit

Permalink
MDL-42069 mod_quiz add lastname sort for manual grading
Browse files Browse the repository at this point in the history
  • Loading branch information
woolardfa committed Oct 4, 2013
1 parent 56cc9b3 commit a41945e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion mod/quiz/report/grading/gradingsettings_form.php
Expand Up @@ -79,7 +79,8 @@ protected function definition() {
'date' => get_string('bydate', 'quiz_grading'),
);
if ($this->shownames) {
$orderoptions['student'] = get_string('bystudentname', 'quiz_grading');
$orderoptions['studentfirstname'] = get_string('bystudentfirstname', 'quiz_grading');
$orderoptions['studentlastname'] = get_string('bystudentlastname', 'quiz_grading');
}
if ($this->showidnumbers) {
$orderoptions['idnumber'] = get_string('bystudentidnumber', 'quiz_grading');
Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/report/grading/lang/en/quiz_grading.php
Expand Up @@ -30,7 +30,8 @@
$string['backtothelistofquestions'] = 'Back to the list of questions';
$string['bydate'] = 'By date';
$string['bystudentidnumber'] = 'By student id number';
$string['bystudentname'] = 'By student name';
$string['bystudentfirstname'] = 'By student first name';
$string['bystudentlastname'] = 'By student last name';
$string['cannotloadquestioninfo'] = 'Unable to load questiontype specific question information';
$string['cannotgradethisattempt'] = 'Cannot grade this attempt.';
$string['changeoptions'] = 'Change options';
Expand Down
17 changes: 12 additions & 5 deletions mod/quiz/report/grading/report.php
Expand Up @@ -89,9 +89,9 @@ public function display($quiz, $cm, $course) {
$showidnumbers = has_capability('quiz/grading:viewidnumber', $this->context);

// Validate order.
if (!in_array($order, array('random', 'date', 'student', 'idnumber'))) {
if (!in_array($order, array('random', 'date', 'studentfirstname', 'studentlastname', 'idnumber'))) {
$order = self::DEFAULT_ORDER;
} else if (!$shownames && $order == 'student') {
} else if (!$shownames && ($order == 'studentfirstname' || $order == 'studentlastname')) {
$order = self::DEFAULT_ORDER;
} else if (!$showidnumbers && $order == 'idnumber') {
$order = self::DEFAULT_ORDER;
Expand Down Expand Up @@ -547,10 +547,17 @@ protected function get_usage_ids_where_question_in_state($summarystate, $slot,
WHERE sortqas.questionattemptid = qa.id
AND sortqas.state $statetest
)";
} else if ($orderby == 'student' || $orderby == 'idnumber') {
} else if ($orderby == 'studentfirstname' || $orderby == 'studentlastname' || $orderby == 'idnumber') {
$qubaids->from .= " JOIN {user} u ON quiza.userid = u.id ";
if ($orderby == 'student') {
$orderby = $DB->sql_fullname('u.firstname', 'u.lastname');
// For name sorting, map orderby form value to
// actual column names; 'idnumber' maps naturally
switch ($orderby) {
case "studentlastname":
$orderby = "u.lastname, u.firstname";
break;
case "studentfirstname":
$orderby = "u.firstname, u.lastname";
break;
}
}

Expand Down

0 comments on commit a41945e

Please sign in to comment.