diff --git a/admin/settings/subsystems.php b/admin/settings/subsystems.php index ceccfe54692..c7735e6ec7f 100644 --- a/admin/settings/subsystems.php +++ b/admin/settings/subsystems.php @@ -37,10 +37,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $optionalsubsystems->add(new admin_setting_configcheckbox('enablecompletion', get_string('enablecompletion','completion'), get_string('configenablecompletion','completion'), 0)); - $optionalsubsystems->add(new admin_setting_pickroles('progresstrackedroles', - get_string('progresstrackedroles','completion'), - get_string('configprogresstrackedroles', 'completion'), - array('student'))); $optionalsubsystems->add(new admin_setting_configcheckbox('enableavailability', get_string('enableavailability','condition'), get_string('configenableavailability','condition'), 0)); diff --git a/course/report/completion/mod.php b/course/report/completion/mod.php index 38a1cfae001..44cca9a2b5a 100644 --- a/course/report/completion/mod.php +++ b/course/report/completion/mod.php @@ -10,7 +10,7 @@ $completion = new completion_info($course); if ($completion->is_enabled() && $completion->has_criteria()) { echo '
'; - echo ''.get_string('coursecompletion').''; + echo ''.get_string('coursecompletion').''; echo '
'; } } diff --git a/course/report/progress/index.php b/course/report/progress/index.php index c68c5718b24..d246139874c 100644 --- a/course/report/progress/index.php +++ b/course/report/progress/index.php @@ -72,9 +72,6 @@ if($group===0 && $course->groupmode==SEPARATEGROUPS) { $reportsurl=$CFG->wwwroot.'/course/report.php?id='.$course->id; $completion=new completion_info($course); $activities=$completion->get_activities(); -if(count($activities)==0) { - print_error('err_noactivities','completion',$reportsurl); -} // Generate where clause $where = array(); @@ -96,16 +93,6 @@ $total = $completion->get_num_tracked_users(implode(' AND ', $where), $where_par // Total user count $grandtotal = $completion->get_num_tracked_users('', array(), $group); -// If no users in this course what-so-ever -if (!$grandtotal) { - echo $OUTPUT->box_start('errorbox errorboxcontent boxaligncenter boxwidthnormal'); - echo ''.get_string('err_nousers','completion').'
'; - echo ''; - echo $OUTPUT->box_end(); - echo $OUTPUT->footer(); - exit; -} - // Get user data $progress = array(); @@ -120,7 +107,7 @@ if ($total) { ); } -if($csv) { +if($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are some users/actvs header('Content-Disposition: attachment; filename=progress.'. preg_replace('/[^a-z0-9-]/','_',strtolower($course->shortname)).'.csv'); // Unicode byte-order mark for Excel @@ -155,6 +142,19 @@ if($csv) { groups_print_course_menu($course,$CFG->wwwroot.'/course/report/progress/?course='.$course->id); } +if(count($activities)==0) { + echo $OUTPUT->container(get_string('err_noactivities', 'completion'), 'errorbox errorboxcontent'); + echo $OUTPUT->footer(); + exit; +} + +// If no users in this course what-so-ever +if (!$grandtotal) { + echo $OUTPUT->container(get_string('err_nousers', 'completion'), 'errorbox errorboxcontent'); + echo $OUTPUT->footer(); + exit; +} + // Build link for paging $link = $CFG->wwwroot.'/course/report/progress/?course='.$course->id; if (strlen($sort)) { diff --git a/course/user.php b/course/user.php index 15acd537080..c50dc40031b 100644 --- a/course/user.php +++ b/course/user.php @@ -369,11 +369,17 @@ switch ($mode) { INNER JOIN {role_assignments} ra ON ra.contextid = con.id + INNER JOIN + {enrol} e + ON c.id = e.courseid + INNER JOIN + {user_enrolments} ue + ON e.id = ue.enrolid AND ra.userid = ue.userid AND ra.userid = {$user->id} "; // Get roles that are tracked by course completion - if ($roles = $CFG->progresstrackedroles) { + if ($roles = $CFG->gradebookroles) { $sql .= ' AND ra.roleid IN ('.$roles.') '; diff --git a/lang/en/completion.php b/lang/en/completion.php index 0d8867562e7..00b6a9dc0a1 100644 --- a/lang/en/completion.php +++ b/lang/en/completion.php @@ -62,7 +62,6 @@ $string['completionusegrade_desc'] = 'Student must receive a grade to complete t $string['completionview'] = 'Require view'; $string['completionview_desc'] = 'Student must view this activity to complete it'; $string['configenablecompletion'] = 'When enabled, this lets you turn on completion tracking (progress) features at course level.'; -$string['configprogresstrackedroles'] = 'Roles that are displayed in the progress-tracking screen. (Usually includes just students and equivalent roles.)'; $string['csvdownload'] = 'Download in spreadsheet format (UTF-8 .csv)'; $string['deletecoursecompletiondata'] = 'Delete course completion data'; $string['enablecompletion'] = 'Enable completion tracking'; @@ -130,7 +129,6 @@ $string['pending']='Pending'; $string['periodpostenrolment']='Period post enrolment'; $string['prerequisites']='Prerequisites'; $string['prerequisitescompleted']='Prerequisites completed'; -$string['progresstrackedroles']='Progress-tracked roles'; $string['recognitionofpriorlearning']='Recognition of prior learning'; $string['remainingenroledfortime']='Remaining enrolled for a specified period of time'; $string['remainingenroleduntildate']='Remaining enrolled until a specified date'; diff --git a/lib/completion/cron.php b/lib/completion/cron.php index 0a5ee7fbb70..1c30809f220 100644 --- a/lib/completion/cron.php +++ b/lib/completion/cron.php @@ -57,8 +57,8 @@ function completion_cron_mark_started() { mtrace('Marking users as started'); } - if (!empty($CFG->progresstrackedroles)) { - $roles = ' AND ra.roleid IN ('.$CFG->progresstrackedroles.')'; + if (!empty($CFG->gradebookroles)) { + $roles = ' AND ra.roleid IN ('.$CFG->gradebookroles.')'; } else { // This causes it to default to everyone (if there is no student role) $roles = ''; diff --git a/lib/completionlib.php b/lib/completionlib.php index b020d329433..2dcf40fcbcd 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -1085,8 +1085,8 @@ class completion_info { $return->sql = ''; $return->data = array(); - if (!empty($CFG->progresstrackedroles)) { - $roles = ' AND ra.roleid IN ('.$CFG->progresstrackedroles.')'; + if (!empty($CFG->gradebookroles)) { + $roles = ' AND ra.roleid IN ('.$CFG->gradebookroles.')'; } else { // This causes it to default to everyone (if there is no student role) $roles = ''; @@ -1154,7 +1154,7 @@ class completion_info { * for all users in a specific group. Intended for use when displaying progress. * * This includes only users who, in course context, have one of the roles for - * which progress is tracked (the progresstrackedroles admin option). + * which progress is tracked (the gradebookroles admin option) and are enrolled in course. * * Users are included (in the first array) even if they do not have * completion progress for any course-module. diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 806b0ba668d..a537c42737b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -5793,8 +5793,8 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); // Check if we need to fix default grade if (array_key_exists('defaultgrade', $columns) && ( - empty($columns['defaultgrade']->unsigned) || - empty($columns['defaultgrade']->not_null) || + empty($columns['defaultgrade']->unsigned) || + empty($columns['defaultgrade']->not_null) || $columns['defaultgrade']->default_value !== '1.0000000')) { // defaultgrade should be unsigned NOT NULL DEFAULT '1.0000000' // Fixed in earlier upgrade code @@ -5945,10 +5945,10 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); $index = new xmldb_index('itemid', XMLDB_INDEX_NOTUNIQUE, array('itemid')); if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); - + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); $dbman->add_key($table, $key); - + $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); $dbman->add_key($table, $key); } @@ -5956,6 +5956,13 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint(true, 2011011415); } + if ($oldversion < 2011012400) { + // Clean up the old progress tracked roles setting, no longer used (replaced by enrolment) + unset_config('progresstrackedroles'); + + upgrade_main_savepoint(true, 2011012400); + } + return true; } diff --git a/version.php b/version.php index a4024e7a325..578760d90c1 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2011011900; // YYYYMMDD = date of the last version bump +$version = 2011012400; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0.1+ (Build: 20110119)'; // Human-friendly version name