Modified Codes for downloaded Excel with Sorting

Modified Codes for downloaded Excel with Sorting

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;

}


評比平均分數: -
In reply to Norie chiba

Re: Modified Codes for downloaded Excel with Sorting

Joseph Rézeau發表於
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片 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; }
評比平均分數:Useful (1)
In reply to Joseph Rézeau

Re: Modified Codes for downloaded Excel with Sorting

Tim Hunt發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 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

Norie chiba發表於
Dear Joseph,

Thanks for changing the format which looks more readable.


Norie