Skip to content

Commit

Permalink
Merge branch 'wip-MDL-54666-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
stronk7 committed May 21, 2016
2 parents 446e029 + 4ca17b6 commit cd1c8d2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/form/modgrade.php
Expand Up @@ -465,10 +465,12 @@ public function onQuickFormEvent($event, $arg, &$caller) {
'[modgrade_rescalegrades]', 'eq', '');

// A constant value should be given as an int.
// The default value should be an int and should really be $CFG->gradepointdefault.
// The default value should be an int and be either $CFG->gradepointdefault or whatever was set in set_data().
$value = $this->_findValue($caller->_constantValues);
if (null === $value) {
if ($caller->isSubmitted()) {
if ($caller->isSubmitted() && $this->_findValue($caller->_submitValues) !== null) {
// Submitted values are array, one value for each individual element in this group.
// When there is submitted data let parent::onQuickFormEvent() process it.
break;
}
$value = $this->_findValue($caller->_defaultValues);
Expand Down
61 changes: 60 additions & 1 deletion lib/form/tests/behat/modgrade_validation.feature
Expand Up @@ -65,7 +65,60 @@ Feature: Using the activity grade form element
And I should not see "You must choose whether to rescale existing grades or not"

@javascript
Scenario: Attempting to change the scale when grades already exist
Scenario: Attempting to change the scale when grades already exist in rating activity
Given I log in as "admin"
And I navigate to "Scales" node in "Site administration > Grades"
And I press "Add a new scale"
And I set the following fields to these values:
| Name | ABCDEF |
| Scale | F,E,D,C,B,A |
And I press "Save changes"
And I press "Add a new scale"
And I set the following fields to these values:
| Name | Letter scale |
| Scale | Disappointing, Good, Very good, Excellent |
And I press "Save changes"
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Forum" to section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
| Aggregate type | Average of ratings |
| scale[modgrade_type] | Scale |
| scale[modgrade_scale] | ABCDEF |
| Group mode | No groups |
And I log out
And I log in as "student1"
And I follow "Course 1"
And I follow "Test forum name"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Discussion subject |
| Message | Discussion message |
And I press "Post to forum"
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Test forum name"
And I follow "Discussion subject"
And I set the field "rating" to "D"
And I click on "Edit settings" "link" in the "Administration" "block"
When I expand all fieldsets
Then I should see "Some grades have already been awarded, so the grade type and scale cannot be changed"
# Try saving the form and visiting it back to verify that everything is working ok.
And I press "Save and display"
And I should not see "When selecting a ratings aggregate type you must also select"
And I click on "Edit settings" "link"
And I expand all fieldsets
And the field "Aggregate type" matches value "Average of ratings"
And the field "scale[modgrade_type]" matches value "Scale"
And the field "scale[modgrade_scale]" matches value "ABCDEF"

@javascript
Scenario: Attempting to change the scale when grades already exist in non-rating activity
Given I log in as "admin"
And I navigate to "Scales" node in "Site administration > Grades"
And I press "Add a new scale"
Expand Down Expand Up @@ -97,6 +150,12 @@ Feature: Using the activity grade form element
And I click on "Edit settings" "link"
When I expand all fieldsets
Then I should see "Some grades have already been awarded, so the grade type and scale cannot be changed"
# Try saving the form and visiting it back to verify everything is working ok.
And I press "Save and display"
And I click on "Edit settings" "link"
And I expand all fieldsets
And the field "grade[modgrade_type]" matches value "Scale"
And the field "grade[modgrade_scale]" matches value "ABCDEF"

Scenario: Attempting to change the maximum grade when ratings exist
Given I log in as "teacher1"
Expand Down

0 comments on commit cd1c8d2

Please sign in to comment.