// default to all (don't restrict) } if (!($course = $DB->get_record('course', array('id' => $id)))) { print_error('invalidcourse'); } if ($roleid != 0 and !($role = $DB->get_record('role', array('id' => $roleid)))) { print_error('invalidrole'); } require_login($course); $context = context_course::instance($course->id); require_capability('report/participation:view', $context); $strparticipation = get_string('participationreport'); $strviews = get_string('views'); $strposts = get_string('posts'); $strreports = get_string('reports'); $actionoptions = report_participation_get_action_options(); if (!array_key_exists($action, $actionoptions)) { $action = ''; } $PAGE->set_title($course->shortname . ': ' . $strparticipation); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); $uselegacyreader = false; // Use legacy reader with sql_internal_reader to aggregate records. $onlyuselegacyreader = false; // Use only legacy log table to aggregate records. $logtable = report_participation_get_log_table_name(); // Log table to use for fetaching records. // If no log table, then use legacy records. if (empty($logtable)) { $onlyuselegacyreader = true;
/** * Print filter form. * * @param stdClass $course course object. * @param int $timefrom Time from which records should be fetched. * @param int $minlog Time of first record present in log store. * @param string $action action to be filtered. * @param int $roleid Role to be filtered. * @param int $instanceid Instance id of module. */ function report_participation_print_filter_form($course, $timefrom, $minlog, $action, $roleid, $instanceid) { global $DB; $timeoptions = report_participation_get_time_options($minlog); $actionoptions = report_participation_get_action_options(); // TODO: we need a new list of roles that are visible here. $context = context_course::instance($course->id); $roles = get_roles_used_in_context($context); $guestrole = get_guest_role(); $roles[$guestrole->id] = $guestrole; $roleoptions = role_fix_names($roles, $context, ROLENAME_ALIAS, true); $modinfo = get_fast_modinfo($course); $modules = $DB->get_records_select('modules', "visible = 1", null, 'name ASC'); $instanceoptions = array(); foreach ($modules as $module) { if (empty($modinfo->instances[$module->name])) { continue; } $instances = array(); foreach ($modinfo->instances[$module->name] as $cm) { // Skip modules such as label which do not actually have links; // this means there's nothing to participate in. if (!$cm->has_view()) { continue; } $instances[$cm->id] = format_string($cm->name); } if (count($instances) == 0) { continue; } $instanceoptions[] = array(get_string('modulenameplural', $module->name) => $instances); } echo '<form class="participationselectform" action="index.php" method="get"><div>' . "\n" . '<input type="hidden" name="id" value="' . $course->id . '" />' . "\n"; echo '<label for="menuinstanceid">' . get_string('activitymodule') . '</label>' . "\n"; echo html_writer::select($instanceoptions, 'instanceid', $instanceid); echo '<label for="menutimefrom">' . get_string('lookback') . '</label>' . "\n"; echo html_writer::select($timeoptions, 'timefrom', $timefrom); echo '<label for="menuroleid">' . get_string('showonly') . '</label>' . "\n"; echo html_writer::select($roleoptions, 'roleid', $roleid, false); echo '<label for="menuaction">' . get_string('showactions') . '</label>' . "\n"; echo html_writer::select($actionoptions, 'action', $action, false); echo '<input type="submit" value="' . get_string('go') . '" />' . "\n</div></form>\n"; }