Merge branch 'MDL-27367-HEAD' of git://github.com/srynot4sale/moodle

This commit is contained in:
Sam Hemelryk
2011-05-09 10:20:15 +08:00
6 changed files with 77 additions and 37 deletions
@@ -47,19 +47,34 @@ class block_completionstatus extends block_base {
// Create empty content
$this->content = new stdClass;
// Can edit settings?
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
// Get course completion data
$info = new completion_info($this->page->course);
// Don't display if completion isn't enabled!
if (!$this->page->course->enablecompletion) {
$this->content->text = get_string('completionnotenabled', 'block_completionstatus');
if (!completion_info::is_enabled_for_site()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforsite', 'completion');
}
return $this->content;
} else if (!$info->is_enabled()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
}
return $this->content;
}
// Load criteria to display
$info = new completion_info($this->page->course);
$completions = $info->get_completions($USER->id);
// Check if this course has any criteria
if (empty($completions)) {
$this->content->text = get_string('nocriteria', 'block_completionstatus');
if ($can_edit) {
$this->content->text = get_string('nocriteriaset', 'completion');
}
return $this->content;
}
+16 -11
View File
@@ -60,14 +60,11 @@ $can_view = false;
// Can view own report
if ($USER->id == $user->id) {
$can_view = true;
}
elseif (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
} else if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
$can_view = true;
}
elseif (has_capability('coursereport/completion:view', $coursecontext)) {
} else if (has_capability('coursereport/completion:view', $coursecontext)) {
$can_view = true;
}
elseif (has_capability('coursereport/completion:view', $personalcontext)) {
} else if (has_capability('coursereport/completion:view', $personalcontext)) {
$can_view = true;
}
@@ -76,23 +73,31 @@ if (!$can_view) {
}
// Load completion data
$info = new completion_info($course);
$returnurl = "{$CFG->wwwroot}/course/view.php?id={$id}";
// Don't display if completion isn't enabled!
if (!$course->enablecompletion) {
print_error('completionnotenabled', 'block_completionstatus');
if (!$info->is_enabled()) {
print_error('completionnotenabled', 'completion', $returnurl);
}
// Load criteria to display
$info = new completion_info($course);
$completions = $info->get_completions($user->id);
// Check if this course has any criteria
if (empty($completions)) {
print_error('nocriteria', 'block_completionstatus');
print_error('nocriteriaset', 'completion', $returnurl);
}
// Check this user is enroled
if (!$info->is_tracked_user($user->id)) {
print_error('notenroled', 'completion');
if ($USER->id == $user->id) {
print_error('notenroled', 'completion', $returnurl);
} else {
print_error('usernotenroled', 'completion', $returnurl);
}
}
@@ -1,9 +1,7 @@
<?php
$string['completionnotenabled'] = 'Course completion is not enabled';
$string['completionprogressdetails'] = 'Completion progress details';
$string['completionstatus'] = 'Course completion status';
$string['criteriagroup'] = 'Criteria group';
$string['nocriteria'] = 'No criteria have been set for this course';
$string['pluginname'] = 'Course completion status';
$string['requirement'] = 'Requirement';
+32 -16
View File
@@ -40,36 +40,44 @@ class block_selfcompletion extends block_base {
}
public function get_content() {
global $USER;
global $CFG, $USER;
// If content is cached
if ($this->content !== NULL) {
return $this->content;
}
global $CFG;
// Create empty content
$this->content = new stdClass;
// Don't display if completion isn't enabled!
if (!$this->page->course->enablecompletion) {
$this->content->text = get_string('completionnotenabled', 'block_selfcompletion');
return $this->content;
}
// Can edit settings?
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
// Get course completion data
$info = new completion_info($this->page->course);
$completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
// Is course complete?
if ($info->is_course_complete($USER->id)) {
// Don't display if completion isn't enabled!
if (!completion_info::is_enabled_for_site()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforsite', 'completion');
}
return $this->content;
} else if (!$info->is_enabled()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
}
return $this->content;
}
// Get this user's data
$completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
// Check if self completion is one of this course's criteria
if (empty($completion)) {
$this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
if ($can_edit) {
$this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
}
return $this->content;
}
@@ -79,13 +87,21 @@ class block_selfcompletion extends block_base {
return $this->content;
}
// Check if the user has already marked themselves as complete
if ($completion->is_complete()) {
// Is course complete?
if ($info->is_course_complete($USER->id)) {
$this->content->text = get_string('coursealreadycompleted', 'completion');
return $this->content;
// Check if the user has already marked themselves as complete
} else if ($completion->is_complete()) {
$this->content->text = get_string('alreadyselfcompleted', 'block_selfcompletion');
return $this->content;
// If user is not complete, or has not yet self completed
} else {
$this->content->text = '';
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/course/togglecompletion.php?course='.$this->page->course->id.'">'.
get_string('completecourse', 'block_selfcompletion').'</a>...';
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/course/togglecompletion.php?course='.$this->page->course->id.'">';
$this->content->footer .= get_string('completecourse', 'block_selfcompletion').'</a>...';
}
return $this->content;
@@ -23,8 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['selfcompletion'] = 'Self completion';
$string['pluginname'] = 'Self completion';
$string['alreadyselfcompleted'] = 'You have already marked yourself as complete in this course';
$string['completecourse'] = 'Complete course';
$string['completionnotenabled'] = 'Course completion is not enabled';
$string['pluginname'] = 'Self completion';
$string['selfcompletion'] = 'Self completion';
$string['selfcompletionnotenabled'] = 'The self completion criteria has not been enabled for this course';
+7 -1
View File
@@ -56,6 +56,9 @@ $string['completion_manual'] = 'Students can manually mark the activity as compl
$string['completion_none'] = 'Do not indicate activity completion';
$string['completion-title-manual-n'] = 'Mark as complete';
$string['completion-title-manual-y'] = 'Mark as not complete';
$string['completionnotenabled'] = 'Completion is not enabled';
$string['completionnotenabledforcourse'] = 'Completion is not enabled for this course';
$string['completionnotenabledforsite'] = 'Completion is not enabled for this site';
$string['completionusegrade'] = 'Require grade';
$string['completionusegrade_help'] = 'If enabled, the activity is considered complete when a student receives a grade. Pass and fail icons may be displayed if a pass grade for the activity has been set.';
$string['completionusegrade_desc'] = 'Student must receive a grade to complete this activity';
@@ -93,6 +96,7 @@ $string['completionsettingslocked']='Completion settings locked';
$string['completionstartonenrol']='Completion tracking begins on enrolment';
$string['completionstartonenrolhelp']='Begin tracking a student\'s progress in course completion after course enrolment';
$string['confirmselfcompletion']='Confirm self completion';
$string['coursealreadycompleted']='You have already completed this course';
$string['coursecomplete']='Course complete';
$string['coursecompleted']='Course completed';
$string['coursegrade']='Course grade';
@@ -121,7 +125,8 @@ $string['markcomplete']='Mark complete';
$string['markedcompleteby']='Marked complete by {$a}';
$string['markingyourselfcomplete']='Marking yourself complete';
$string['moredetails']='More details';
$string['notenroled']='You are not enroled as a student in this course';
$string['nocriteriaset']='No completion criteria set for this course';
$string['notenroled']='You are not enroled in this course';
$string['notyetstarted']='Not yet started';
$string['overallcriteriaaggregation']='Overall criteria type aggregation';
$string['passinggrade']='Passing grade';
@@ -142,6 +147,7 @@ $string['unenrolingfromcourse']='Unenroling from course';
$string['unenrolment']='Unenrolment';
$string['unlockcompletiondelete']='Unlock completion options and delete user completion data';
$string['usealternateselector']='Use the alternate course selector';
$string['usernotenroled']='User is not enroled in this course';
$string['viewcoursereport']='View course report';
$string['viewingactivity']='Viewing the {$a}';
$string['xdays']='{$a} days';