Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@tanabe13f

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

More than 1 year has passed since last update.

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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?