Skip to content

Commit

Permalink
Merge branch 'MDL-74465-master-5' of https://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Mar 31, 2023
2 parents 5b8c1ff + 9788496 commit e541732
Show file tree
Hide file tree
Showing 54 changed files with 1,108 additions and 776 deletions.
9 changes: 9 additions & 0 deletions blocks/activity_results/edit_form.php
Expand Up @@ -124,4 +124,13 @@ protected function specific_definition($mform) {
$mform->freeze('config_decimalpoints');
}
}

/**
* Display the configuration form when block is being added to the page
*
* @return bool
*/
public static function display_form_when_adding(): bool {
return true;
}
}
41 changes: 18 additions & 23 deletions blocks/activity_results/tests/behat/addblockinactivity.feature
Expand Up @@ -47,42 +47,37 @@ Feature: The activity results block displays student scores

Scenario: Configure the block on a non-graded activity to show 3 high scores
Given I am on the "Test page name" "page activity" page
And I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
And I add the "Activity results" block to the default region with:
| config_activitygradeitemid | Test assignment 1 |
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"
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"

@javascript @addablocklink
Scenario: Block should select current activity by default
Given I am on the "Test assignment 1" "assign activity" page
When I add the "Activity results" block
And I configure the "Activity results" block
Then the field "config_activitygradeitemid" matches value "Test assignment 1"
And I press "Cancel"
Given I click on "Test assignment 1" "link" in the "region-main" "region"
When I add the "Activity results..." block
Then the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" matches value "Test assignment 1"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
And I am on "Course 1" course homepage
And I am on the "Test assignment 2" "assign activity" page
And I add the "Activity results" block
And I configure the "Activity results" block
And the field "config_activitygradeitemid" matches value "Test assignment 2"
And I press "Cancel"
And I click on "Test assignment 2" "link" in the "region-main" "region"
And I add the "Activity results..." block
And the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" matches value "Test assignment 2"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
And I am on "Course 1" course homepage
And I am on the "Test assignment 3" "assign activity" page
And I add the "Activity results" block
And I configure the "Activity results" block
And the field "config_activitygradeitemid" matches value "Test assignment 3"
And I press "Cancel"
And I click on "Test assignment 3" "link" in the "region-main" "region"
And I add the "Activity results..." block
And the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" matches value "Test assignment 3"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
And I am on "Course 1" course homepage
And I am on the "Test page name" "page activity" page
And I add the "Activity results" block
And I configure the "Activity results" block
And the field "config_activitygradeitemid" does not match value "Test page name"
And I click on "Test page name" "link" in the "region-main" "region"
And I add the "Activity results..." block
And the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" does not match value "Test page name"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
Expand Up @@ -17,10 +17,16 @@ Feature: The activity results block doesn't displays student scores for unconfig
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on

Scenario: Add the block to a the course
Scenario: Add the block to a the course with Javascript disabled
Given I add the "Activity results" block
Then I should see "Please configure this block and select which activity it should display results from." in the "Activity results" "block"

@javascript
Scenario: Add the block to a the course with Javascript enabled
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
Then I should see "Please configure this block and select which activity it should display results from." in the "Activity results" "block"

Scenario: Try to configure the block on the course page in a course without activities
Given I add the "Activity results" block
When I configure the "Activity results" block
Expand Down
Expand Up @@ -39,63 +39,48 @@ Feature: The activity results block displays student high scores
And I am on "Course 1" course homepage

Scenario: Configure the block on the course page to show 0 high scores
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "This block's configuration currently does not allow it to show any results." in the "Activity results" "block"

Scenario: Configure the block on the course page to show 1 high score
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90%" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show 1 high score as a fraction
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00/100.00" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show 1 high score as a absolute numbers
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores as percentages
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90%" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
Expand All @@ -104,14 +89,11 @@ Feature: The activity results block displays student high scores
And I should see "70%" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores as fractions
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00/100.00" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
Expand All @@ -120,14 +102,11 @@ Feature: The activity results block displays student high scores
And I should see "70.00/100.00" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores as absolute numbers
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
Expand All @@ -138,14 +117,11 @@ Feature: The activity results block displays student high scores
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
And I press "Save changes"
Then I should see "User S1" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
And I should see "User S2" in the "Activity results" "block"
Expand All @@ -154,14 +130,11 @@ Feature: The activity results block displays student high scores
And I should see "70.00%" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
And I press "Save changes"
Then I should see "User" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
And I should see "80.00%" in the "Activity results" "block"
Expand Down
20 changes: 4 additions & 16 deletions blocks/activity_results/tests/behat/highscoreswithscales.feature
Expand Up @@ -58,25 +58,19 @@ Feature: The activity results block displays students high scores in group as sc
And I am on "Course 1" course homepage with editing mode on

Scenario: Configure the block on the course page to show 1 high score
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores using full names
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display full names |
And I press "Save changes"
Then I should see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
Expand All @@ -87,13 +81,10 @@ Feature: The activity results block displays students high scores in group as sc
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display only ID numbers |
And I press "Save changes"
Then I should see "User S1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "User S2" in the "Activity results" "block"
Expand All @@ -102,13 +93,10 @@ Feature: The activity results block displays students high scores in group as sc
And I should see "Good" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Anonymous results |
And I press "Save changes"
Then I should see "User" in the "Activity results" "block"
And I should not see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
Expand Down
Expand Up @@ -44,6 +44,7 @@ Feature: The activity results block displays student in group high scores as sca
And the following "activities" exist:
| activity | name | intro | course | section | idnumber |
| assign | Test assignment | Offline text | C1 | 1 | assign1 |
And I change window size to "large"
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Scales" in the course gradebook
Expand Down Expand Up @@ -73,14 +74,11 @@ Feature: The activity results block displays student in group high scores as sca
And I am on "Course 1" course homepage

Scenario: Try to configure the block on the course page to show 1 high score
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_nameformat | Display full names |
| config_usegroups | Yes |
And I press "Save changes"
Then I should see "Group 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I log out
Expand All @@ -90,14 +88,11 @@ Feature: The activity results block displays student in group high scores as sca
And I should see "Excellent!" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores using full names
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display full names |
| config_usegroups | Yes |
And I press "Save changes"
Then I should see "Group 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
Expand All @@ -115,14 +110,11 @@ Feature: The activity results block displays student in group high scores as sca
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
And I press "Save changes"
Then I should see "Group" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
Expand All @@ -138,14 +130,11 @@ Feature: The activity results block displays student in group high scores as sca
And I should see "Very good" in the "Activity results" "block"

Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block
When I configure the "Activity results" block
And I set the following fields to these values:
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
And I press "Save changes"
Then I should see "Group" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
Expand Down

0 comments on commit e541732

Please sign in to comment.