Merge branch 'MDL-48452-master' of https://github.com/sammarshallou/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2014-12-16 19:21:40 +01:00
commit ccad9ddee6
2 changed files with 68 additions and 6 deletions

View File

@ -483,12 +483,17 @@ function update_moduleinfo($cm, $moduleinfo, $course, $mform = null) {
}
$completion = new completion_info($course);
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
// Update completion settings.
$cm->completion = $moduleinfo->completion;
$cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;
$cm->completionview = $moduleinfo->completionview;
$cm->completionexpected = $moduleinfo->completionexpected;
if ($completion->is_enabled()) {
// Completion settings that would affect users who have already completed
// the activity may be locked; if so, these should not be updated.
if (!empty($moduleinfo->completionunlocked)) {
$cm->completion = $moduleinfo->completion;
$cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;
$cm->completionview = $moduleinfo->completionview;
}
// The expected date does not affect users who have completed the activity,
// so it is safe to update it regardless of the lock status.
$cm->completionexpected = $moduleinfo->completionexpected;
}
if (!empty($CFG->enableavailability)) {
// This code is used both when submitting the form, which uses a long

View File

@ -0,0 +1,57 @@
@core @core_course
Feature: Edit completion settings of an activity
In order to edit completion settings without accidentally breaking user data
As a teacher
I need to edit the activity and use the unlock button if required
Background:
Given I log in as "admin"
And I set the following administration settings values:
| Enable completion tracking | 1 |
And I log out
And the following "courses" exist:
| fullname | shortname | enablecompletion |
| Course 1 | C1 | 1 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | content | completion | completionview |
| page | C1 | x | TestPage | x | x | 2 | 1 |
And I log in as "admin"
And I follow "Course 1"
Scenario: Completion is not locked when the activity has not yet been viewed
Given I turn editing mode on
And I click on "Edit settings" "link" in the "TestPage" activity
When I expand all fieldsets
Then I should see "Completion tracking"
And I should not see "Completion options locked"
Scenario: Completion is locked after the activity has been viewed
Given I follow "TestPage"
When I follow "Edit settings"
And I expand all fieldsets
Then I should see "Completion options locked"
@javascript
Scenario: Pressing the unlock button allows the user to edit completion settings
Given I follow "TestPage"
When I follow "Edit settings"
And I expand all fieldsets
And I press "Unlock completion options"
Then I should see "Completion options unlocked"
And I set the field "Completion tracking" to "Students can manually mark the activity as completed"
And I press "Save and display"
And I follow "Edit settings"
And I expand all fieldsets
Then the field "Completion tracking" matches value "Students can manually mark the activity as completed"
@javascript
Scenario: Even when completion is locked, the user can still set the date
Given I follow "TestPage"
And I follow "Edit settings"
And I expand all fieldsets
When I click on "id_completionexpected_enabled" "checkbox"
And I set the field "id_completionexpected_year" to "2013"
And I press "Save and display"
And I follow "Edit settings"
And I expand all fieldsets
Then the field "id_completionexpected_year" matches value "2013"