From 71f15e84fef90d5feffa80d373cad2b75e95b3e4 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 11 Mar 2008 09:21:17 +0000 Subject: [PATCH] MDL-13885 fixed participation report problems; merged from MOODLE_19_STABLE --- course/report/participation/index.php | 29 +++++---- course/report/participation/mod.php | 90 ++------------------------- 2 files changed, 19 insertions(+), 100 deletions(-) diff --git a/course/report/participation/index.php b/course/report/participation/index.php index 1c3c669083..9e24ac23c5 100644 --- a/course/report/participation/index.php +++ b/course/report/participation/index.php @@ -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.'&roleid=' .$roleid.'&instanceid='.$instanceid.'&timefrom='.$timefrom.'&action='.$action.'&perpage='.$perpage; + 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); - // 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'); + include_once($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php'); - $viewfun = $cm->modname.'_get_view_actions'; - $postfun = $cm->modname.'_get_post_actions'; + $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); - } + if (!function_exists($viewfun) || !function_exists($postfun)) { + error(get_string('modulemissingcode','error',$cm->modname), $baseurl); + } - $viewnames = $viewfun(); - $postnames = $postfun(); + $viewnames = $viewfun(); + $postnames = $postfun(); - if (!empty($instanceid) && !empty($roleid)) { $table = new flexible_table('course-participation-'.$course->id.'-'.$cm->id.'-'.$roleid); $table->course = $course; diff --git a/course/report/participation/mod.php b/course/report/participation/mod.php index 04171c2692..22146808d0 100644 --- a/course/report/participation/mod.php +++ b/course/report/participation/mod.php @@ -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 '
'."\n". - ''."\n"; - echo ''; - choose_from_menu($modoptions,'moduleid',0); - echo ''; - choose_from_menu($timeoptions,'timefrom',0); - echo ''; - choose_from_menu($useroptions,'roleid',0,''); - echo ''; - choose_from_menu($actionoptions,'action',0,''); - helpbutton('participationreport',get_string('participationreport')); - echo ''."\n
\n"; - + echo '

'; + $participationreport = get_string('participationreport'); + echo "wwwroot}/course/report/participation/index.php?id={$course->id}\">"; + echo "$participationreport\n"; + echo '

'; ?> -- 2.39.5