moodle 課題のダウンロード (更新)

前記事のバージョンアップ.moodle 3.4 で,課題一括ファイルダウンロードの際にユーザ名 (username) を入れるための修正.変なコードも入っているけど余り気にしないで....

--- mod/assign/locallib.php-orig        2018-02-22 19:14:37.752749187 +0900
+++ mod/assign/locallib.php     2018-02-22 19:40:12.383882868 +0900
@@ -3388,7 +3388,8 @@
                     $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;
+                    // $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid));
                 }

                 if ($submission) {
@@ -3402,6 +3403,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 .
@@ -3427,6 +3429,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 .
                                                                        '_' .