Ordering of Grade Essays list - could it be alphabetical by student

Ordering of Grade Essays list - could it be alphabetical by student

by Steve Rowett -
Number of replies: 3
Hi

We're using Lessons for some medical scenarios which students work through. The Lesson tool is working very well for this and we are getting very positive student feedback (so, thanks!)

The student responses are mostly Essays, which are graded by volunteer tutors. We have 30 tutors, each with approx 12 students' work to mark.

The Grade Essay page shows the student submissions in date order, earliest to latest. This is causing problems for our tutors as they are having to pick out their students from a very long list.

Is it possible to change the sorting order to be alphabetical by student surname, so that the tutors could more quickly find their students from within the list?

Also just wondered if there is a reason for not being able to use groups - it would be handy in this case but the above would be nearly as good.

Many thanks for any help you can give,
Steve
Average of ratings: -
In reply to Steve Rowett

Re: Ordering of Grade Essays list - could it be alphabetical by student

by Peter Roberts -
To sort the results I resorted to hacking the code in essay.php. The page works by building an array of links - so it seemed easiest to just sort that before displaying it to the page. The hack is shown below - it looks at the link and extracts the last word in it which it assumes to be the surname - then sorts by that.

As I said - it's a last minute hack. I'm still kind of new to Moodle - so there may be a nicer Moodle way to do it with existing library functions - in which case I welcome your input - but as a quick and dirty fix this certainly works. It goes around line 300 or so just before print_table.


/*
* hack - two functions to process the $data array in the $table to allow sorting by lastname
*/
function ucl_stripname($n) {
// this extracts the lastname from the link string
$la=explode('</a>',$n);
$fullname=trim($la[1]);
$fa=explode(' ',$fullname);
$nc = count($fa);
if ($fa[$nc-1]<>'') {
$lastname=$fa[$nc-1];
}
else {
$lastname=$fullname; //just in case there's no space in their name
}

return $lastname;
}

function ucl_compare_lastname($a, $b) {
// custom sort
return strnatcmp(ucl_stripname($a[0]), ucl_stripname($b[0]));
} # sort alphabetically by lastname
usort($table->data, 'ucl_compare_lastname');
/*
* end of hack!
*/

Hope this is of use. Feedback welcome.
Pete
In reply to Peter Roberts

Re: Ordering of Grade Essays list - could it be alphabetical by student

by Jo Matthews -

Hi Pete,

To achieve the same result in moodle 2.2, I've modified mod/lesson/essay.php around line 331 and  just replaced

foreach (array_keys($studentessays) as $userid) {

with

foreach (array_keys($users) as $userid) {

$users is an array of all the users who have taken this lesson, order by their last name.

In reply to Jo Matthews

Re: Ordering of Grade Essays list - could it be alphabetical by student

by Frank Erazo -

Jo:

I applied your code and it worked.  However, teachers are asking if I can sort by date submitted - from newest to oldest.