adding some strings
[moodle-linuxchix.git] / course / report / participation / mod.php
blob04171c269225401db494dbd6fadff8240ebcc844
1 <?php // $Id$
3 if (!defined('MOODLE_INTERNAL')) {
4 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
7 $strparticipation = get_string('participationreport');
8 $strviews = get_string('views');
9 $strposts = get_string('posts');
10 $strview = get_string('view');
11 $strpost = get_string('post');
12 $strallactions = get_string('allactions');
16 $allowedmodules = array('assignment','book','chat','choice','exercise','forum','glossary','hotpot',
17 'journal','lesson','questionnaire','quiz','resource','scorm',
18 'survey','wiki','workshop'); // some don't make sense here - eg 'label'
20 if (!$modules = get_records_sql('SELECT DISTINCT module,name FROM '.$CFG->prefix.'course_modules cm JOIN '.
21 $CFG->prefix.'modules m ON cm.module = m.id WHERE course = '.$course->id)) {
22 print_error('noparticipatorycms','', $CFG->wwwroot.'/course/view.php?id='.$course->id);
26 $modoptions = array();
27 foreach ($modules as $m) {
28 if (in_array($m->name,$allowedmodules)) {
29 $modoptions[$m->module] = get_string('modulename',$m->name);
33 $timeoptions = array();
34 // get minimum log time for this course
35 $minlog = get_field_sql('SELECT min(time) FROM '.$CFG->prefix.'log WHERE course = '.$course->id);
37 $now = usergetmidnight(time());
39 // days
40 for ($i = 1; $i < 7; $i++) {
41 if (strtotime('-'.$i.' days',$now) >= $minlog) {
42 $timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
45 // weeks
46 for ($i = 1; $i < 10; $i++) {
47 if (strtotime('-'.$i.' weeks',$now) >= $minlog) {
48 $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
51 // months
52 for ($i = 2; $i < 12; $i++) {
53 if (strtotime('-'.$i.' months',$now) >= $minlog) {
54 $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
57 // try a year
58 if (strtotime('-1 year',$now) >= $minlog) {
59 $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
62 $useroptions = array();
63 if ($roles = get_roles_on_exact_context(get_context_instance(CONTEXT_COURSE,$course->id))) {
64 foreach ($roles as $role) {
65 $useroptions[$role->id] = $role->name;
68 $guestrole = get_guest_role();
69 if (empty($useroptions[$guestrole->id])) {
70 $useroptions[$guestrole->id] = $guestrole->name;
72 $actionoptions = array('' => $strallactions,
73 'view' => $strview,
74 'post' => $strpost,
78 // print first controls.
79 echo '<form class="participationselectform" action="'.$CFG->wwwroot.'/course/report/participation/index.php" method="get"><div>'."\n".
80 '<input type="hidden" name="id" value="'.$course->id.'" />'."\n";
81 echo '<label for="menumoduleid">'.get_string('activitymodule').'</label>';
82 choose_from_menu($modoptions,'moduleid',0);
83 echo '<label for="menutimefrom">'.get_string('lookback').'</label>';
84 choose_from_menu($timeoptions,'timefrom',0);
85 echo '<label for="menuroleid">'.get_string('showonly').'</label>';
86 choose_from_menu($useroptions,'roleid',0,'');
87 echo '<label for="menuaction">'.get_string('showactions').'</label>';
88 choose_from_menu($actionoptions,'action',0,'');
89 helpbutton('participationreport',get_string('participationreport'));
90 echo '<input type="submit" value="'.get_string('go').'" />'."\n</div></form>\n";