diff --git a/blocks/activity_results/block_activity_results.php b/blocks/activity_results/block_activity_results.php index 90cbf5f85da..796304e86ad 100644 --- a/blocks/activity_results/block_activity_results.php +++ b/blocks/activity_results/block_activity_results.php @@ -92,7 +92,7 @@ class block_activity_results extends block_base { return $result; } // See if it is a gradable activity. - if (($rec->gradetype != GRADE_TYPE_VALUE) || ($rec->gradetype != GRADE_TYPE_SCALE)) { + if (($rec->gradetype != GRADE_TYPE_VALUE) && ($rec->gradetype != GRADE_TYPE_SCALE)) { return $result; } return $rec; diff --git a/blocks/activity_results/tests/behat/addblockinactivity.feature b/blocks/activity_results/tests/behat/addblockinactivity.feature index d55ae9aed59..1f444c88533 100644 --- a/blocks/activity_results/tests/behat/addblockinactivity.feature +++ b/blocks/activity_results/tests/behat/addblockinactivity.feature @@ -28,31 +28,44 @@ Feature: The activity results block displays student scores And I follow "Course 1" And I turn editing mode on And I add a "Assignment" to section "1" and I fill the form with: - | Assignment name | Test assignment | + | Assignment name | Test assignment 1 | | Description | Offline text | | assignsubmission_file_enabled | 0 | And I follow "Course 1" + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test assignment 2 | + | Description | Offline text | + | assignsubmission_file_enabled | 0 | + And I follow "Course 1" + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test assignment 3 | + | Description | Offline text | + | assignsubmission_file_enabled | 0 | + And I follow "Course 1" + And I add a "Page" to section "1" + And I set the following fields to these values: + | Name | Test page name | + | Description | Test page description | + | Page content | This is a page | + And I press "Save and return to course" + And I follow "Course 1" + And I should see "Test page name" And I navigate to "Grades" node in "Course administration" And I turn editing mode on - And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment" - And I give the grade "80.00" to the user "Student 2" for the grade item "Test assignment" - And I give the grade "70.00" to the user "Student 3" for the grade item "Test assignment" - And I give the grade "60.00" to the user "Student 4" for the grade item "Test assignment" - And I give the grade "50.00" to the user "Student 5" for the grade item "Test assignment" + And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment 1" + And I give the grade "80.00" to the user "Student 2" for the grade item "Test assignment 1" + And I give the grade "70.00" to the user "Student 3" for the grade item "Test assignment 1" + And I give the grade "60.00" to the user "Student 4" for the grade item "Test assignment 1" + And I give the grade "50.00" to the user "Student 5" for the grade item "Test assignment 1" And I press "Save changes" And I follow "Course 1" Scenario: Configure the block on a non-graded activity to show 3 high scores - Given I add a "Page" to section "1" + Given I follow "Test page name" + And I add the "Activity results" block + When I configure the "Activity results" block And I set the following fields to these values: - | Name | Test page name | - | Description | Test page description | - | page | This is a page | - And I press "Save and display" - When I add the "Activity results" block - And I configure the "Activity results" block - And I set the following fields to these values: - | id_config_activitygradeitemid | Test assignment | + | id_config_activitygradeitemid | Test assignment 1 | | id_config_showbest | 3 | | id_config_showworst | 0 | | id_config_gradeformat | Absolute numbers | @@ -63,4 +76,25 @@ Scenario: Configure the block on a non-graded activity to show 3 high scores And I should see "Student 2" in the "Activity results" "block" And I should see "80.00" in the "Activity results" "block" And I should see "Student 3" in the "Activity results" "block" - And I should see "70.00" in the "Activity results" "block" \ No newline at end of file + And I should see "70.00" in the "Activity results" "block" + +Scenario: Block should select current activity by default + Given I follow "Test assignment 1" + When I add the "Activity results" block + And I configure the "Activity results" block + Then the field "id_config_activitygradeitemid" matches value "Test assignment 1" + And I follow "Course 1" + And I follow "Test assignment 2" + And I add the "Activity results" block + And I configure the "Activity results" block + And the field "id_config_activitygradeitemid" matches value "Test assignment 2" + And I follow "Course 1" + And I follow "Test assignment 3" + And I add the "Activity results" block + And I configure the "Activity results" block + And the field "id_config_activitygradeitemid" matches value "Test assignment 3" + And I follow "Course 1" + And I follow "Test page name" + And I add the "Activity results" block + And I configure the "Activity results" block + And the field "id_config_activitygradeitemid" does not match value "Test page name"