
構想から1年半、ようやくできた。今どきではあるがSCORMで教材を提供している場合、それなりのトラッキング情報が得られる。しかしながら、MoodleのSCORMモジュールのレポート機能は解析を目的としたデータを出力することを目的とはしていないため、データクレンジングが必要となる。このカスタマイズで多くを学ぶことができ本当に楽しい。
mod/scorm/report/interactions/report.php
- ユーザ名を内部IDにする
[code]421c421
< $row[] = ‘<a href="’.$CFG->wwwroot.’/user/view.php?id=’.$scouser->userid.’&course=’.$course->id.’">’.$scouser->userid.'</a>’;
—
> $row[] = ‘<a href="’.$CFG->wwwroot.’/user/view.php?id=’.$scouser->userid.’&course=’.$course->id.’">’.$scouser->username.'</a>’;
423c423
< $row[] = $scouser->userid;
—
> $row[] = $scouser->username;[/code] - UnixTimeにする
[code]440c440
< $row[] = $timetracks->start;
—
> $row[] = userdate($timetracks->start);
445c445
< $row[] = $timetracks->finish;
—
> $row[] = userdate($timetracks->finish);
[/code] - トラッキング詳細の「total_time」を単位なしで秒単位で表示(関数formatDurationは別ファイルlocallib.php)
[code]471c471
< ‘&amp;attempt=’.$scouser->attempt.’" title="’.get_string(‘details’, ‘scorm’).’">’. formatDuration($trackdata->total_time).’</a>’;
—
> ‘&amp;attempt=’.$scouser->attempt.’" title="’.get_string(‘details’, ‘scorm’).’">’.$score.’</a>’;
473c473
< $row[] = formatDuration($trackdata->total_time);
—
> $row[] = $score;
[/code] - 不要な空白セルを出力しないようにする(環境依存かもしれない)
[code]
482c482
< //$row[] = ‘&nbsp;’;
—
> $row[] = ‘&nbsp;’;
490c490
< //$row[] = ‘&nbsp;’;
—
> $row[] = ‘&nbsp;’;
508c508
< //$row[] = ‘&nbsp;’;
—
> $row[] = ‘&nbsp;’;
[/code] - 「完了」「未受験」などを表示しないようにする
[code]515,516c515
< //$strstatus = get_string(‘notattempted’, ‘scorm’);
< $strstatus = ”;
—
> $strstatus = get_string(‘notattempted’, ‘scorm’);
524c523
< //$row[] = ‘&nbsp;’;
—
> $row[] = ‘&nbsp;’;
[/code]
mod/scorm/report/locallib.php
[code]
< // http://stackoverflow.com/questions/18128145/how-to-convert-scorm-2004-session-time-format-to-a-usable-datetime-format-in-sql
< //
< function formatDuration($duration)
< {
< $count = preg_match(‘/P(([0-9]+)Y)?(([0-9]+)M)?(([0-9]+)D)?T?(([0-9]+)H)?(([0-9]+)M)?(([0-9]+)(\.[0-9]+)?S)?/’, $duration, $matches);
<
< if ($count)
< {
< $_years = (int) $matches[2];
< $_months = (int) $matches[4];
< $_days = (int) $matches[6];
< $_hours = (int) $matches[8];
< $_minutes = (int) $matches[10];
< $_seconds = (int) $matches[12];
< }
< else
< {
< if (strstr($duration, ‘:’))
< {
< list($_hours, $_minutes, $_seconds) = explode(‘:’, $duration);
< }
< else
< {
< $_hours = 0;
< $_minutes = 0;
< $_seconds = 0;
< }
< }
<
< // I just ignore years, months and days as it is unlikely that a
< // course would take any longer than 1 hour
< return $_seconds + (($_minutes + ($_hours * 60)) * 60);
< }
[/code]

https://github.com/uedahiro4/moodle-analytics
へ移行