Modified Codes for downloaded Excel with Sorting

Modified Codes for downloaded Excel with Sorting

by Norie chiba -
Number of replies: 4
My name is Norie Chiba and I work as a web developer for Royal Holloway, University of London. As we have a sorting problem, when downloding a list on Result Quiz Page to the Excel format, see more details
(http://moodle.org/mod/forum/discuss.php?d=115940&parent=519193)

I have modified codes in moodle\mod\quiz\report\overview\report.php to sort by user's requested order when an Excel is downloaded.

I tested and this looks OK.
But, I am not so much experienced PHP and Virtual learning environment,
if you find any errors in my codes or have any advices or suggestions, please let me know.

Any help would be grateful.

Thanks

Norie

I use Moodle 1.9.3

Line 410

Old Codes

if ($download){

$sort = '';

}

// Fix some wired sorting

if (empty($sort)) {

$sort = ' ORDER BY uniqueid';

} else {

$sort = ' ORDER BY '.$sort;

}

New Codes

if ($download){

//$sort = '';

if (empty($_SESSION['mysortstring'])) {

$sort ='';

}else {

$sort =$_SESSION['mysortstring'];

}

}

// Fix some wired sorting

if (empty($sort)) {

$sort = ' ORDER BY uniqueid';

} else {

// add here for using session to keep sort order for excel sheet

$_SESSION['mysortstring'] = $sort;

$sort = ' ORDER BY '.$sort;

}


Average of ratings: -
In reply to Norie chiba

Re: Modified Codes for downloaded Excel with Sorting

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
For better formatting, use the <code></code> tags.

// old code if ($download) { $sort = ''; } // Fix some wired sorting if (empty($sort)) { $sort = ' ORDER BY uniqueid'; } else { $sort = ' ORDER BY '.$sort; } //New Code if ($download){ //$sort = ''; if (empty($_SESSION['mysortstring'])) { $sort =''; }else { $sort =$_SESSION['mysortstring']; } } // Fix some wired sorting if (empty($sort)) { $sort = ' ORDER BY uniqueid'; } else { // add here for using session to keep sort order for excel sheet $_SESSION['mysortstring'] = $sort; $sort = ' ORDER BY '.$sort; }
Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Modified Codes for downloaded Excel with Sorting

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thanks Joseph.

Hmm Yucky user of session. Can't we get the sort order added to the URL that the download button goes to?
In reply to Joseph Rézeau

Re: Modified Codes for downloaded Excel with Sorting

by Norie chiba -
Dear Joseph,

Thanks for changing the format which looks more readable.


Norie