mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-40241_master' of https://github.com/dmonllao/moodle
This commit is contained in:
commit
7b58b245bf
6 changed files with 82 additions and 12 deletions
|
@ -57,6 +57,8 @@ class block_completionstatus extends block_base {
|
||||||
|
|
||||||
// Create empty content.
|
// Create empty content.
|
||||||
$this->content = new stdClass();
|
$this->content = new stdClass();
|
||||||
|
$this->content->text = '';
|
||||||
|
$this->content->footer = '';
|
||||||
|
|
||||||
// Can edit settings?
|
// Can edit settings?
|
||||||
$can_edit = has_capability('moodle/course:update', $context);
|
$can_edit = has_capability('moodle/course:update', $context);
|
||||||
|
@ -67,13 +69,13 @@ class block_completionstatus extends block_base {
|
||||||
// Don't display if completion isn't enabled!
|
// Don't display if completion isn't enabled!
|
||||||
if (!completion_info::is_enabled_for_site()) {
|
if (!completion_info::is_enabled_for_site()) {
|
||||||
if ($can_edit) {
|
if ($can_edit) {
|
||||||
$this->content->text = get_string('completionnotenabledforsite', 'completion');
|
$this->content->text .= get_string('completionnotenabledforsite', 'completion');
|
||||||
}
|
}
|
||||||
return $this->content;
|
return $this->content;
|
||||||
|
|
||||||
} else if (!$info->is_enabled()) {
|
} else if (!$info->is_enabled()) {
|
||||||
if ($can_edit) {
|
if ($can_edit) {
|
||||||
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
|
$this->content->text .= get_string('completionnotenabledforcourse', 'completion');
|
||||||
}
|
}
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +86,7 @@ class block_completionstatus extends block_base {
|
||||||
// Check if this course has any criteria.
|
// Check if this course has any criteria.
|
||||||
if (empty($completions)) {
|
if (empty($completions)) {
|
||||||
if ($can_edit) {
|
if ($can_edit) {
|
||||||
$this->content->text = get_string('nocriteriaset', 'completion');
|
$this->content->text .= get_string('nocriteriaset', 'completion');
|
||||||
}
|
}
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
@ -230,11 +232,11 @@ class block_completionstatus extends block_base {
|
||||||
$rows = array_merge($rows, $srows);
|
$rows = array_merge($rows, $srows);
|
||||||
|
|
||||||
$table->data = $rows;
|
$table->data = $rows;
|
||||||
$this->content->text = html_writer::table($table);
|
$this->content->text .= html_writer::table($table);
|
||||||
|
|
||||||
// Display link to detailed view.
|
// Display link to detailed view.
|
||||||
$details = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id));
|
$details = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id));
|
||||||
$this->content->footer = html_writer::link($details, get_string('moredetails', 'completion'));
|
$this->content->footer .= html_writer::link($details, get_string('moredetails', 'completion'));
|
||||||
} else {
|
} else {
|
||||||
// If user is not enrolled, show error.
|
// If user is not enrolled, show error.
|
||||||
$this->content->text = get_string('nottracked', 'completion');
|
$this->content->text = get_string('nottracked', 'completion');
|
||||||
|
|
|
@ -105,4 +105,20 @@ class behat_completion extends behat_base {
|
||||||
return $steps;
|
return $steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles completion tracking for course being in the course page.
|
||||||
|
*
|
||||||
|
* @When /^completion tracking is "(?P<completion_status_string>Enabled|Disabled)" in current course$/
|
||||||
|
* @param string $completionstatus The status, enabled or disabled.
|
||||||
|
*/
|
||||||
|
public function completion_is_toggled_in_course($completionstatus) {
|
||||||
|
|
||||||
|
$toggle = strtolower($completionstatus) == 'enabled' ? get_string('yes') : get_string('no');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
new Given('I follow "'.get_string('editsettings').'"'),
|
||||||
|
new Given('I set the field "'.get_string('enablecompletion', 'completion').'" to "'.$toggle.'"'),
|
||||||
|
new Given('I press "'.get_string('savechanges').'"')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
45
completion/tests/behat/teacher_manual_completion.feature
Normal file
45
completion/tests/behat/teacher_manual_completion.feature
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
@core @core_completion
|
||||||
|
Feature: Allow teachers to manually mark users as complete when configured
|
||||||
|
In order for teachers to mark students as complete
|
||||||
|
As a teacher
|
||||||
|
I need to be able to use the completion report mark complete functionality
|
||||||
|
|
||||||
|
Scenario: Mark a student as complete using the completion report
|
||||||
|
Given the following "courses" exist:
|
||||||
|
| fullname | shortname | category |
|
||||||
|
| Completion course | CC1 | 0 |
|
||||||
|
And the following "users" exist:
|
||||||
|
| username | firstname | lastname | email |
|
||||||
|
| student1 | Student | First | student1@example.com |
|
||||||
|
| teacher1 | Teacher | First | teacher1@example.com |
|
||||||
|
And the following "course enrolments" exist:
|
||||||
|
| user | course | role |
|
||||||
|
| student1 | CC1 | student |
|
||||||
|
| teacher1 | CC1 | editingteacher |
|
||||||
|
And I log in as "admin"
|
||||||
|
And I set the following administration settings values:
|
||||||
|
| Enable completion tracking | 1 |
|
||||||
|
And I am on homepage
|
||||||
|
And I follow "Completion course"
|
||||||
|
And completion tracking is "Enabled" in current course
|
||||||
|
And I follow "Course completion"
|
||||||
|
And I set the field "Teacher" to "1"
|
||||||
|
And I press "Save changes"
|
||||||
|
And I turn editing mode on
|
||||||
|
And I add the "Course completion status" block
|
||||||
|
And I log out
|
||||||
|
And I log in as "student1"
|
||||||
|
And I follow "Completion course"
|
||||||
|
And I should see "Status: Not yet started"
|
||||||
|
And I log out
|
||||||
|
When I log in as "teacher1"
|
||||||
|
And I follow "Completion course"
|
||||||
|
And I follow "View course report"
|
||||||
|
And I should see "Student First"
|
||||||
|
And I follow "Click to mark user complete"
|
||||||
|
And I trigger cron
|
||||||
|
And I am on homepage
|
||||||
|
And I log out
|
||||||
|
Then I log in as "student1"
|
||||||
|
And I follow "Completion course"
|
||||||
|
And I should see "Status: Complete"
|
|
@ -19,6 +19,9 @@
|
||||||
* Toggles the manual completion flag for a particular activity or course completion
|
* Toggles the manual completion flag for a particular activity or course completion
|
||||||
* and the current user.
|
* and the current user.
|
||||||
*
|
*
|
||||||
|
* If by student params: course=2
|
||||||
|
* If by manager params: course=2&user=4&rolec=3&sesskey=ghfgsdf
|
||||||
|
*
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
* @package course
|
* @package course
|
||||||
*/
|
*/
|
||||||
|
@ -31,6 +34,10 @@ $cmid = optional_param('id', 0, PARAM_INT);
|
||||||
$courseid = optional_param('course', 0, PARAM_INT);
|
$courseid = optional_param('course', 0, PARAM_INT);
|
||||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||||
|
|
||||||
|
// Check if we are marking a user complete via the completion report.
|
||||||
|
$user = optional_param('user', 0, PARAM_INT);
|
||||||
|
$rolec = optional_param('rolec', 0, PARAM_INT);
|
||||||
|
|
||||||
if (!$cmid && !$courseid) {
|
if (!$cmid && !$courseid) {
|
||||||
print_error('invalidarguments');
|
print_error('invalidarguments');
|
||||||
}
|
}
|
||||||
|
@ -45,16 +52,14 @@ if ($courseid) {
|
||||||
require_login($course);
|
require_login($course);
|
||||||
|
|
||||||
$completion = new completion_info($course);
|
$completion = new completion_info($course);
|
||||||
|
$trackeduser = ($user ? $user : $USER->id);
|
||||||
|
|
||||||
if (!$completion->is_enabled()) {
|
if (!$completion->is_enabled()) {
|
||||||
throw new moodle_exception('completionnotenabled', 'completion');
|
throw new moodle_exception('completionnotenabled', 'completion');
|
||||||
} elseif (!$completion->is_tracked_user($USER->id)) {
|
} else if (!$completion->is_tracked_user($trackeduser)) {
|
||||||
throw new moodle_exception('nottracked', 'completion');
|
throw new moodle_exception('nottracked', 'completion');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we are marking a user complete via the completion report
|
|
||||||
$user = optional_param('user', 0, PARAM_INT);
|
|
||||||
$rolec = optional_param('rolec', 0, PARAM_INT);
|
|
||||||
|
|
||||||
if ($user && $rolec) {
|
if ($user && $rolec) {
|
||||||
require_sesskey();
|
require_sesskey();
|
||||||
|
|
||||||
|
|
|
@ -672,8 +672,9 @@ foreach ($progress as $user) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
print '<a href="'.$toggleurl->out().'"><img src="'.$OUTPUT->pix_url('i/completion-manual-'.($is_complete ? 'y' : 'n')).
|
print '<a href="'.$toggleurl->out().'" title="'.get_string('clicktomarkusercomplete', 'report_completion').'">' .
|
||||||
'" alt="'.$describe.'" class="icon" title="'.get_string('markcomplete', 'completion').'" /></a></td>';
|
'<img src="'.$OUTPUT->pix_url('i/completion-manual-'.($is_complete ? 'y' : 'n')).
|
||||||
|
'" alt="'.$describe.'" class="icon" /></a></td>';
|
||||||
} else {
|
} else {
|
||||||
print '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).'" alt="'.$describe.'" class="icon" title="'.$fulldescribe.'" /></td>';
|
print '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).'" alt="'.$describe.'" class="icon" title="'.$fulldescribe.'" /></td>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['clicktomarkusercomplete'] = 'Click to mark user complete';
|
||||||
$string['completion:view'] = 'View course completion report';
|
$string['completion:view'] = 'View course completion report';
|
||||||
$string['completiondate'] = 'Completion date';
|
$string['completiondate'] = 'Completion date';
|
||||||
$string['id'] = 'ID';
|
$string['id'] = 'ID';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue