LoginSignup
0
0

More than 5 years have passed since last update.

Moodleで課題一括ダウンロード時のフォルダ名にユーザ名を入れる

Posted at

Moodleで課題の一括ダウンロードをする際,フォルダ名に,学生の名前は入るが,ユーザ名が入っていない.ユーザ名を学籍番号にしているので,ユーザ名が入ってくれるとフォルダが学籍番号順になってくれて嬉しいので,入れることにした..ついでに,(学生ごとの)フォルダ名に assignsubmission という長い文字列が入って邪魔なので as と短縮する.
mod/locallib.php を修正する.

--- locallib.php-orig   2019-05-05 15:36:20.724294366 +0900
+++ locallib.php        2019-05-05 15:53:59.152414973 +0900
@@ -3408,7 +3408,7 @@
                     $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid));
                 } else {
                     $prefix = str_replace('_', ' ', $groupname . fullname($student));
-                    $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid));
+                    $prefix = $student->username . '_' . $prefix;
                 }

                 if ($submission) {
@@ -3422,6 +3422,7 @@
                                 $pluginfiles = $plugin->get_files($submission, $student);
                                 foreach ($pluginfiles as $zipfilepath => $file) {
                                     $subtype = $plugin->get_subtype();
+                                    if (strcmp($subtype, "assignsubmission") == 0) { $subtype = "as"; }
                                     $type = $plugin->get_type();
                                     $zipfilename = basename($zipfilepath);
                                     $prefixedfilename = clean_filename($prefix .
@@ -3447,6 +3448,7 @@
                                 $pluginfiles = $plugin->get_files($submission, $student);
                                 foreach ($pluginfiles as $zipfilename => $file) {
                                     $subtype = $plugin->get_subtype();
+                                    if (strcmp($subtype, "assignsubmission") == 0) { $subtype = "as"; }
                                     $type = $plugin->get_type();
                                     $prefixedfilename = clean_filename($prefix .
                                                                        '_' .

上のpatchは,Moodle 3.6用である.私のところでは動作しているけれど,言うまでもなく無保証なので,ソースを読んでこれで良いと信じられる場合のみお使いください.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0