PULL-99, MDL-25929 progresstrackedroles out. Fixed conflicts and whitespace

This commit is contained in:
Eloy Lafuente (stronk7)
2011-01-24 11:55:57 +01:00
9 changed files with 39 additions and 32 deletions
-4
View File
@@ -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));
+1 -1
View File
@@ -10,7 +10,7 @@
$completion = new completion_info($course);
if ($completion->is_enabled() && $completion->has_criteria()) {
echo '<p>';
echo '<a href="'.$CFG->wwwroot.'/course/report/completion/index.php?coursetest='.$course->id.'">'.get_string('coursecompletion').'</a>';
echo '<a href="'.$CFG->wwwroot.'/course/report/completion/index.php?course='.$course->id.'">'.get_string('coursecompletion').'</a>';
echo '</p>';
}
}
+14 -14
View File
@@ -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 '<p class="nousers">'.get_string('err_nousers','completion').'</p>';
echo '<p><a href="'.$CFG->wwwroot.'/course/report.php?id='.$course->id.'">'.get_string('continue').'</a></p>';
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)) {
+7 -1
View File
@@ -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.')
';
-2
View File
@@ -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';
+2 -2
View File
@@ -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 = '';
+3 -3
View File
@@ -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.
+11 -4
View File
@@ -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;
}
+1 -1
View File
@@ -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