View
3 mod/quiz/report/grading/gradingsettings_form.php
@@ -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');
View
3 mod/quiz/report/grading/lang/en/quiz_grading.php
@@ -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';
View
17 mod/quiz/report/grading/report.php
@@ -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;
@@ -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;
}
}

0 comments on commit a41945e

Please sign in to comment.