Virtualbox + Ubuntu (hostはWindows)

Windows host の VirtualBox で,Ubuntu (16.04LTS) を入れようとしている.

日本語キーボードで US JP を使って英語配列のエミュレートという環境 (いろいろ事情が...)  Ubuntuのインストールの時には,US JP のエミュレートを無向にしておいて,日本語キーボードだというふうに設定するべきであるようだ.その後,英語配列エミュレートを有効にすれば,Virtual Box のなかでもエミュレートしてくれる.

ホームディレクトリの日本語ディレクトリ名を英語に変える:

$LANG=C xdg-user-dirs-gtk-update
(https://qiita.com/taiko19xx/items/d1a001bfc25245b91354 を参照.)

参照: http://gcg00467.xii.jp/wp/archives/1718

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 .
                                                                        '_' .

画像のデータに不足があります

latex で作成したPDFファイルを,Adobe Acrobat (11 および DC) で読んでいったら,画像を取り込んでいるところで,「画像のデータに不足があります」というダイアログボックスが出て,画像が表示されなかった.

# 今までこんなこと無かったと思うのだけれどなあ.気がついていなかっただけかなあ.

その画像は,JPGファイルを CygwinImageMagick の convert コマンドで PDF に変換したもので,それを includegraphics で読み込んでいる.プレビューはsumatra PDF で行っており,何の問題もなかった.検索をしてみると,Adobe は,過去にこの問題を認識している (Acrobat 9 とか 10 とかの時代) が,すでに修正済み,とのことらしい.

よくよくプロセスを見てみたら,dvipdfmx が警告を出していた:

dvipdfmx:warning: Version of PDF file (1.7) is newer than version limit specification.
dvipdfmx:warning: pdf_open: Not a PDF 1.[1-5] file.
dvipdfmx:warning: Trying to include PDF file which has newer version number than output PDF: 1.5.
ということで,画像のPDFファイルフォーマットが良くなかったということらしい.たまたまGraphicsMagick が cygwin にインストールされていたので,この convert コマンドをつかってみた.これで良いらしい.
$ gm convert -density 300 fig01.jpg fig01.pdf
$ pdfinfo fig01.pdf | grep 'PDF version'
PDF version: 1.2
実際に動作した.また,Acrobat にJPGファイルを読み込ませて保存した場合も,(今度はdvipdfmxの警告が 1.6 であって危ない,に変わったが) 動作した.(コマンドラインじゃないので勘弁して欲しいが.)  なお,dvipdfmx が警告を出すのは,自分が作るPDFファイルが1.5仕様だからであって,オプションで1.7仕様のものを作るようにする (-V 7) と,警告は出てこない.しかし,このようにして作成したPDFも,Acrobat で読むと「画像のデータに不足があります」になる.

keywords: tex image pdf version

moodle で課題評定一覧などにユーザ名を表示

moodle で,課題評定の一覧などにユーザ名 (username) が表示されない.ユーザ名に学籍番号を使っているので,学籍番号でソートすることができなくて不便である.デフォルトで表示されているのは氏名とメールアドレスである.このメールアドレスの部分は変更ができる.管理→サイト管理→ユーザ→パーミッション→ユーザポリシー→表示するユーザ固有情報 で選択すればよいのだが,あいにくここに username という選択肢がない.ソース (admin/settings/users.php) には,次のように書いてある:

 // Username is not included as an option because in some sites, it might
// be a security problem to reveal usernames even to trusted staff.
なんだかなあ.そんなの,その管理者が判断して出さないようにすればいいだけじゃないか.デフォルトでは出ないようにしていれば問題ないだろうに.ともあれ,以下の変更で表示可能となる.

--- admin/settings/users.php-20171202 2016-03-12 08:38:07.000000000 +0900
+++ admin/settings/users.php 2017-12-02 07:50:56.240459183 +0900
@@ -180,6 +180,7 @@
 // Username is not included as an option because in some sites, it might
 // be a security problem to reveal usernames even to trusted staff.
 // Custom user profile fields are not currently supported.
+ // *** Changed by XXX 2017-12-02. Username added (ignoring security issues).
 $temp->add(new admin_setting_configmulticheckbox('showuseridentity',
 new lang_string('showuseridentity', 'admin'),
 new lang_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
@@ -189,6 +190,7 @@
 'phone2' => new lang_string('phone2'),
 'department' => new lang_string('department'),
 'institution' => new lang_string('institution'),
+ 'username' => new lang_string('username'),
 )));
 $temp->add(new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50));
 $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'),

もちろん,ソースを変更しなくても,たとえば「IDナンバー」(ID number) で代用するという方法もある.だけど,既存ユーザの該当フィールドに全部設定して歩かなくてはいけないし,また,このフィールドはユーザが変更することができてしまう,というのがいまひとつである.
参照: http://gcg00467.xii.jp/wp/archives/1667

moodle 課題のダウンロード

更新版あり (2018/02/22)

moodle で,全提出課題を zip ファイルでダウンロード (「すべての提出をダウンロード」) できるが,各提出者のファイル名に,氏名は入っているのだけれど,usernameが入っていない.download_submission 関数を次のように変更すれば入れられる:

--- locallib.php-orig   2016-10-22 11:16:13.891650622 +0900
+++ locallib.php        2016-10-22 11:42:00.129553030 +0900
@@ -2686,7 +2686,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 = clean_filename($student->username . '_' . $prefix . '_' . $this->get_uniqueid_for_user($userid) . '_');
                 }

                 if ($submission) {