Moodle1.9+で,テキストファイル形式とXML形式の時のみ,ブラウザーがIEだとファイル名が文字化けします.Moodle1.8.4+の頃はExcelとods形式も同じ理由でファイル名が文字化けしていたのですが,Moodle1.9になった際にgrade以下のファイルが大幅に刷新され,Excel/odsのエクスポートはHTMLヘッダーを使ったダウンロードではなくなったために問題が発生しないようです.
Moodle1.8.4の際にはこの問題はgrade/lib.php中に全ての形式のファイルのエクスポートのためのコードが入ってしました.これが,grade/export/形式別のフォルダに分かれました.
対策法は他の箇所とほぼ同じで,UTF-8形式のファイル名をrawurlencode()するか,S-JISに変換します.rawurlencode()ですとIEはOKになるのですが,Firefoxではエンコードされた文字列のままでダウンロードされてしまうので,S-JISに変換します.
(1) テキストファイル形式のエクスポート
grade/export/txt/grade_export_txt.php
function print_grades(), 73行目近辺
/// Print header to force download
@header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
@header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
@header('Pragma: no-cache');
header("Content-Type: application/download\n");
$downloadfilename = clean_filename("{$this->course->shortname} $strgrades");
// (IE_Problem021): ここから追加
$downloadfilename = mb_convert_encoding($downloadfilename, 'SJIS-WIN', 'UTF-8');
// (IE_Problem021): ここまで追加
header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
(2) XML形式のエクスポート
grade/export/xml/grade_expot_ml.php
function print_grades(), 49行目近辺
function print_grades($feedback = false) {
global $CFG;
require_once($CFG->libdir.'/filelib.php');
$export_tracking = $this->track_exports();
$strgrades = get_string('grades');
/// Calculate file name
$downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml");
// (IE_Problem021): ここから追加
$downloadfilename = mb_convert_encoding($downloadfilename, 'SJIS-WIN', 'UTF-8');
// (IE_Problem021): ここまで追加
make_upload_directory('temp/gradeexport', false);
以上です.