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,88 @@
@format @format_singleactivity
Feature: Activity navigation in a single activity course
In order to quickly switch to another activity in a single activity course with multiple (hidden) activities
As a teacher
I need to use the activity navigation controls in activities
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname | format | activitytype |
| Course 1 | C1 | singleactivity | forum |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| assign | Assignment 1 | Test assignment description | C1 | assign1 | 0 |
| lesson | Lesson 1 | Test lesson description | C1 | lesson1 | 0 |
| forum | Forum 1 | Test forum description | C1 | forum1 | 0 |
Scenario: Step through hidden activities in the course as a teacher.
Given I log in as "teacher1"
When I am on "Course 1" course homepage
# The first activity (Forum 1) won't have the previous activity link.
Then "#prev-activity-link" "css_element" should not exist
And I should see "Assignment 1 (hidden)" in the "#next-activity-link" "css_element"
And I follow "Assignment 1 (hidden)"
And I should see "Forum 1" in the "#prev-activity-link" "css_element"
And I should see "Lesson 1 (hidden)" in the "#next-activity-link" "css_element"
And I follow "Lesson 1 (hidden)"
And I should see "Assignment 1 (hidden)" in the "#prev-activity-link" "css_element"
And "#next-activity-link" "css_element" should not exist
Scenario: Jump to a hidden activity as a teacher
Given I log in as "teacher1"
When I am on "Course 1" course homepage
Then "Jump to..." "field" should exist
# The current activity (Forum 1) will not be listed.
And the "Jump to..." select box should not contain "Forum 1"
# Check drop down menu contents.
And the "Jump to..." select box should contain "Assignment 1 (hidden)"
And the "Jump to..." select box should contain "Lesson 1 (hidden)"
# Jump to a hidden activity somewhere in the middle.
When I select "Assignment 1 (hidden)" from the "Jump to..." singleselect
Then I should see "Assignment 1"
And I should see "Forum 1" in the "#prev-activity-link" "css_element"
And I should see "Lesson 1 (hidden)" in the "#next-activity-link" "css_element"
# Jump to the first activity.
And I select "Forum 1" from the "Jump to..." singleselect
And I should see "Assignment 1 (hidden)" in the "#next-activity-link" "css_element"
But "#prev-activity-link" "css_element" should not exist
# Jump to the last activity.
And I select "Lesson 1 (hidden)" from the "Jump to..." singleselect
And I should see "Assignment 1 (hidden)" in the "#prev-activity-link" "css_element"
But "#next-activity-link" "css_element" should not exist
Scenario: The activity navigation controls are not available as a student.
Given I log in as "student1"
And I am on "Course 1" course homepage
# The first activity won't have the previous activity link.
Then "#prev-activity-link" "css_element" should not exist
And "#next-activity-link" "css_element" should not exist
And "Jump to..." "field" should not exist
Scenario: The activity navigation asks for login to guest user
Given I log in as "guest"
When I am on "Course 1" course homepage
Then I should see "Guests cannot access this course. Please log in"
Scenario: The activity navigation asks for login to not enrolled user
Given I log in as "student2"
When I am on "Course 1" course homepage
Then I should see "You cannot enrol yourself in this course"
Scenario: The single activity course format supports multilang course names
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
When I am on the "Course 1" "course editing" page logged in as "teacher1"
And I expand all fieldsets
And I set the field "Course full name" in the "General" "fieldset" to "<span lang=\"de\" class=\"multilang\">Kurs</span><span lang=\"en\" class=\"multilang\">Course</span> 1"
And I click on "Save and display" "button"
Then I should see "Course 1" in the ".page-header-headings" "css_element"
And I should not see "KursCourse 1" in the ".page-header-headings" "css_element"
@@ -0,0 +1,36 @@
@format @format_singleactivity
Feature: Courses can be created in Single Activity mode
In order to create a single activity course
As a manager
I need to create courses and set default values on them
Scenario: Create a course as a custom course creator
Given the following "users" exist:
| username | firstname | lastname | email |
| kevin | Kevin | the | kevin@example.com |
And the following "roles" exist:
| shortname | name | archetype |
| creator | Creator | |
And the following "system role assigns" exist:
| user | role | contextlevel |
| kevin | creator | System |
And the following "role capability" exists:
| role | creator |
| moodle/course:create | allow |
| moodle/course:update | allow |
| moodle/course:manageactivities | allow |
| moodle/course:viewparticipants | allow |
| moodle/role:assign | allow |
When I log in as "kevin"
And I am on site homepage
And I press "Add a new course"
And I set the following fields to these values:
| Course full name | My first course |
| Course short name | myfirstcourse |
| Format | Single activity |
And I press "Update format"
Then I should see "Quiz" in the "Type of activity" "field"
And I should see "Forum" in the "Type of activity" "field"
And I set the field "Type of activity" to "Quiz"
And I press "Save and display"
And I should see "New Quiz"
@@ -0,0 +1,27 @@
@format @format_singleactivity
Feature: Edit format course to Single Activity format
In order to set the format course to single activity course
As a teacher
I need to edit the course settings and see the dropdown type activity
Scenario: Edit a format course as a teacher
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | summary | format |
| Course 1 | C1 | <p>Course summary</p> | topics |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage
When I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Course full name | My first course |
| Course short name | myfirstcourse |
| Format | Single activity |
And I press "Update format"
Then I should see "Forum" in the "Type of activity" "field"
And I press "Save and display"
And I should see "New Forum"
@@ -0,0 +1,77 @@
<?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 format_singleactivity;
/**
* Single activity course format related unit tests.
*
* @package format_singleactivity
* @copyright 2023 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \format_singleactivity
*/
class format_singleactivity_test extends \advanced_testcase {
/**
* Test for get_view_url().
*
* @covers ::get_view_url
*/
public function test_get_view_url(): void {
global $CFG;
$this->resetAfterTest();
// Generate a course with two sections (0 and 1) and two modules.
$generator = $this->getDataGenerator();
$course1 = $generator->create_course(['format' => 'singleactivity']);
course_create_sections_if_missing($course1, [0, 1]);
$data = (object)['id' => $course1->id];
$format = course_get_format($course1);
$format->update_course_format_options($data);
// In page.
$this->assertNotEmpty($format->get_view_url(null));
$this->assertNotEmpty($format->get_view_url(0));
$this->assertNotEmpty($format->get_view_url(1));
// Navigation.
$this->assertStringContainsString('course/view.php', $format->get_view_url(0));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1));
$this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['navigation' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['navigation' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['sr' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['sr' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['sr' => 0]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['sr' => 0]));
}
/**
* Test get_required_jsfiles().
*
* @covers ::get_required_jsfiles
*/
public function test_get_required_jsfiles(): void {
$this->resetAfterTest();
$generator = $this->getDataGenerator();
$course = $generator->create_course(['format' => 'singleactivity']);
$format = course_get_format($course);
$this->assertEmpty($format->get_required_jsfiles());
}
}