コースのセクションにアンダースコア (アンダーバー) を含むファイル名のファイルをドラッグ&ドロップした場合にアンダースコアが取り除かれてしまうのを止めたいということですね。
恐らく、何らかの理由で敢えてファイル名に含まれるアンダースコアを取り除く処理を入れてあるのだと思います。どうしても、ファイルのドラッグ&ドロップ時にファイル名のアンダースコアが必要であるとお考えでしたら、以下のプログラム修正でご希望の動作になるかと思います。
修正対象プログラム:
course/dnduploadlib.php
修正箇所:
555行目
[ 修正前 ]
/**
* Generate the name of the mod instance from the name of the file
* (remove the extension and convert underscore => space
*
* @param string $filename the filename of the uploaded file
* @return string the display name to use
*/
protected function display_name_from_file($filename) {
$pos = core_text::strrpos($filename, '.');
if ($pos) { // Want to skip if $pos === 0 OR $pos === false.
$filename = core_text::substr($filename, 0, $pos);
}
return str_replace('_', ' ', $filename);
}
[ 修正後 ]
/**
* Generate the name of the mod instance from the name of the file
* (remove the extension and convert underscore => space
*
* @param string $filename the filename of the uploaded file
* @return string the display name to use
*/
protected function display_name_from_file($filename) {
$pos = core_text::strrpos($filename, '.');
if ($pos) { // Want to skip if $pos === 0 OR $pos === false.
$filename = core_text::substr($filename, 0, $pos);
}
// return str_replace('_', ' ', $filename);
return $filename;
}