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
+76
View File
@@ -0,0 +1,76 @@
<?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/>.
/**
* Steps definitions related to mod_chat.
*
* @package mod_chat
* @category test
* @copyright 2021 Dongsheng Cai
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
/**
* Steps definitions related to mod_chat.
*
*/
class behat_mod_chat extends behat_base {
/**
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
*
* Recognised page names are:
* | pagetype | name meaning | description |
* | View | Chat name | The chat info page (view.php) |
*
* @param string $type identifies which type of page this is, e.g. 'View'.
* @param string $name chat instance name
* @return moodle_url the corresponding URL.
* @throws Exception with a meaningful error message if the specified page cannot be found.
*/
protected function resolve_page_instance_url(string $type, string $name): moodle_url {
switch (strtolower($type)) {
case 'view':
$cm = $this->get_cm_by_chat_name($name);
return new moodle_url('/mod/chat/view.php', ['id' => $cm->id]);
default:
throw new Exception('Unrecognised chat page type "' . $type . '."');
}
}
/**
* Get a chat by name.
*
* @param string $name chat name.
* @return stdClass the corresponding DB row.
*/
protected function get_chat_by_name(string $name): stdClass {
global $DB;
return $DB->get_record('chat', ['name' => $name], '*', MUST_EXIST);
}
/**
* Get a chat coursemodule object from the name.
*
* @param string $name chat name.
* @return stdClass cm from get_coursemodule_from_instance.
*/
protected function get_cm_by_chat_name(string $name): stdClass {
$chat = $this->get_chat_by_name($name);
return get_coursemodule_from_instance('chat', $chat->id, $chat->course);
}
}
@@ -0,0 +1,56 @@
@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 | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
And I enable "chat" "mod" plugin
Scenario: View automatic completion items
Given I log in as "teacher1"
And the following "activity" exists:
| activity | chat |
| course | C1 |
| name | Music history |
| section | 1 |
| completion | 2 |
| completionview | 1 |
And I am on "Course 1" course homepage
# Teacher view.
And I am on the "Music history" Activity page
And "Music history" should have the "View" completion condition
And I log out
# Student view.
And I am on the "Music history" Activity page logged in as student1
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 |
| name | Music history |
| section | 1 |
| completion | 1 |
And I am on "Course 1" course homepage
# Teacher view.
And "Music history" should have the "Mark as done" completion condition
And I log out
# Student view.
And I am on the "Music history" Activity page logged in as student1
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"
@@ -0,0 +1,36 @@
@mod @mod_chat
Feature: Chat calendar entries
In order to notify students of upcoming chat sessons
As a teacher
I need to create a chat activity and publish the event times
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Tina | Teacher1 | teacher1@example.com |
| student1 | Sam | Student1 | student1@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 enable "chat" "mod" plugin
Scenario Outline: Create a chat activity with repeated chat times set
# Create an activity with repeated chat times
Given the following "activities" exist:
| activity | course | name | schedule |
| chat | C1 | Chat 1 | <scheduleset> |
And I log in as "teacher1"
# Confirm Chat activity visibility based on schedule
When I am viewing calendar in "upcoming" view
Then I <chatvisibility> see "Chat 1"
Examples:
| scheduleset | chatvisibility |
| 0 | should not |
| 1 | should |
| 2 | should |
| 3 | should |
@@ -0,0 +1,55 @@
@mod @mod_chat
Feature: Chat reset
In order to reuse past chat activities
As a teacher
I need to remove all previous data.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Tina | Teacher1 | teacher1@example.com |
| student1 | Sam | Student1 | student1@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 enable "chat" "mod" plugin
And the following "activities" exist:
| activity | name | Description | course | idnumber |
| chat | Test chat name | Test chat description | C1 | chat1 |
Scenario: Use course reset to update chat start date
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| startdate[day] | 1 |
| startdate[month] | January |
| startdate[year] | 2020 |
And I press "Save and display"
And I follow "Test chat name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| chattime[day] | 1 |
| chattime[month] | January |
| chattime[year] | 2020 |
| chattime[hour] | 12 |
| chattime[minute] | 00 |
And I press "Save and display"
And I am on the "Course 1" "reset" page
And I set the following fields to these values:
| reset_start_date[enabled] | 1 |
| reset_start_date[day] | 1 |
| reset_start_date[month] | January |
| reset_start_date[year] | 2030 |
And I press "Reset course"
And I should see "Date changed" in the "Chats" "table_row"
And I press "Continue"
Then I am on "Course 1" course homepage
And I follow "Test chat name"
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the "chattime[year]" select box should contain "2030"
@@ -0,0 +1,61 @@
@mod @mod_chat
Feature: Chat with my group
In order to chat with my group
As a student
I want to be able to see or select by group in the Chat activity
Background:
And the following "courses" exist:
| fullname | shortname |
| Test Course 1 | C1 |
And the following "groups" exist:
| name | course | idnumber | participation |
| Group 1 | C1 | G1 | 1 |
| Group 2 | C1 | G2 | 1 |
| Group 3 | C1 | G3 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | TeacherG1 | 1 | teacher1@example.com |
| user1 | User1G1 | 1 | user1@example.com |
| user2 | User2G2 | 2 | user2@example.com |
| user3 | User3None | 3 | user3@example.com |
| user4 | User4NPgroup | 4 | user4@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| user1 | C1 | student |
| user2 | C1 | student |
| user3 | C1 | student |
| user4 | C1 | student |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
| user1 | G1 |
| user2 | G2 |
| user4 | G3 |
And I enable "chat" "mod" plugin
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| chat | Separate Chat | Chat with separate groups | C1 | chat1 | 1 |
| chat | Visible Chat | Chat with visible groups | C1 | chat2 | 2 |
Scenario Outline: Users should see their own participation groups in "separate groups" mode, and all
participation groups in "visible groups" mode.
Given I am on the "<chat>" "chat activity" page logged in as "<user>"
Then I <all> "All participants"
And I <G1> "Group 1"
And I <G2> "Group 2"
And I should not see "Group 3"
Examples:
| chat | user | all | G1 | G2 |
| chat1 | teacher1 | should see | should see | should see |
| chat1 | user1 | should not see | should see | should not see |
| chat1 | user2 | should not see | should not see | should see |
| chat1 | user3 | should see | should not see | should not see |
| chat1 | user4 | should see | should not see | should not see |
| chat2 | teacher1 | should see | should see | should see |
| chat2 | user1 | should see | should see | should see |
| chat2 | user2 | should see | should see | should see |
| chat2 | user3 | should see | should see | should see |
| chat2 | user4 | should see | should see | should see |
@@ -0,0 +1,49 @@
@mod @mod_chat
Feature: Chat with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create chats even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I enable "chat" "mod" plugin
And the following "activity" exists:
| activity | chat |
| course | C1 |
| idnumber | 0001 |
| name | Test chat name |
| intro | Test chat description |
| section | 1 |
And I log in as "admin"
And I am on the "Course 1" "permissions" page
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I am on "Course 1" course homepage
And I follow "Test chat name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Repeat/publish session times | No repeats - publish the specified time only |
| id_chattime_day | 1 |
| id_chattime_month | 1 |
| id_chattime_year | 2017 |
And I press "Save and return to course"
And I log out
Scenario: Editing a chat
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test chat name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| id_chattime_year | 2018 |
And I press "Save and return to course"
Then I should see "Test chat name"
@@ -0,0 +1,48 @@
@mod @mod_chat @javascript
Feature: View past chat sessions
In order for students to view past chat sessions
As a teacher
I need to be able to change the mod/chat:readlog permission for students
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
| student1 | Student | One | student1@example.com |
And the following "course" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I enable "chat" "mod" plugin
Scenario Outline: View past chat sessions
# Display or hide past chat session based on example data
Given the following "activities" exist:
| activity | course | name | studentlogs |
| chat | C1 | Chat 1 | <studentlogvalue> |
And I am on the "Chat 1" "chat activity" page logged in as teacher1
# Display or hide past chat session by default based on mod/chat:readlog setting
And the following "role capability" exists:
| role | student |
| mod/chat:readlog | <readpermission> |
# Enter chat activity to create a session
And I click on "Enter the chat" "link"
# Close chat window
When I close all opened windows
And I reload the page
# Confirm that past chat sessions is always visible for teacher
Then I should see "Past sessions"
# Confirm past chat sessions visibility for student based on settings
And I am on the "Chat 1" "chat activity" page logged in as student1
And I <sessionvisibility> see "Past sessions"
# Regardless of studentlogvalue value if readpermission is allowed, then Past sessions will be visible for students
Examples:
| studentlogvalue | readpermission | sessionvisibility |
| 0 | allow | should |
| 1 | allow | should |
| 0 | prohibit | should not |
| 1 | prohibit | should |