From b04f03598a102201ba27fb284d584eb1547963fc Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Fri, 16 Apr 2021 19:40:09 +0800 Subject: [PATCH 01/20] MDL-71162 mod_lesson: Add behat testing for completion conditions --- .../behat/lesson_activity_completion.feature | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 mod/lesson/tests/behat/lesson_activity_completion.feature diff --git a/mod/lesson/tests/behat/lesson_activity_completion.feature b/mod/lesson/tests/behat/lesson_activity_completion.feature new file mode 100644 index 00000000000..74254aeff75 --- /dev/null +++ b/mod/lesson/tests/behat/lesson_activity_completion.feature @@ -0,0 +1,104 @@ +@mod @mod_lesson @core_completion +Feature: View activity completion in the lesson activity + In order to have visibility of lesson completion requirements + As a student + I need to be able to view my lesson completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And the following "activity" exists: + | activity | lesson | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 2 | + | completionview | 1 | + | completionusegrade | 1 | + | completionendreached | 1 | + | completiontimespentenabled | 1 | + | completiontimespent | 1 | + And I am on "Course 1" course homepage + And I follow "Music history" + And I follow "Add a content page" + And I set the following fields to these values: + | Page title | Music history part 1 | + | Description | The history of music part 1 | + | Jump | Next page | + And I click on "Save page" "button" + And I select "Add a question page" from the "qtype" singleselect + And I set the field "Select a question type" to "Essay" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | Music essay | + | Page contents | Write a really interesting music essay | + | Jump | End of lesson | + | Score | 1 | + And I press "Save page" + And I log out + + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Spend at least 1 sec on this activity" completion condition + And "Music history" should have the "Go through the activity to the end" completion condition + And "Music history" should have the "Receive a grade" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Spend at least 1 sec on this activity" completion condition of "Music history" is displayed as "todo" + And the "Go through the activity to the end" completion condition of "Music history" is displayed as "todo" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + When I am on "Course 1" course homepage + And I follow "Music history" + And I wait "2" seconds + And I press "The history of music part 1" + And I set the field "Your answer" to "Some drummers play with their sticks flipped around" + And I press "Submit" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Spend at least 1 sec on this activity" completion condition of "Music history" is displayed as "done" + And the "Go through the activity to the end" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 954ec584f2a4e34dd9eb46cdc03a95d1408a49ff Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Fri, 16 Apr 2021 20:15:46 +0800 Subject: [PATCH 02/20] MDL-71162 mod_choice: Updated completion behat to use latest rules --- ...activity_info_completion_automatic.feature | 16 ++++----- .../activity_info_completion_manual.feature | 33 ++++++++----------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/mod/choice/tests/behat/activity_info_completion_automatic.feature b/mod/choice/tests/behat/activity_info_completion_automatic.feature index 8c4cf786cde..6acd80966d5 100644 --- a/mod/choice/tests/behat/activity_info_completion_automatic.feature +++ b/mod/choice/tests/behat/activity_info_completion_automatic.feature @@ -32,19 +32,19 @@ Feature: Automatic completion in the choice activity Given I log in as "student1" And I am on "Course 1" course homepage When I follow "What to drink?" - Then I should see "Done: View" in the "[data-region=completionrequirements]" "css_element" - And I should see "To do: Make a choice" in the "[data-region=completionrequirements]" "css_element" + Then the "View" completion condition of "What to drink?" is displayed as "done" + And the "Make a choice" completion condition of "What to drink?" is displayed as "todo" And I set the field "Beer" to "1" And I press "Save my choice" - And I should see "Done: View" in the "[data-region=completionrequirements]" "css_element" - And I should see "Done: Make a choice" in the "[data-region=completionrequirements]" "css_element" + And the "View" completion condition of "What to drink?" is displayed as "done" + And the "Make a choice" completion condition of "What to drink?" is displayed as "done" Scenario: Viewing a choice activity with automatic completion as a teacher Given I log in as "teacher1" And I am on "Course 1" course homepage When I follow "What to drink?" - And I should see "View" in the "[data-region=completionrequirements]" "css_element" - And I should see "Make a choice" in the "[data-region=completionrequirements]" "css_element" + Then "What to drink?" should have the "View" completion condition + And "What to drink?" should have the "Make a choice" completion condition @javascript Scenario: Overriding automatic choice completion for a user @@ -57,5 +57,5 @@ Feature: Automatic completion in the choice activity And I log in as "student1" And I am on "Course 1" course homepage When I follow "What to drink?" - Then "span[aria-label=\"Done: View (set by Teacher 1)\"]" "css_element" should exist - And "span[aria-label=\"Done: Make a choice (set by Teacher 1)\"]" "css_element" should exist + Then the "View" completion condition of "What to drink?" overridden by "Teacher 1" is displayed as "done" + And the "Make a choice" completion condition of "What to drink?" overridden by "Teacher 1" is displayed as "done" diff --git a/mod/choice/tests/behat/activity_info_completion_manual.feature b/mod/choice/tests/behat/activity_info_completion_manual.feature index e5285746ab7..b44b9690d6e 100644 --- a/mod/choice/tests/behat/activity_info_completion_manual.feature +++ b/mod/choice/tests/behat/activity_info_completion_manual.feature @@ -31,31 +31,28 @@ Feature: Manual completion in the choice activity Given I log in as "student1" And I am on "Course 1" course homepage And I follow "What to drink?" - And "Mark as done" "button" should exist - When I press "Mark as done" - And I wait until the page is ready - Then "Done" "button" should exist + And the manual completion button of "What to drink?" is displayed as "Mark as done" + When I toggle the manual completion state of "What to drink?" + Then the manual completion button of "What to drink?" is displayed as "Done" But "Mark as done" "button" should not exist # Just make sure that the change persisted. And I reload the page And I wait until the page is ready And I should not see "Mark as done" - And I should see "Done" - And I press "Done" - And I wait until the page is ready - And "Mark as done" "button" should exist + And the manual completion button of "What to drink?" is displayed as "Done" + And I toggle the manual completion state of "What to drink?" + And the manual completion button of "What to drink?" is displayed as "Mark as done" But "Done" "button" should not exist # Just make sure that the change persisted. And I reload the page - And I wait until the page is ready - And "Mark as done" "button" should exist + And the manual completion button of "What to drink?" is displayed as "Mark as done" But "Done" "button" should not exist Scenario: Viewing a choice activity with manual completion as a teacher Given I log in as "teacher1" And I am on "Course 1" course homepage When I follow "What to drink?" - Then the "Mark as done" "button" should be disabled + Then the manual completion button for "What to drink?" should be disabled @javascript Scenario: Overriding a manual choice completion for a user to done @@ -68,10 +65,9 @@ Feature: Manual completion in the choice activity And I log in as "student1" And I am on "Course 1" course homepage When I follow "What to drink?" - Then "button[aria-label=\"What to drink? is marked by Teacher 1 as done. Press to undo.\"]" "css_element" should exist - And I press "Done" - And I wait until the page is ready - And "button[aria-label=\"Mark What to drink? as done\"]" "css_element" should exist + Then the manual completion button of "What to drink?" overridden by "Teacher 1" is displayed as "Done" + And I toggle the manual completion state of "What to drink?" + And the manual completion button of "What to drink?" is displayed as "Mark as done" @javascript Scenario: Overriding a manual choice completion for a user to not done @@ -90,7 +86,6 @@ Feature: Manual completion in the choice activity And I log in as "student1" And I am on "Course 1" course homepage When I follow "What to drink?" - Then "button[aria-label=\"What to drink? is marked by Teacher 1 as not done. Press to mark as done.\"]" "css_element" should exist - And I press "Mark as done" - And I wait until the page is ready - And "button[aria-label=\"What to drink? is marked as done. Press to undo.\"]" "css_element" should exist + Then the manual completion button of "What to drink?" overridden by "Teacher 1" is displayed as "Mark as done" + And I toggle the manual completion state of "What to drink?" + And the manual completion button of "What to drink?" is displayed as "Done" From f5687b7bc6d39cd7392df96645bbdf06de38ba99 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Thu, 22 Apr 2021 10:03:40 +0800 Subject: [PATCH 03/20] MDL-71162 mod_data: Ensure completion conditions displayed on all tabs --- mod/data/edit.php | 7 +++++++ mod/data/export.php | 7 +++++++ mod/data/lib.php | 9 ++++++++- mod/data/preset.php | 6 ++++++ mod/data/templates.php | 7 +++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/mod/data/edit.php b/mod/data/edit.php index 0bbdf974166..85f53d9fd98 100644 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -232,6 +232,13 @@ if ($datarecord = data_submitted() and confirm_sesskey()) { echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name), 2); + +// Render the activity information. +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $OUTPUT->box(format_module_intro('data', $data, $cm->id), 'generalbox', 'intro'); groups_print_activity_menu($cm, $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id); diff --git a/mod/data/export.php b/mod/data/export.php index e6d6e50213c..73d7980e328 100644 --- a/mod/data/export.php +++ b/mod/data/export.php @@ -87,6 +87,13 @@ if($mform->is_cancelled()) { $PAGE->force_settings_menu(true); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name), 2); + + // Render the activity information. + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $OUTPUT->box(format_module_intro('data', $data, $cm->id), 'generalbox', 'intro'); $url = new moodle_url('/mod/data/export.php', array('d' => $d)); diff --git a/mod/data/lib.php b/mod/data/lib.php index 460bda83b83..7b6014427bd 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -2305,11 +2305,18 @@ function data_delete_site_preset($name) { */ function data_print_header($course, $cm, $data, $currenttab='') { - global $CFG, $displaynoticegood, $displaynoticebad, $OUTPUT, $PAGE; + global $CFG, $displaynoticegood, $displaynoticebad, $OUTPUT, $PAGE, $USER; $PAGE->set_title($data->name); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name), 2); + + // Render the activity information. + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $OUTPUT->box(format_module_intro('data', $data, $cm->id), 'generalbox', 'intro'); // Groups needed for Add entry tab diff --git a/mod/data/preset.php b/mod/data/preset.php index 82007c9f3c5..b9f53898bd3 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -102,6 +102,12 @@ if (!$form_export->is_submitted()) { echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name), 2); + // Render the activity information. + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + // Needed for tabs.php $currenttab = 'presets'; $currentgroup = groups_get_activity_group($cm); diff --git a/mod/data/templates.php b/mod/data/templates.php index ce5af6c782a..1a31c86bd46 100644 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -106,6 +106,13 @@ $PAGE->set_pagelayout('admin'); $PAGE->force_settings_menu(true); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name), 2); + +// Render the activity information. +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $OUTPUT->box(format_module_intro('data', $data, $cm->id), 'generalbox', 'intro'); /// Groups needed for Add entry tab From 29a02febdc203a8a47bddd32435c4c06c26dd351 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Sat, 17 Apr 2021 00:19:36 +0800 Subject: [PATCH 04/20] MDL-71162 mod_data: Add behat testing for completion conditions --- .../completion_condition_entries.feature | 62 -------- .../behat/data_activity_completion.feature | 141 ++++++++++++++++++ 2 files changed, 141 insertions(+), 62 deletions(-) delete mode 100644 mod/data/tests/behat/completion_condition_entries.feature create mode 100644 mod/data/tests/behat/data_activity_completion.feature diff --git a/mod/data/tests/behat/completion_condition_entries.feature b/mod/data/tests/behat/completion_condition_entries.feature deleted file mode 100644 index 4f74d2cb65d..00000000000 --- a/mod/data/tests/behat/completion_condition_entries.feature +++ /dev/null @@ -1,62 +0,0 @@ -@mod @mod_data -Feature: Set entries required as a completion condition for a data item - In order to ensure students make a minimum number of entries - As a teacher - I need to set entries required to mark the database activity as completed - - Scenario: Two entries required to complete the activity - Given the following "users" exist: - | username | firstname | lastname | email | - | student1 | Student | 1 | student1@example.com | - | teacher1 | Teacher | 1 | teacher1@example.com | - And the following "courses" exist: - | fullname | shortname | enablecompletion | - | Course 1 | C1 | 1 | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - | student1 | C1 | student | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "Database" to section "1" and I fill the form with: - | Name | Test database name | - | Description | Test database description | - | Completion tracking | Show activity as complete when conditions are met | - | completionview | 0 | - | completionentriesenabled | checked | - | completionentries | 2 | - And I am on "Course 1" course homepage - And I add a "Text input" field to "Test database name" database and I fill the form with: - | Field name | Test field name | - And I am on "Course 1" course homepage - And I log out - When I log in as "student1" - And I am on "Course 1" course homepage - And I add an entry to "Test database name" database with: - | Test field name | Student original entry | - And I press "Save and view" - And I am on "Course 1" course homepage - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage - #One entry is not enough to mark as complete - And "Student 1" user has not completed "Test database name" activity - And I log out - When I log in as "student1" - And I am on "Course 1" course homepage - And I add an entry to "Test database name" database with: - | Test field name | Student second entry | - And I press "Save and view" - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage - Then "Student 1" user has completed "Test database name" activity - And I am on "Course 1" course homepage - And I follow "Test database name" - And I navigate to "Edit settings" in current page administration - And I press "Unlock completion" - And I set the field "completionentries" to "1" - And I press "Save and display" - And I am on "Course 1" course homepage - Then "Student 1" user has completed "Test database name" activity - And I log out diff --git a/mod/data/tests/behat/data_activity_completion.feature b/mod/data/tests/behat/data_activity_completion.feature new file mode 100644 index 00000000000..709f739c511 --- /dev/null +++ b/mod/data/tests/behat/data_activity_completion.feature @@ -0,0 +1,141 @@ +@mod @mod_data @core_completion +Feature: View activity completion in the database activity + In order to have visibility of database completion requirements + As a student + I need to be able to view my database completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And the following "activity" exists: + | activity | data | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Aggregate type | Average of ratings | + | scale[modgrade_type] | Point | + | scale[modgrade_point] | 100 | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | 1 | + | completionentriesenabled | 1 | + | completionentries | 2 | + And I press "Save and display" + And I add a "Text input" field to "Music history" database and I fill the form with: + | Field name | Instrument types | + And I follow "Templates" + And I press "Save template" + And I log out + + Scenario: View automatic completion items as a teacher and confirm all tabs display conditions + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "View single" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "Search" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "Add entry" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "Export" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "Templates" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "Fields" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I follow "Presets" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 2" completion condition + And "Music history" should have the "Receive a grade" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Make entries: 2" completion condition of "Music history" is displayed as "todo" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + And I am on "Course 1" course homepage + And I add an entry to "Music history" database with: + | Instrument types | Drums | + And I press "Save and view" + # One entry is not enough to mark as complete. + And the "Make entries: 2" completion condition of "Music history" is displayed as "todo" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I follow "View single" + And I set the field "rating" to "3" + And I press "Rate" + And I log out + When I log in as "student1" + And I am on "Course 1" course homepage + And I add an entry to "Music history" database with: + | Instrument types | Hurdygurdy | + And I press "Save and view" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Make entries: 2" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And "Vinnie Student1" user has completed "Music history" activity + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 70fe3792b3fe3963b8dc5c716c8a9bdbc2e9c957 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Sat, 17 Apr 2021 00:52:42 +0800 Subject: [PATCH 05/20] MDL-71162 mod_feedback: Add behat testing for completion conditions --- .../feedback_activity_completion.feature | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 mod/feedback/tests/behat/feedback_activity_completion.feature diff --git a/mod/feedback/tests/behat/feedback_activity_completion.feature b/mod/feedback/tests/behat/feedback_activity_completion.feature new file mode 100644 index 00000000000..42482b88007 --- /dev/null +++ b/mod/feedback/tests/behat/feedback_activity_completion.feature @@ -0,0 +1,85 @@ +@mod @mod_feedback @core_completion +Feature: View activity completion in the feedback activity + In order to have visibility of feedback completion requirements + As a student + I need to be able to view my feedback completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And the following "activity" exists: + | activity | feedback | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 2 | + | completionview | 1 | + | completionsubmit | 1 | + And I am on "Course 1" course homepage + And I follow "Music history" + And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I add a "Multiple choice" question to the feedback with: + | Question | What is your favourite instrument | + | Label | instrument1 | + | Multiple choice type | Multiple choice - single answer | + | Multiple choice values | drums\guitar\hurdygurdy | + And I log out + + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Submit feedback" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "todo" + And the "Submit feedback" completion condition of "Music history" is displayed as "todo" + When I follow "Answer the questions" + And I set the field "drums" to "1" + And I press "Submit your answers" + And I press "Continue" + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Submit feedback" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 751220c3bed7cb846576d2b49a99e9b90682edaa Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Mon, 19 Apr 2021 17:36:27 +0800 Subject: [PATCH 06/20] MDL-71162 mod_forum: Add behat testing for completion conditions --- ...etion_condition_number_discussions.feature | 48 -------- .../behat/forum_activity_completion.feature | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 48 deletions(-) delete mode 100644 mod/forum/tests/behat/completion_condition_number_discussions.feature create mode 100644 mod/forum/tests/behat/forum_activity_completion.feature diff --git a/mod/forum/tests/behat/completion_condition_number_discussions.feature b/mod/forum/tests/behat/completion_condition_number_discussions.feature deleted file mode 100644 index 94c84f17f0d..00000000000 --- a/mod/forum/tests/behat/completion_condition_number_discussions.feature +++ /dev/null @@ -1,48 +0,0 @@ -@mod @mod_forum -Feature: Set a certain number of discussions as a completion condition for a forum - In order to ensure students are participating on forums - As a teacher - I need to set a minimum number of discussions to mark the forum activity as completed - - Scenario: Set X number of discussions as a condition - Given the following "users" exist: - | username | firstname | lastname | email | - | student1 | Student | 1 | student1@example.com | - | teacher1 | Teacher | 1 | teacher1@example.com | - And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - | student1 | C1 | student | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Edit settings" in current page administration - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - When I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | - | Completion tracking | Show activity as complete when conditions are met | - | completionview | 0 | - | completionpostsenabled | 0 | - | completiondiscussionsenabled | 1 | - | completiondiscussions | 2 | - And I log out - And I log in as "student1" - And I am on "Course 1" course homepage - And the "Start discussions: 2" completion condition of "Test forum name" is displayed as "todo" - And I add a new discussion to "Test forum name" forum with: - | Subject | Post 1 subject | - | Message | Body 1 content | - And I add a new discussion to "Test forum name" forum with: - | Subject | Post 2 subject | - | Message | Body 2 content | - And I am on "Course 1" course homepage - Then the "Start discussions: 2" completion condition of "Test forum name" is displayed as "done" - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage - And "Student 1" user has completed "Test forum name" activity diff --git a/mod/forum/tests/behat/forum_activity_completion.feature b/mod/forum/tests/behat/forum_activity_completion.feature new file mode 100644 index 00000000000..478e5354e4e --- /dev/null +++ b/mod/forum/tests/behat/forum_activity_completion.feature @@ -0,0 +1,115 @@ +@mod @mod_forum @core_completion +Feature: View activity completion in the forum activity + In order to have visibility of forum completion requirements + As a student + I need to be able to view my forum completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And the following "activity" exists: + | activity | forum | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Whole forum grading > Type | Point | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | Whole forum | + | completionpostsenabled | 1 | + | completionposts | 2 | + | completiondiscussionsenabled | 1 | + | completiondiscussions | 1 | + | completionrepliesenabled | 1 | + | completionreplies | 1 | + And I press "Save and display" + And I log out + + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Start discussions: 1" completion condition + And "Music history" should have the "Make forum posts: 2" completion condition + And "Music history" should have the "Post replies: 1" completion condition + And "Music history" should have the "Receive a grade" completion condition + + @javascript + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Start discussions: 1" completion condition of "Music history" is displayed as "todo" + And the "Make forum posts: 2" completion condition of "Music history" is displayed as "todo" + And the "Post replies: 1" completion condition of "Music history" is displayed as "todo" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + And I add a new discussion to "Music history" forum with: + | Subject | Fun instruments | + | Message | I like drums | + And I reply "Fun instruments" post from "Music history" forum with: + | Subject | Reply 1 to Fun instruments | + | Message | Guitar is also Fun | + And I log out + # Grade the student + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I press "Grade users" + And I set the field "grade" to "33" + And I press "Save" + And I press "Close grader" + And I log out + # All conditions should now be completed. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Start discussions: 1" completion condition of "Music history" is displayed as "done" + And the "Make forum posts: 2" completion condition of "Music history" is displayed as "done" + And the "Post replies: 1" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 0888b6b285dd3ef4fe816752c5dd274faacd05c4 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 20 Apr 2021 12:40:54 +0800 Subject: [PATCH 07/20] MDL-71162 mod_book: Add behat testing for completion conditions --- .../behat/book_activity_completion.feature | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 mod/book/tests/behat/book_activity_completion.feature diff --git a/mod/book/tests/behat/book_activity_completion.feature b/mod/book/tests/behat/book_activity_completion.feature new file mode 100644 index 00000000000..4c20d333bda --- /dev/null +++ b/mod/book/tests/behat/book_activity_completion.feature @@ -0,0 +1,78 @@ +@mod @mod_book @core_completion +Feature: View activity completion information in the book activity + In order to have visibility of book completion requirements + As a student + I need to be able to view my book completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And the following "activity" exists: + | activity | book | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 2 | + | completionview | 1 | + And I log out + + Scenario: View automatic completion items + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I set the following fields to these values: + | Chapter title | Drum theory | + | Content | Rudiments are important | + And I press "Save changes" + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + And I set the following fields to these values: + | Chapter title | Drum theory | + | Content | Rudiments are important | + And I press "Save changes" + And I follow "Music history" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 5a9053f87e4eae87e5d4e356bb427a63825650a5 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Thu, 22 Apr 2021 14:30:36 +0800 Subject: [PATCH 08/20] MDL-71162 mod_wiki: Ensure completion conditions displayed on all tabs --- mod/wiki/files.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mod/wiki/files.php b/mod/wiki/files.php index 3bcfed478c4..f7730a24d74 100644 --- a/mod/wiki/files.php +++ b/mod/wiki/files.php @@ -88,6 +88,13 @@ $PAGE->set_heading($course->fullname); $PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki'))); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($wiki->name)); + +// Render the activity information. +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro'); $renderer = $PAGE->get_renderer('mod_wiki'); From 4aec4586d3b5dd8c8efa53967692c3883d46a980 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 20 Apr 2021 12:43:14 +0800 Subject: [PATCH 09/20] MDL-71162 mod_wiki: Improve behat testing for completion conditions --- .../behat/wiki_activity_completion.feature | 69 ++++++++++++------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/mod/wiki/tests/behat/wiki_activity_completion.feature b/mod/wiki/tests/behat/wiki_activity_completion.feature index 43176b05e6c..ea474417729 100644 --- a/mod/wiki/tests/behat/wiki_activity_completion.feature +++ b/mod/wiki/tests/behat/wiki_activity_completion.feature @@ -1,8 +1,8 @@ -@mod @mod_url @core_completion +@mod @mod_wiki @core_completion Feature: View activity completion information in the Wiki activity - In order to have visibility of URL completion requirements + In order to have visibility of wiki completion requirements As a student - I need to be able to view my URL completion progress + I need to be able to view my wiki completion progress Background: Given the following "users" exist: @@ -24,35 +24,52 @@ Feature: View activity completion information in the Wiki activity | Enable completion tracking | Yes | | Show completion conditions | Yes | And I press "Save and display" - - Scenario: View automatic completion items - Given I am on "Course 1" course homepage with editing mode on - And I add a "Wiki" to section "1" and I fill the form with: - | Wiki name | Music history | - | First page name | Respect | - | Completion tracking | Show activity as complete when conditions are met | - | Require view | 1 | - # Teacher view. - And I follow "Music history" - And I click on "Create page" "button" - And "Music history" should have the "View" completion condition - And I log out - # Student view. - When I log in as "student1" + And the following "activity" exists: + | activity | wiki | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 2 | + | completionview | 1 | And I am on "Course 1" course homepage And I follow "Music history" - And the "View" completion condition of "Music history" is displayed as "done" + And I click on "Create page" "button" + And I log out + + Scenario: View automatic completion items as a teacher and confirm all tabs display conditions + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And I click on "Edit" "link" in the "region-main" "region" + And "Music history" should have the "View" completion condition + And I follow "Comments" + And "Music history" should have the "View" completion condition + And I follow "Map" + And "Music history" should have the "View" completion condition + And I follow "Files" + And "Music history" should have the "View" completion condition + And I follow "Administration" + And "Music history" should have the "View" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + When I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" @javascript Scenario: Use manual completion - Given I am on "Course 1" course homepage with editing mode on - And I add a "Wiki" to section "1" and I fill the form with: - | Wiki name | Music history | - | First page name | Respect | - | Completion tracking | Students can manually mark the activity as completed | - # Teacher view. + Given I log in as "teacher1" + And I am on "Course 1" course homepage And I follow "Music history" - And I click on "Create page" "button" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I press "Unlock completion options" + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. And the manual completion button for "Music history" should be disabled And I log out # Student view. From 5150efa190984f53701ad26c25d352d533d7e2cf Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 20 Apr 2021 00:32:37 +0800 Subject: [PATCH 10/20] MDL-71162 mod_glossary: Add behat testing for completion conditions --- .../glossary_activity_completion.feature | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 mod/glossary/tests/behat/glossary_activity_completion.feature diff --git a/mod/glossary/tests/behat/glossary_activity_completion.feature b/mod/glossary/tests/behat/glossary_activity_completion.feature new file mode 100644 index 00000000000..a5a0484380f --- /dev/null +++ b/mod/glossary/tests/behat/glossary_activity_completion.feature @@ -0,0 +1,103 @@ +@mod @mod_glossary @core_completion +Feature: View activity completion in the glossary activity + In order to have visibility of glossary completion requirements + As a student + I need to be able to view my glossary completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And the following "activity" exists: + | activity | glossary | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Aggregate type | Average of ratings | + | scale[modgrade_type] | Point | + | scale[modgrade_point] | 100 | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | 1 | + | completionentriesenabled | 1 | + | completionentries | 1 | + And I press "Save and display" + And I log out + + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Make entries: 1" completion condition + And "Music history" should have the "Receive a grade" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Make entries: 1" completion condition of "Music history" is displayed as "todo" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + When I am on "Course 1" course homepage + And I follow "Music history" + And I press "Add a new entry" + And I set the following fields to these values: + | Concept | Blast beats | + | Definition | Repeated fast tempo hits combining bass, snare and cymbal | + And I press "Save changes" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I set the field "rating" to "3" + And I press "Rate" + And I log out + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Make entries: 1" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 0773b2c4c67022cf0c3d751dc3d2a68bad7324fe Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 20 Apr 2021 17:05:25 +0800 Subject: [PATCH 11/20] MDL-71162 mod_scorm: Add behat testing for completion conditions --- .../behat/scorm_activity_completion.feature | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 mod/scorm/tests/behat/scorm_activity_completion.feature diff --git a/mod/scorm/tests/behat/scorm_activity_completion.feature b/mod/scorm/tests/behat/scorm_activity_completion.feature new file mode 100644 index 00000000000..0397223cb71 --- /dev/null +++ b/mod/scorm/tests/behat/scorm_activity_completion.feature @@ -0,0 +1,112 @@ +@mod @mod_scorm @core_completion @_file_upload @_switch_iframe +Feature: View activity completion in the SCORM activity + In order to have visibility of scorm completion requirements + As a student + I need to be able to view my scorm completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I turn editing mode on + And I add a "SCORM package" to section "1" + And I set the following fields to these values: + | Name | Music history | + | Number of attempts | 1 attempt | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | 1 | + | completionscoredisabled | 0 | + | completionscorerequired | 3 | + | completionstatusrequired[2] | 1 | + | completionstatusrequired[4] | 1 | + | completionstatusallscos | 1 | + And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip" file to "Package file" filemanager + And I click on "Save and display" "button" + And I log out + + @javascript + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Receive a score of 3 or more" completion condition + And "Music history" should have the "Do all parts of this activity" completion condition + And "Music history" should have the "Receive a grade" completion condition + And "Music history" should have the "Complete and pass the activity" completion condition + + @javascript + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "todo" + And the "Receive a score of 3 or more" completion condition of "Music history" is displayed as "todo" + And the "Do all parts of this activity" completion condition of "Music history" is displayed as "todo" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + And the "Complete and pass the activity" completion condition of "Music history" is displayed as "todo" + And I press "Enter" + And I switch to the main frame + And I click on "Par?" "list_item" + And I click on "Keeping Score" "list_item" + And I click on "Other Scoring Systems" "list_item" + And I click on "The Rules of Golf" "list_item" + And I click on "Playing Golf Quiz" "list_item" + And I switch to "scorm_object" iframe + And I click on "[id='question_com.scorm.golfsamples.interactions.playing_1_1']" "css_element" + And I press "Submit Answers" + And I switch to the main frame + And I click on "How to Have Fun Playing Golf" "list_item" + And I click on "How to Make Friends Playing Golf" "list_item" + And I click on "Having Fun Quiz" "list_item" + And I switch to "scorm_object" iframe + And I click on "[id='question_com.scorm.golfsamples.interactions.fun_1_False']" "css_element" + And I press "Submit Answers" + And I switch to the main frame + And I follow "Exit activity" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + # Conditions that are not possible to achieve (eg score below requirement but all attempts used) are marked as failed. + And the "Receive a score of 3 or more" completion condition of "Music history" is displayed as "failed" + # This condition caches as failed, which will be investigated as part of MDL-71401. + And the "Do all parts of this activity" completion condition of "Music history" is displayed as "failed" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + And the "Complete and pass the activity" completion condition of "Music history" is displayed as "failed" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 619b5d1b98bcc6ef1a1081741a05ebae0868a518 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 20 Apr 2021 18:41:46 +0800 Subject: [PATCH 12/20] MDL-71162 mod_survey: Improve behat testing for completion conditions --- .../tests/behat/survey_completion.feature | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/mod/survey/tests/behat/survey_completion.feature b/mod/survey/tests/behat/survey_completion.feature index c7d2cd3b4c8..3b1b682ee82 100644 --- a/mod/survey/tests/behat/survey_completion.feature +++ b/mod/survey/tests/behat/survey_completion.feature @@ -20,14 +20,22 @@ Feature: A teacher can use activity completion to track a student progress And I am on "Course 1" course homepage with editing mode on Scenario: Require survey view - Given I add a "Survey" to section "1" and I fill the form with: - | Name | Test survey name | - | Survey type | Critical incidents | - | Description | Test survey description | + Given the following "activities" exist: + | activity | name | intro | course | idnumber | + | survey | Test survey name | Test survey description | C1 | survey1 | + And I am on "Course 1" course homepage + And I follow "Test survey name" + And I navigate to "Edit settings" in current page administration + And I set the following fields to these values: | Completion tracking | Show activity as complete when conditions are met | - | id_completionview | 1 | - | id_completionsubmit | 0 | + | completionview | 1 | + | completionsubmit | 0 | + And I press "Save and return to course" + And I follow "Test survey name" + # Teacher view. + And "Test survey name" should have the "View" completion condition And I log out + # Student view. When I log in as "student1" And I am on "Course 1" course homepage And the "View" completion condition of "Test survey name" is displayed as "todo" @@ -36,17 +44,47 @@ Feature: A teacher can use activity completion to track a student progress Then the "View" completion condition of "Test survey name" is displayed as "done" Scenario: Require survey submission - Given I add a "Survey" to section "1" and I fill the form with: - | Name | Test survey name | + Given the following "activities" exist: + | activity | name | intro | course | idnumber | + | survey | Test survey name | Test survey description | C1 | survey1 | + And I am on "Course 1" course homepage + And I follow "Test survey name" + And I navigate to "Edit settings" in current page administration + And I set the following fields to these values: | Survey type | Critical incidents | - | Description | Test survey description | | Completion tracking | Show activity as complete when conditions are met | - | id_completionsubmit | 1 | + | completionview | 1 | + | completionsubmit | 1 | + And I press "Save and return to course" + And I follow "Test survey name" + # Teacher view. + And "Test survey name" should have the "Submit answers" completion condition And I log out + # Student view. When I log in as "student1" And I am on "Course 1" course homepage - And the "View" completion condition of "Test survey name" is displayed as "todo" + And the "Submit answers" completion condition of "Test survey name" is displayed as "todo" And I follow "Test survey name" + And the "Submit answers" completion condition of "Test survey name" is displayed as "todo" And I press "Click here to continue" And I am on "Course 1" course homepage - And the "View" completion condition of "Test survey name" is displayed as "done" + And the "Submit answers" completion condition of "Test survey name" is displayed as "done" + And I follow "Test survey name" + And the "Submit answers" completion condition of "Test survey name" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given the following "activities" exist: + | activity | name | intro | course | idnumber | completion | + | survey | Test survey name | Test survey description | C1 | survey1 | 1 | + And I am on "Course 1" course homepage + # Teacher view. + And the manual completion button for "Test survey name" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Test survey name" + Then the manual completion button of "Test survey name" is displayed as "Mark as done" + And I toggle the manual completion state of "Test survey name" + And the manual completion button of "Test survey name" is displayed as "Done" From ef3b5d92979a1edb961a4d0a80d1dd406c15cc03 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 13:51:42 +0800 Subject: [PATCH 13/20] MDL-71162 mod_quiz: Improve behat testing for completion conditions --- ...completion_condition_attempts_used.feature | 8 +++- ...pletion_condition_minimum_attempts.feature | 7 ++- ...completion_condition_passing_grade.feature | 14 ++++-- .../tests/behat/completion_manual.feature | 48 +++++++++++++++++++ 4 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 mod/quiz/tests/behat/completion_manual.feature diff --git a/mod/quiz/tests/behat/completion_condition_attempts_used.feature b/mod/quiz/tests/behat/completion_condition_attempts_used.feature index 49d6e257454..dea3fc19586 100644 --- a/mod/quiz/tests/behat/completion_condition_attempts_used.feature +++ b/mod/quiz/tests/behat/completion_condition_attempts_used.feature @@ -1,4 +1,4 @@ -@mod @mod_quiz +@mod @mod_quiz @core_completion Feature: Set a quiz to be marked complete when the student uses all attempts allowed In order to ensure a student has learned the material before being marked complete As a teacher @@ -47,8 +47,14 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all And I am on "Course 1" course homepage Then the "Receive a grade" completion condition of "Test quiz name" is displayed as "failed" And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done" + And I follow "Test quiz name" + And the "Receive a grade" completion condition of "Test quiz name" is displayed as "failed" + And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage + And I follow "Test quiz name" + And "Test quiz name" should have the "Receive a pass grade or complete all available attempts" completion condition + And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration And "Completed" "icon" should exist in the "Student 1" "table_row" diff --git a/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature b/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature index a066a36ac8e..499e68ab8d8 100644 --- a/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature +++ b/mod/quiz/tests/behat/completion_condition_minimum_attempts.feature @@ -1,4 +1,4 @@ -@mod @mod_quiz +@mod @mod_quiz @core_completion Feature: Set a quiz to be marked complete when the student completes a minimum amount of attempts In order to ensure a student has completed the quiz before being marked complete As a teacher @@ -49,8 +49,13 @@ Feature: Set a quiz to be marked complete when the student completes a minimum a And I press "Submit all and finish" And I am on "Course 1" course homepage Then the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done" + And I follow "Test quiz name" + And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage + And I follow "Test quiz name" + And "Test quiz name" should have the "Make attempts: 2" completion condition + And I am on "Course 1" course homepage And I navigate to "Reports > Activity completion" in current page administration And "Completed" "icon" should exist in the "Student 1" "table_row" diff --git a/mod/quiz/tests/behat/completion_condition_passing_grade.feature b/mod/quiz/tests/behat/completion_condition_passing_grade.feature index 2684ffa1d4b..4c435129c4f 100644 --- a/mod/quiz/tests/behat/completion_condition_passing_grade.feature +++ b/mod/quiz/tests/behat/completion_condition_passing_grade.feature @@ -1,4 +1,4 @@ -@mod @mod_quiz +@mod @mod_quiz @core_completion Feature: Set a quiz to be marked complete when the student passes In order to ensure a student has learned the material before being marked complete As a teacher @@ -25,8 +25,8 @@ Feature: Set a quiz to be marked complete when the student passes | questioncategory | qtype | name | questiontext | | Test questions | truefalse | First question | Answer the first question | And the following "activities" exist: - | activity | name | course | idnumber | attempts | gradepass | completion | completionusegrade | completionpass | - | quiz | Test quiz name | C1 | quiz1 | 4 | 5.00 | 2 | 1 | 1 | + | activity | name | course | idnumber | attempts | gradepass | completion | completionusegrade | completionpass | completionview | + | quiz | Test quiz name | C1 | quiz1 | 4 | 5.00 | 2 | 1 | 1 | 1 | And quiz "Test quiz name" contains the following questions: | question | page | | First question | 1 | @@ -36,12 +36,18 @@ Feature: Set a quiz to be marked complete when the student passes And I am on "Course 1" course homepage And the "Receive a grade" completion condition of "Test quiz name" is displayed as "todo" And the "Receive a pass grade" completion condition of "Test quiz name" is displayed as "todo" + And the "View" completion condition of "Test quiz name" is displayed as "todo" And user "student1" has attempted "Test quiz name" with responses: | slot | response | | 1 | True | - And I am on "Course 1" course homepage + And I follow "Test quiz name" Then the "Receive a grade" completion condition of "Test quiz name" is displayed as "done" And the "Receive a pass grade" completion condition of "Test quiz name" is displayed as "done" + And the "View" completion condition of "Test quiz name" is displayed as "done" + And I am on "Course 1" course homepage + And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done" + And the "Receive a pass grade" completion condition of "Test quiz name" is displayed as "done" + And the "View" completion condition of "Test quiz name" is displayed as "done" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage diff --git a/mod/quiz/tests/behat/completion_manual.feature b/mod/quiz/tests/behat/completion_manual.feature new file mode 100644 index 00000000000..de63ece55fa --- /dev/null +++ b/mod/quiz/tests/behat/completion_manual.feature @@ -0,0 +1,48 @@ +@mod @mod_quiz @core_completion +Feature: Manually complete a quiz + In order to meet manual quiz completion requirements + As a student + I need to be able to view and modify my quiz manual completion status + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@example.com | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following config values are set as admin: + | grade_item_advanced | hiddenuntil | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | First question | Answer the first question | + And the following "activities" exist: + | activity | name | course | idnumber | completion | + | quiz | Test quiz name | C1 | quiz1 | 1 | + And quiz "Test quiz name" contains the following questions: + | question | page | + | First question | 1 | + + @javascript + Scenario: Use manual completion + When I log in as "teacher1" + # Teacher view. + And I am on "Course 1" course homepage + And I follow "Test quiz name" + And the manual completion button for "Test quiz name" should be disabled + And I log out + # Student view. + And I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Test quiz name" + Then the manual completion button of "Test quiz name" is displayed as "Mark as done" + And I toggle the manual completion state of "Test quiz name" + And the manual completion button of "Test quiz name" is displayed as "Done" From 29cb40286a46c9d0443ab8a98a610837c5ae97b8 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 14:51:52 +0800 Subject: [PATCH 14/20] MDL-71162 mod_chat: Add behat testing for completion conditions --- .../behat/chat_activity_completion.feature | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 mod/chat/tests/behat/chat_activity_completion.feature diff --git a/mod/chat/tests/behat/chat_activity_completion.feature b/mod/chat/tests/behat/chat_activity_completion.feature new file mode 100644 index 00000000000..141be8a6503 --- /dev/null +++ b/mod/chat/tests/behat/chat_activity_completion.feature @@ -0,0 +1,70 @@ +@mod @mod_chat @core_completion +Feature: View activity completion information in the chat activity + In order to have visibility of chat completion requirements + As a student + I need to be able to view my chat completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I log out + + Scenario: View automatic completion items + Given I log in as "teacher1" + And the following "activity" exists: + | activity | chat | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 2 | + | completionview | 1 | + And I am on "Course 1" course homepage + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And the following "activity" exists: + | activity | chat | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 1 | + And I am on "Course 1" course homepage + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 7b9a10b1753a4673b5903d48340de7074b83dc18 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 14:52:37 +0800 Subject: [PATCH 15/20] MDL-71162 mod_folder: Add behat testing for completion conditions --- .../behat/folder_activity_completion.feature | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 mod/folder/tests/behat/folder_activity_completion.feature diff --git a/mod/folder/tests/behat/folder_activity_completion.feature b/mod/folder/tests/behat/folder_activity_completion.feature new file mode 100644 index 00000000000..93c3de985e4 --- /dev/null +++ b/mod/folder/tests/behat/folder_activity_completion.feature @@ -0,0 +1,71 @@ +@mod @mod_folder @core_completion +Feature: View activity completion information in the folder activity + In order to have visibility of folder completion requirements + As a student + I need to be able to view my folder completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I log out + + Scenario: View automatic completion items + Given I log in as "teacher1" + And the following "activity" exists: + | activity | folder | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 2 | + | completionview | 1 | + And I am on "Course 1" course homepage + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And the following "activity" exists: + | activity | folder | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 1 | + And I am on "Course 1" course homepage + And I follow "Music history" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From f84235eac73244975f4440c025c15c8ac864ba70 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 16:41:01 +0800 Subject: [PATCH 16/20] MDL-71162 mod_h5pactivity: Add behat testing for completion conditions --- .../behat/h5pactivity_completion.feature | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 mod/h5pactivity/tests/behat/h5pactivity_completion.feature diff --git a/mod/h5pactivity/tests/behat/h5pactivity_completion.feature b/mod/h5pactivity/tests/behat/h5pactivity_completion.feature new file mode 100644 index 00000000000..ceb6e6475d9 --- /dev/null +++ b/mod/h5pactivity/tests/behat/h5pactivity_completion.feature @@ -0,0 +1,75 @@ +@mod @mod_h5pactivity @core_h5p @_file_upload @_switch_iframe @javascript @core_completion +Feature: View activity completion information in the h5p activity + In order to have visibility of h5p completion requirements + As a student + I need to be able to view my h5p completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "admin" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I am on "Course 1" course homepage with editing mode on + And I add a "H5P" to section "1" + And I set the following fields to these values: + | Name | Music history | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | 1 | + And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Package file" filemanager + And I click on "Save and display" "button" + And I log out + + Scenario: View automatic completion items + Given I log in as "teacher1" + And I am on "Course 1" course homepage + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And "Music history" should have the "Receive a grade" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I switch to "h5p-player" class iframe + And I switch to "h5p-iframe" class iframe + And I click on "Check" "button" in the ".h5p-question-buttons" "css_element" + And I reload the page + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + 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 "Music history" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 0fb2ea4eef5595add36371f99e2a8c5fc54c3a12 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 16:47:47 +0800 Subject: [PATCH 17/20] MDL-71162 mod_imscp: Add behat testing for completion conditions --- .../behat/imscp_activity_completion.feature | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 mod/imscp/tests/behat/imscp_activity_completion.feature diff --git a/mod/imscp/tests/behat/imscp_activity_completion.feature b/mod/imscp/tests/behat/imscp_activity_completion.feature new file mode 100644 index 00000000000..2ebae36b953 --- /dev/null +++ b/mod/imscp/tests/behat/imscp_activity_completion.feature @@ -0,0 +1,69 @@ +@mod @mod_imscp @_file_upload @core_completion @javascript +Feature: View activity completion information in the IMS content package activity + In order to have visibility of IMS content package completion requirements + As a student + I need to be able to view my IMS content package completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I log out + + Scenario: View automatic completion items + Given I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + And I add a "IMS content package" to section "1" + And I set the following fields to these values: + | Name | Music history | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager + And I click on "Save and display" "button" + And I am on "Course 1" course homepage + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + And I add a "IMS content package" to section "1" + And I set the following fields to these values: + | Name | Music history | + | Completion tracking | Students can manually mark the activity as completed | + And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager + And I click on "Save and display" "button" + And I follow "Music history" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" From 5c0a2b0d7d39e8d8e828762cd27f8f346f1173ba Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 17:09:52 +0800 Subject: [PATCH 18/20] MDL-71162 mod_label: Improve behat testing for completion conditions --- .../behat/label_activity_completion.feature | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/mod/label/tests/behat/label_activity_completion.feature b/mod/label/tests/behat/label_activity_completion.feature index c501bc86a31..10ed1d5aaad 100644 --- a/mod/label/tests/behat/label_activity_completion.feature +++ b/mod/label/tests/behat/label_activity_completion.feature @@ -24,22 +24,43 @@ Feature: View activity completion information for the label | Enable completion tracking | Yes | | Show completion conditions | No | And I press "Save and display" + And the following "activity" exists: + | activity | label | + | course | C1 | + | idnumber | mh1 | + | section | 1 | + | completion | 1 | @javascript Scenario: The manual completion button will be shown on the course page if the Show completion conditions is set to No - Given I am on "Course 1" course homepage with editing mode on - When I add a "label" to section "1" and I fill the form with: - | Label text | Swanky label | - | Availability | Show on course page | - | Completion tracking | Students can manually mark the activity as completed | + Given I am on "Course 1" course homepage # Teacher view. - And the manual completion button for "Swanky label" should exist - And the manual completion button for "Swanky label" should be disabled + And the manual completion button for "Test label 1" should exist + And the manual completion button for "Test label 1" should be disabled And I log out # Student view. When I log in as "student1" And I am on "Course 1" course homepage - Then the manual completion button for "Swanky label" should exist - And the manual completion button of "Swanky label" is displayed as "Mark as done" - And I toggle the manual completion state of "Swanky label" - And the manual completion button of "Swanky label" is displayed as "Done" + Then the manual completion button for "Test label 1" should exist + And the manual completion button of "Test label 1" is displayed as "Mark as done" + And I toggle the manual completion state of "Test label 1" + And the manual completion button of "Test label 1" is displayed as "Done" + + @javascript + Scenario: The manual completion button will be shown on the course page if the Show completion conditions is set to Yes + Given I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Show completion conditions" to "Yes" + And I press "Save and display" + # Teacher view. + And the manual completion button for "Test label 1" should exist + And the manual completion button for "Test label 1" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + Then the manual completion button for "Test label 1" should exist + And the manual completion button of "Test label 1" is displayed as "Mark as done" + And I toggle the manual completion state of "Test label 1" + And the manual completion button of "Test label 1" is displayed as "Done" From 3ac450e1fcaee47216fe140e70d7574e21d83b94 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 21 Apr 2021 17:31:05 +0800 Subject: [PATCH 19/20] MDL-71162 mod_resource: Improve behat testing for completion conditions --- .../resource_activity_completion.feature | 69 +++++++++++++++++-- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/mod/resource/tests/behat/resource_activity_completion.feature b/mod/resource/tests/behat/resource_activity_completion.feature index 1bf7fa870bc..26ada2058d1 100644 --- a/mod/resource/tests/behat/resource_activity_completion.feature +++ b/mod/resource/tests/behat/resource_activity_completion.feature @@ -1,8 +1,8 @@ @mod @mod_resource @core_completion @_file_upload -Feature: View activity completion information for the resource - In order to have visibility of Resource completion requirements +Feature: View activity completion information for file resources + In order to have visibility of file resource completion requirements As a student - I need to be able to view my Resource completion progress + I need to be able to view my file resource completion progress Background: Given the following "users" exist: @@ -28,15 +28,15 @@ Feature: View activity completion information for the resource And I press "Save and display" @javascript - Scenario Outline: The manual completion button will be shown on the course page for Open, In pop-up, New window and Force download display mode if the Show completion conditions is set to No + Scenario Outline: The manual completion button will be shown on the course page for Open, In pop-up, New window and Force download display mode if Show completion conditions is set to No Given I am on "Course 1" course homepage with editing mode on And I add a "File" to section "1" And I set the following fields to these values: - | Name | Myfile | + | Name | Myfile | | id_display | | | Show size | 0 | | Show type | 0 | - | Show upload/modified date | 0 | + | Show upload/modified date | 0 | | Completion tracking | Students can manually mark the activity as completed | And I upload "mod/resource/tests/fixtures/samplefile.txt" file to "Select files" filemanager And I press "Save and return to course" @@ -58,3 +58,60 @@ Feature: View activity completion information for the resource | In pop-up | | Force download | | New window | + + @javascript + Scenario: The manual completion button will be shown on the activity page and course page if Show completion conditions is set to Yes + Given I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Show completion conditions" to "Yes" + And I press "Save and display" + And I am on "Course 1" course homepage with editing mode on + And I add a "File" to section "1" + And I set the following fields to these values: + | Name | Myfile | + | id_display | Embed | + | Completion tracking | Students can manually mark the activity as completed | + And I upload "mod/resource/tests/fixtures/samplefile.txt" file to "Select files" filemanager + And I click on "Save and display" "button" + # Teacher view. + And the manual completion button for "Myfile" should exist + And the manual completion button for "Myfile" should be disabled + And I follow "Myfile" + And the manual completion button for "Myfile" should exist + And the manual completion button for "Myfile" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + Then the manual completion button for "Myfile" should exist + And I follow "Myfile" + And the manual completion button of "Myfile" is displayed as "Mark as done" + And I toggle the manual completion state of "Myfile" + And the manual completion button of "Myfile" is displayed as "Done" + + @javascript + Scenario: View automatic completion items + Given I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Show completion conditions" to "Yes" + And I press "Save and display" + And I am on "Course 1" course homepage with editing mode on + And I add a "File" to section "1" + And I set the following fields to these values: + | Name | Myfile | + | id_display | Embed | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + And I upload "mod/resource/tests/fixtures/samplefile.txt" file to "Select files" filemanager + And I press "Save and display" + And I am on "Course 1" course homepage + # Teacher view. + And I follow "Myfile" + And "Myfile" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Myfile" + Then the "View" completion condition of "Myfile" is displayed as "done" From 635a53e293e7cef9cf645b995a1aed90915c1ad4 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 27 Apr 2021 16:19:31 +0800 Subject: [PATCH 20/20] MDL-71162 mod_assign: Update and improve completion behat testing --- .../behat/assign_activity_completion.feature | 132 ++++++++++++++---- 1 file changed, 107 insertions(+), 25 deletions(-) diff --git a/mod/assign/tests/behat/assign_activity_completion.feature b/mod/assign/tests/behat/assign_activity_completion.feature index acaf766774a..38a702c9060 100644 --- a/mod/assign/tests/behat/assign_activity_completion.feature +++ b/mod/assign/tests/behat/assign_activity_completion.feature @@ -1,12 +1,12 @@ @mod @mod_assign @core_completion -Feature: View activity completion information in the Assign resource - In order to have visibility of assign completion requirements +Feature: View activity completion in the assignment activity + In order to have visibility of assignment completion requirements As a student - I need to be able to view my assign completion progress + I need to be able to view my assignment completion progress Background: Given the following "users" exist: - | username | firstname | lastname | email | + | username | firstname | lastname | email | | student1 | Vinnie | Student1 | student1@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: @@ -17,47 +17,129 @@ Feature: View activity completion information in the Assign resource | student1 | C1 | student | | teacher1 | C1 | editingteacher | And I log in as "teacher1" - - @javascript - Scenario: The manual completion button will be shown on the course page if the Show completion conditions is set to Yes - Given I am on "Course 1" course homepage with editing mode on + And I am on "Course 1" course homepage And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the following fields to these values: | Enable completion tracking | Yes | | Show completion conditions | Yes | And I press "Save and display" - And I add a "Assignment" to section "1" and I fill the form with: - | Assignment name | History of ants | - | Completion tracking | Students can manually mark the activity as completed | + And the following "activity" exists: + | activity | assign | + | course | C1 | + | idnumber | mh1 | + | name | Music history | + | section | 1 | + | completion | 1 | + | grade[modgrade_type] | point | + | grade[modgrade_point] | 100 | + + @javascript + Scenario: The manual completion button will be shown on the course page if the Show completion conditions is set to Yes + Given I am on "Course 1" course homepage # Teacher view. - And the manual completion button for "History of ants" should exist - And the manual completion button for "History of ants" should be disabled + And the manual completion button for "Music history" should exist + And the manual completion button for "Music history" should be disabled And I log out # Student view. When I log in as "student1" And I am on "Course 1" course homepage - Then the manual completion button for "History of ants" should exist - And the manual completion button of "History of ants" is displayed as "Mark as done" - And I toggle the manual completion state of "History of ants" - And the manual completion button of "History of ants" is displayed as "Done" + Then the manual completion button for "Music history" should exist + And the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" @javascript Scenario: The manual completion button will not be shown on the course page if the Show completion conditions is set to No Given I am on "Course 1" course homepage with editing mode on And I navigate to "Edit settings" in current page administration And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show completion conditions | No | + And I set the field "Show completion conditions" to "No" And I press "Save and display" - And I add a "Assignment" to section "1" and I fill the form with: - | Assignment name | History of ants | - | Completion tracking | Students can manually mark the activity as completed | # Teacher view. - And the manual completion button for "History of ants" should not exist + And the manual completion button for "Music history" should not exist + And I follow "Music history" + And the manual completion button for "Music history" should exist + And the manual completion button for "Music history" should be disabled And I log out # Student view. When I log in as "student1" And I am on "Course 1" course homepage - Then the manual completion button for "History of ants" should not exist + Then the manual completion button for "Music history" should not exist + And I follow "Music history" + And the manual completion button for "Music history" should exist + + @javascript + Scenario: Use manual completion from the activity page + Given I am on "Course 1" course homepage + And I follow "Music history" + # Teacher view. + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" + + Scenario: View automatic completion items as a teacher + Given I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | completionusegrade | 1 | + | completionsubmit | 1 | + And I press "Save and display" + Then "Music history" should have the "View" completion condition + And "Music history" should have the "Make a submission" completion condition + And "Music history" should have the "Receive a grade" completion condition + + @javascript + Scenario: View automatic completion items as a student + Given I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | assignsubmission_onlinetext_enabled | 1 | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | completionusegrade | 1 | + | completionsubmit | 1 | + And I press "Save and display" + And I log out + And I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Make a submission" completion condition of "Music history" is displayed as "todo" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + And I am on "Course 1" course homepage + And I follow "Music history" + And I press "Add submission" + And I set the field "Online text" to "History of playing with drumsticks reversed" + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "View all submissions" in current page administration + And I click on "Grade" "link" in the "Vinnie Student1" "table_row" + And I set the field "Grade out of 100" to "33" + And I set the field "Notify students" to "0" + And I press "Save changes" + And I follow "View all submissions" + And I log out + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Make a submission" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done"