mod_quizにこだわって分析したい場合のカスタマイズをまとめておく。端的にはこの記事の続編である。今回からはUNIX VMを準備するのはやめ、Ubuntu on Windows10で開発環境を構築している。XAMPとかVMWare Playerをインストールする必要がなくなり素晴らしい。対象は、mod/quiz/review.php, mod/quiz/report/{attemptsreport_table,attemptsreport}.phpである。
前提として、もしPHPスクリプトでどのようなクエリを発行しているのか知りたければ、各スクリプト冒頭のrequire群の後に以下を追加すればよい(だいたい後悔するのがオチである)。相変わらずたいしたことはやっていない。
[code]$DB->set_debug(true);[/code]
- mod/quiz/review.php それぞれの受験結果について、すべてを1ページにまとめて表示/内部IDを表示/時刻をUNIX形式に
[code]uep@ROBBY:/var/www/html/mod/quiz$ diff -up review.php review.php.orig
— review.php 2016-11-30 16:08:11.177961500 +0100
+++ review.php.orig 2016-11-30 14:50:08.366458300 +0100
@@ -32,8 +32,7 @@ require_once($CFG->dirroot . ‘/mod/quiz/$attemptid = required_param(‘attempt’, PARAM_INT);
$page = optional_param(‘page’, 0, PARAM_INT);
-$showall = optional_param(‘showall’, 1, PARAM_BOOL);
+$showall = optional_param(‘showall’, 0, PARAM_BOOL);$url = new moodle_url(‘/mod/quiz/review.php’, array(‘attempt’=>$attemptid));
if ($page !== 0) {
@@ -139,8 +138,7 @@ if (!$attemptobj->get_quiz()->showuserpi
‘title’ => $usrepicture,
‘content’ => new action_link(new moodle_url(‘/user/view.php’, array(
‘id’ => $student->id, ‘course’ => $attemptobj->get_courseid())),
– $student->id),
+ fullname($student, true)),
);
}@@ -158,8 +156,7 @@ if ($attemptobj->has_capability(‘mod/qui
// Timing information.
$summarydata[‘startedon’] = array(
‘title’ => get_string(‘startedon’, ‘quiz’),
– ‘content’ => $attempt->timestart,
+ ‘content’ => userdate($attempt->timestart),
);$summarydata[‘state’] = array(
@@ -170,8 +167,7 @@ $summarydata[‘state’] = array(
if ($attempt->state == quiz_attempt::FINISHED) {
$summarydata[‘completedon’] = array(
‘title’ => get_string(‘completedon’, ‘quiz’),
– ‘content’ => $attempt->timefinish,
+ ‘content’ => userdate($attempt->timefinish),
);
$summarydata[‘timetaken’] = array(
‘title’ => get_string(‘timetaken’, ‘quiz’),[/code] - report/attemptsreport.php 内部IDを表示
[code]uep@ROBBY:/var/www/html/mod/quiz$ diff -up report/attemptsreport.php report/attemptsreport.php.orig
— report/attemptsreport.php 2016-11-30 14:25:30.975380100 +0100
+++ report/attemptsreport.php.orig 2016-11-30 14:24:11.090047900 +0100
@@ -153,12 +153,10 @@ abstract class quiz_attempts_report exte
$headers[] = ”;
}
if (!$table->is_downloading()) {
– $columns[] = ‘userid’;
+ $columns[] = ‘username’;
$headers[] = get_string(‘name’);
} else {
– $columns[] = ‘userid’;
+ $columns[] = ‘username’;
$headers[] = get_string(‘name’);
}
[/code] - report/attemptsreport_table.php UNIXTIMEで表示
[code]uep@ROBBY:/var/www/html/mod/quiz$ diff -up report/attemptsreport_table.php report/attemptsreport_table.php.orig
— report/attemptsreport_table.php 2016-11-30 14:39:19.292503500 +0100
+++ report/attemptsreport_table.php.orig 2016-11-30 14:37:17.118970800 +0100
@@ -163,8 +163,7 @@ abstract class quiz_attempts_report_tabl
*/
public function col_timestart($attempt) {
if ($attempt->attempt) {
– return $attempt->timestart;
+ return userdate($attempt->timestart, $this->strtimeformat);
} else {
return ‘-‘;
}
@@ -177,8 +176,7 @@ abstract class quiz_attempts_report_tabl
*/
public function col_timefinish($attempt) {
if ($attempt->attempt && $attempt->timefinish) {
– return $attempt->timefinish;
+ return userdate($attempt->timefinish, $this->strtimeformat);
} else {
return ‘-‘;
}
@@ -191,8 +189,7 @@ abstract class quiz_attempts_report_tabl
*/
public function col_duration($attempt) {
if ($attempt->timefinish) {
– return $attempt->timefinish – $attempt->timestart;
+ return format_time($attempt->timefinish – $attempt->timestart);
} else {
return ‘-‘;
}
[/code]