From ba9af1f476dd10da456b301c4eaba67e91621cf5 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 22 Oct 2013 12:09:43 +0800 Subject: [PATCH] MDL-42283 Behat: Automated MDLQA-1777 MDLQA-1777: A teacher can set grade conditions to restrict availability of a section --- .../restrict_section_availability.feature | 60 ++++++++++++++++--- course/tests/behat/behat_course.php | 27 +++++++++ 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/completion/tests/behat/restrict_section_availability.feature b/completion/tests/behat/restrict_section_availability.feature index 35b7f0902e7..03505dc66ea 100644 --- a/completion/tests/behat/restrict_section_availability.feature +++ b/completion/tests/behat/restrict_section_availability.feature @@ -1,11 +1,10 @@ @core @core_completion -Feature: Restrict sections availability through completion conditions - In order to control section's contents access through activities completion +Feature: Restrict sections availability through completion or grade conditions + In order to control section's contents access through activities completion or grade condition As a teacher I need to restrict sections availability using different conditions - @javascript - Scenario: Show section greyed-out to students when completion conditions are not satisfied + Background: Given the following "courses" exists: | fullname | shortname | category | | Course 1 | C1 | 0 | @@ -22,7 +21,10 @@ Feature: Restrict sections availability through completion conditions | Enable completion tracking | 1 | | Enable conditional access | 1 | And I log out - And I log in as "teacher1" + + @javascript + Scenario: Show section greyed-out to student when completion condition is not satisfied + Given I log in as "teacher1" And I follow "Course 1" And I turn editing mode on And I follow "Edit settings" @@ -36,12 +38,10 @@ Feature: Restrict sections availability through completion conditions | Name | Test page name | | Description | Test page description | | Page content | Test page contents | - When I click on "Edit summary" "link" in the "#section-2" "css_element" - And I fill the moodle form with: + When I edit the section "2" and I fill the form with: | id_conditioncompletiongroup_0_conditionsourcecmid | Test label | | id_conditioncompletiongroup_0_conditionrequiredcompletion | must be marked complete | | Before section can be accessed | Show section greyed-out, with restriction information | - And I press "Save changes" And I log out And I log in as "student1" And I follow "Course 1" @@ -50,3 +50,47 @@ Feature: Restrict sections availability through completion conditions And I press "Not completed: Test label. Select to mark as complete." And I should see "Test page name" And I should not see "Not available until the activity Test label is marked complete." + + @javascript + Scenario: Show section greyed-out to student when grade condition is not satisfied + Given I log in as "teacher1" + 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 | Grade assignment | + | Description | Grade this assignment to revoke restriction on restricted assignment | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 0 | + And I add a "Page" to section "2" and I fill the form with: + | Name | Test page name | + | Description | Restricted section page resource, till grades in Grade assignment is at least 20% | + | Page content | Test page contents | + And I edit the section "2" and I fill the form with: + | id_conditiongradegroup_0_conditiongradeitemid | 2 | + | id_conditiongradegroup_0_conditiongrademin | 20 | + | Before section can be accessed | 1 | + And I log out + When I log in as "student1" + And I follow "Course 1" + Then I should see "Not available until you achieve a required score in Grade assignment" + And "Test page name" activity should be hidden + And I follow "Grade assignment" + And I press "Add submission" + And I fill the moodle form with: + | Online text | I'm the student submission | + And I press "Save changes" + And I should see "Submitted for grading" + And I log out + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Grade assignment" + And I follow "View/grade all submissions" + And I click on "Grade Student First" "link" in the "Student First" "table_row" + And I fill the moodle form with: + | Grade | 21 | + And I press "Save changes" + And I log out + And I log in as "student1" + And I follow "Course 1" + And "Test page name" activity should be visible + And I should not see "Not available until you achieve a required score in Grade assignment" \ No newline at end of file diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 49145f29859..e4cfa09aaca 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -218,6 +218,33 @@ class behat_course extends behat_base { } } + /** + * Go to editing section page for specified section number. You need to be in the course page and on editing mode. + * + * @Given /^I edit the section "(?P\d+)"$/ + * @param int $sectionnumber + */ + public function i_edit_the_section($sectionnumber) { + return new Given('I click on "' . get_string('editsummary') . '" "link" in the "#section-' . $sectionnumber . '" "css_element"'); + } + + /** + * Edit specified section and fill the form data with the specified field/value pairs. + * + * @When /^I edit the section "(?P\d+)" and I fill the form with:$/ + * @param int $sectionnumber The section number + * @param TableNode $data The activity field/value data + * @return Given[] + */ + public function i_edit_the_section_and_i_fill_the_form_with($sectionnumber, TableNode $data) { + + return array( + new Given('I edit the section "' . $sectionnumber . '"'), + new Given('I fill the moodle form with:', $data), + new Given('I press "' . get_string('savechanges') . '"') + ); + } + /** * Checks if the specified course section hightlighting is turned on. You need to be in the course page on editing mode. *