first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,110 @@
@report @report_progress
Feature: Teacher can view and override users' activity completion data via the progress report.
In order to view and override a student's activity completion status
As a teacher
I need to view the course progress report and click the respective completion status icon
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section | completion | completionview | completionusegrade | assignsubmission_onlinetext_enabled | submissiondrafts |
| assign | my assignment | A1 desc | C1 | assign1 | 0 | 1 | 0 | | 0 | 0 |
| assign | my assignment 2 | A2 desc | C1 | assign2 | 0 | 2 | 1 | | 0 | 0 |
| assign | my assignment 3 | A3 desc | C1 | assign3 | 0 | 2 | 1 | 1 | 1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic |
| teacher1 | Teacher | One | teacher1@example.com | t1 | | fred | | |
| student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following config values are set as admin:
| fullnamedisplay | firstname |
| alternativefullnameformat | middlename, alternatename, firstname, lastname |
# Course comprising one activity with auto completion (student must view it) and one with manual completion.
# This confirms that after being completed by the student and overridden by the teacher, that both activities can still be
# completed again via normal mechanisms.
@javascript
Scenario: Given the status has been overridden, when a student tries to complete it again, completion can still occur.
# Student completes the activities, manual and automatic completion.
Given I am on the "Course 1" course page logged in as student1
And the manual completion button of "my assignment" is displayed as "Mark as done"
And I toggle the manual completion state of "my assignment"
And the manual completion button of "my assignment" is displayed as "Done"
And I am on the "my assignment 2" "assign activity" page
And the "View" completion condition of "my assignment 2" is displayed as "done"
And I log out
# Teacher overrides the activity completion statuses to incomplete.
When I am on the "Course 1" course page logged in as teacher1
And I navigate to "Reports" in current page administration
And I click on "Activity completion" "link"
And "Ann, Jill, Grainne, Beauchamp, my assignment: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And "Ann, Jill, Grainne, Beauchamp, my assignment 2: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "my assignment" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "Save changes" "button"
And "Ann, Jill, Grainne, Beauchamp, my assignment: Not completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "my assignment 2" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "Save changes" "button"
And "Ann, Jill, Grainne, Beauchamp, my assignment 2: Not completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I log out
# Student can now complete the activities again, via normal means.
And I am on the "Course 1" course page logged in as student1
Then the manual completion button of "my assignment" overridden by "Teacher" is displayed as "Mark as done"
And the "View" completion condition of "my assignment 2" overridden by "Teacher" is displayed as "todo"
And I toggle the manual completion state of "my assignment"
And the manual completion button of "my assignment" is displayed as "Done"
And I am on the "my assignment 2" "assign activity" page
And I am on "Course 1" course homepage
And the "View" completion condition of "my assignment 2" is displayed as "done"
And I log out
# And the activity completion report should show the same.
And I am on the "Course 1" Course page logged in as teacher1
And I navigate to "Reports" in current page administration
And I click on "Activity completion" "link"
And "Ann, Jill, Grainne, Beauchamp, my assignment: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And "Ann, Jill, Grainne, Beauchamp, my assignment 2: Completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
# Course comprising one activity with auto completion (student must view it and receive a grade) and one with manual completion.
# This confirms that after being overridden to complete by the teacher, that the completion status for activities with automatic
# completion can no longer be affected by any normal completion mechanisms triggered by the student. Manual completion unaffected.
@javascript
Scenario: Given the status has been overridden to complete, when a student triggers completion updates, the status remains fixed.
# When the teacher overrides the activity completion statuses to complete.
When I am on the "Course 1" Course page logged in as teacher1
And I navigate to "Reports" in current page administration
And I click on "Activity completion" "link"
And "Ann, Jill, Grainne, Beauchamp, my assignment: Not completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And "Ann, Jill, Grainne, Beauchamp, my assignment 3: Not completed" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "my assignment" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "Save changes" "button"
And "Ann, Jill, Grainne, Beauchamp, my assignment: Completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "my assignment 3" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I click on "Save changes" "button"
And "Ann, Jill, Grainne, Beauchamp, my assignment 3: Completed (set by Teacher)" "icon" should exist in the "Ann, Jill, Grainne, Beauchamp" "table_row"
And I log out
# Then as a student, confirm that automatic completion checks are no longer triggered (such as after an assign submission).
And I am on the "Course 1" course page logged in as student1
Then the "Receive a grade" completion condition of "my assignment 3" overridden by "Teacher" is displayed as "done"
And I am on the "my assignment 3" "assign activity" page
And I press "Add submission"
And I set the following fields to these values:
| Online text | I'm the student first submission |
And I press "Save changes"
And I should see "Submitted for grading"
And I am on "Course 1" course homepage
And the "Receive a grade" completion condition of "my assignment 3" overridden by "Teacher" is displayed as "done"
# And Confirm that manual completion changes are still allowed.
And I am on "Course 1" course homepage
And the manual completion button of "my assignment" overridden by "Teacher" is displayed as "Done"
And I toggle the manual completion state of "my assignment"
And the manual completion button of "my assignment" is displayed as "Mark as done"
@@ -0,0 +1,74 @@
@report @report_progress
Feature: Teacher can view and filter activity completion data by group, activity type and section.
Background:
Given the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| format | topics |
| enablecompletion | 1 |
| groupmode | 1 |
| initsections | 1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section | completion | completionview |
| quiz | My quiz B | A3 desc | C1 | quizb | 0 | 2 | 1 |
| quiz | My quiz A | A3 desc | C1 | quiza | 1 | 2 | 1 |
| page | My page | A4 desc | C1 | page1 | 2 | 2 | 1 |
| assign | My assignment | A1 desc | C1 | assign1 | 2 | 2 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
| student1 | Student | One | student1@example.com |
| student2 | Student | Two | student2@example.com |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G2 |
| teacher1 | G1 |
| teacher1 | G2 |
@javascript
Scenario: Teacher can view the activity completion report using filtering and sorting options.
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Reports" in current page administration
And I click on "Activity completion" "link"
Then "My quiz B" "link" should appear before "My quiz A" "link" in the "completion-progress" "table"
And I should see "My assignment" in the "completion-progress" "table"
And I should see "My page" in the "completion-progress" "table"
And I should see "Student One" in the "completion-progress" "table"
And I should see "Student Two" in the "completion-progress" "table"
And I set the field "Separate groups" to "Group 1"
And I set the field "Include" to "Quizzes"
And I set the field "Activity order" to "Alphabetical"
And "My quiz A" "link" should appear before "My quiz B" "link" in the "completion-progress" "table"
And I should not see "My assignment" in the "completion-progress" "table"
And I should not see "My page" in the "completion-progress" "table"
And I should see "Student One" in the "completion-progress" "table"
And I should not see "Student Two" in the "completion-progress" "table"
And I set the field "Separate groups" to "All participants"
And I set the field "Include" to "All activities and resources"
And I set the field "Section" to "Section 1"
And I should not see "My assignment" in the "completion-progress" "table"
And I should not see "My page" in the "completion-progress" "table"
And I should not see "My assignment" in the "completion-progress" "table"
And I should not see "My quiz B" in the "completion-progress" "table"
And I should see "My quiz A" in the "completion-progress" "table"
And I should see "Quiz" in the "activityinclude" "select"
And I should not see "Page" in the "activityinclude" "select"
And I set the field "Section" to "Section 2"
And I should not see "Quiz" in the "activityinclude" "select"
And I should see "Page" in the "activityinclude" "select"
And I should see "Assignment" in the "activityinclude" "select"
And I set the field "Include" to "Page"
And I set the field "Section" to "Section 1"
And I should see "Page" in the "activityinclude" "select"
@@ -0,0 +1,50 @@
@report @report_progress
Feature: In a course administration page, navigate through report page, test for selector in activity completion
In order to view and override a student's activity completion status
As a teacher
Go to course administration -> Reports -> Activity completion
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section | completion | completionview | completionusegrade | assignsubmission_onlinetext_enabled | submissiondrafts |
| assign | my assignment | A1 desc | C1 | assign1 | 0 | 1 | 0 | | 0 | 0 |
| assign | my assignment 2 | A2 desc | C1 | assign2 | 0 | 2 | 1 | | 0 | 0 |
| assign | my assignment 3 | A3 desc | C1 | assign3 | 0 | 2 | 1 | 1 | 1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
| student1 | Student | One | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
@javascript
Scenario: Selector should be available in the course acitivity completion page
Given I log in as "admin"
And I am on "Course 1" course homepage
When I navigate to "Reports" in current page administration
And I click on "Activity completion" "link"
Then "Report" "field" should exist in the "tertiary-navigation" "region"
And I should see "Activity completion" in the "tertiary-navigation" "region"
Scenario: Custom profile fields selected for identity should display on the activity completion report
Given the following "custom profile fields" exist:
| datatype | shortname | name |
| text | frog | Favourite frog |
And the following "users" exist:
| username | firstname | lastname | profile_field_frog |
| student2 | Student | Two | Kermit |
And the following "course enrolments" exist:
| user | course | role |
| student2 | C1 | student |
And the following config values are set as admin:
| showuseridentity | email,profile_field_frog |
When I am on the "C1" "Course" page logged in as "admin"
And I navigate to "Reports" in current page administration
And I click on "Activity completion" "link"
Then I should see "Favourite frog"
Then I should see "Kermit" in the "Student Two" "table_row"
@@ -0,0 +1,125 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace report_progress;
use advanced_testcase;
use completion_info;
use testing_data_generator;
/**
* Class for testing report progress helper.
*
* @package report_progress
* @covers \report_progress\local\helper
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
final class report_progress_helper_test extends advanced_testcase {
/** @var testing_data_generator data generator.*/
protected $generator;
/**
* Set up testcase.
*/
public function setUp(): void {
global $CFG;
$CFG->enablecompletion = true;
$this->setAdminUser();
$this->resetAfterTest();
$this->generator = $this->getDataGenerator();
}
/**
* Test process_activities_by_filter_options function.
*/
public function test_sort_activities() {
$expectedactivitytypes = ['all' => 'All activities and resources', 'assign' => 'Assignments', 'quiz' => 'Quizzes'];
// Generate test data.
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
$quiz2 = $this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 2'],
['completion' => 1]);
$quiz1 = $this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 1'],
['completion' => 1]);
$assign1 = $this->generator->create_module('assign', ['course' => $course->id, 'name' => 'Assignment'],
['completion' => 1]);
$completion = new completion_info($course);
// Sort the activities by name.
list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, 'quiz',
'alphabetical');
// Check weather the result is filtered and sorted.
$this->assertEquals(2, count($activities));
$this->assertEquals('Quiz 1', $activities[0]->name);
$this->assertEquals('Quiz 2', $activities[1]->name);
$this->assertEquals($activitytypes, $expectedactivitytypes);
}
/**
* Test filtering by section.
*/
public function test_filter_activities_by_section() {
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
$this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 2', 'section' => 1],
['completion' => 1]);
$this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 1', 'section' => 2],
['completion' => 1]);
$this->generator->create_module('assign', ['course' => $course->id, 'name' => 'Assignment', 'section' => 2],
['completion' => 1]);
$completion = new completion_info($course);
// Get activities of section 0.
list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, '', '', 0);
$this->assertEquals(0, count($activities));
$this->assertEquals($activitytypes, ['all' => 'All activities and resources']);
// Get activities of section 1.
list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, '', '', 1);
$this->assertEquals(1, count($activities));
$this->assertEquals('Quiz 2', array_shift($activities)->name);
$this->assertEquals($activitytypes, ['all' => 'All activities and resources', 'quiz' => 'Quizzes']);
// Get activities of section 2.
list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, '', '', 2);
$this->assertEquals(2, count($activities));
$this->assertEquals('Quiz 1', array_shift($activities)->name);
$this->assertEquals('Assignment', array_shift($activities)->name);
$this->assertEquals(
$activitytypes,
['all' => 'All activities and resources', 'assign' => 'Assignments', 'quiz' => 'Quizzes']
);
// Get assignments of section 2.
list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, 'assign', '', 2);
$this->assertEquals(1, count($activities));
$this->assertEquals('Assignment', array_shift($activities)->name);
$this->assertEquals(
$activitytypes,
['all' => 'All activities and resources', 'assign' => 'Assignments', 'quiz' => 'Quizzes']
);
// Get assignments of section 1.
list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, 'assign', '', 1);
$this->assertEquals(0, count($activities));
$this->assertEquals(
$activitytypes,
['all' => 'All activities and resources', 'assign' => 'Assignments', 'quiz' => 'Quizzes']
);
}
}