MDL-13885 fixed participation report problems; merged from MOODLE_19_STABLE

This commit is contained in:
skodak 2008-03-11 09:21:17 +00:00
parent 0a2925beb9
commit 71f15e84fe
2 changed files with 23 additions and 104 deletions

View File

@ -55,7 +55,7 @@
$modinfo = get_fast_modinfo($course);
$modules = get_records_select('modules', "visible = 1 AND name <> 'label'", 'name ASC');
$modules = get_records_select('modules', "visible = 1 AND name <> 'label'", 'name ASC');
$instanceoptions = array();
foreach ($modules as $module) {
@ -65,7 +65,7 @@
$agroup = get_string('modulenameplural', $module->name);
$instanceoptions[$agroup] = array();
foreach ($modinfo->instances[$module->name] as $cm) {
$instanceoptions[$agroup][$cm->id] = format_string($cm->name);
$instanceoptions[$agroup][$cm->id] = format_string($cm->name);
}
}
@ -128,24 +128,23 @@
$baseurl = $CFG->wwwroot.'/course/report/participation/index.php?id='.$course->id.'&amp;roleid='
.$roleid.'&amp;instanceid='.$instanceid.'&amp;timefrom='.$timefrom.'&amp;action='.$action.'&amp;perpage='.$perpage;
// from here assume we have at least the module we're using.
$cm = $modinfo->cms[$instanceid];
$modulename = get_string('modulename', $cm->modname);
include_once($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php');
$viewfun = $cm->modname.'_get_view_actions';
$postfun = $cm->modname.'_get_post_actions';
if (!function_exists($viewfun) || !function_exists($postfun)) {
error(get_string('modulemissingcode','error',$cm->modname), $baseurl);
}
$viewnames = $viewfun();
$postnames = $postfun();
if (!empty($instanceid) && !empty($roleid)) {
// from here assume we have at least the module we're using.
$cm = $modinfo->cms[$instanceid];
$modulename = get_string('modulename', $cm->modname);
include_once($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php');
$viewfun = $cm->modname.'_get_view_actions';
$postfun = $cm->modname.'_get_post_actions';
if (!function_exists($viewfun) || !function_exists($postfun)) {
error(get_string('modulemissingcode','error',$cm->modname), $baseurl);
}
$viewnames = $viewfun();
$postnames = $postfun();
$table = new flexible_table('course-participation-'.$course->id.'-'.$cm->id.'-'.$roleid);
$table->course = $course;

View File

@ -4,90 +4,10 @@
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
$strparticipation = get_string('participationreport');
$strviews = get_string('views');
$strposts = get_string('posts');
$strview = get_string('view');
$strpost = get_string('post');
$strallactions = get_string('allactions');
$allowedmodules = array('assignment','book','chat','choice','exercise','forum','glossary','hotpot',
'journal','lesson','questionnaire','quiz','resource','scorm',
'survey','wiki','workshop'); // some don't make sense here - eg 'label'
if (!$modules = get_records_sql('SELECT DISTINCT module,name FROM '.$CFG->prefix.'course_modules cm JOIN '.
$CFG->prefix.'modules m ON cm.module = m.id WHERE course = '.$course->id)) {
print_error('noparticipatorycms','', $CFG->wwwroot.'/course/view.php?id='.$course->id);
}
$modoptions = array();
foreach ($modules as $m) {
if (in_array($m->name,$allowedmodules)) {
$modoptions[$m->module] = get_string('modulename',$m->name);
}
}
$timeoptions = array();
// get minimum log time for this course
$minlog = get_field_sql('SELECT min(time) FROM '.$CFG->prefix.'log WHERE course = '.$course->id);
$now = usergetmidnight(time());
// days
for ($i = 1; $i < 7; $i++) {
if (strtotime('-'.$i.' days',$now) >= $minlog) {
$timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
}
}
// weeks
for ($i = 1; $i < 10; $i++) {
if (strtotime('-'.$i.' weeks',$now) >= $minlog) {
$timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
}
}
// months
for ($i = 2; $i < 12; $i++) {
if (strtotime('-'.$i.' months',$now) >= $minlog) {
$timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
}
}
// try a year
if (strtotime('-1 year',$now) >= $minlog) {
$timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
}
$useroptions = array();
if ($roles = get_roles_on_exact_context(get_context_instance(CONTEXT_COURSE,$course->id))) {
foreach ($roles as $role) {
$useroptions[$role->id] = $role->name;
}
}
$guestrole = get_guest_role();
if (empty($useroptions[$guestrole->id])) {
$useroptions[$guestrole->id] = $guestrole->name;
}
$actionoptions = array('' => $strallactions,
'view' => $strview,
'post' => $strpost,
);
// print first controls.
echo '<form class="participationselectform" action="'.$CFG->wwwroot.'/course/report/participation/index.php" method="get"><div>'."\n".
'<input type="hidden" name="id" value="'.$course->id.'" />'."\n";
echo '<label for="menumoduleid">'.get_string('activitymodule').'</label>';
choose_from_menu($modoptions,'moduleid',0);
echo '<label for="menutimefrom">'.get_string('lookback').'</label>';
choose_from_menu($timeoptions,'timefrom',0);
echo '<label for="menuroleid">'.get_string('showonly').'</label>';
choose_from_menu($useroptions,'roleid',0,'');
echo '<label for="menuaction">'.get_string('showactions').'</label>';
choose_from_menu($actionoptions,'action',0,'');
helpbutton('participationreport',get_string('participationreport'));
echo '<input type="submit" value="'.get_string('go').'" />'."\n</div></form>\n";
echo '<p>';
$participationreport = get_string('participationreport');
echo "<a href=\"{$CFG->wwwroot}/course/report/participation/index.php?id={$course->id}\">";
echo "$participationreport</a>\n";
echo '</p>';
?>