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,54 @@
@format @format_social
Feature: Change number of discussions displayed
In order to change the number of discussions displayed
As a teacher
I need to edit the course and change the number of sections displayed.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category | format |
| Course 1 | C1 | 0 | social |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "mod_forum > discussions" exist:
| user | forum | subject | message | created | timemodified |
| teacher1 | Social forum | Forum Post 10 | This is forum post ten | ##now +1 second## | ##now +1 second## |
| teacher1 | Social forum | Forum Post 9 | This is forum post nine | ##now +2 seconds## | ##now +2 seconds## |
| teacher1 | Social forum | Forum Post 8 | This is forum post eight | ##now +3 seconds## | ##now +3 seconds## |
| teacher1 | Social forum | Forum Post 7 | This is forum post seven | ##now +4 seconds## | ##now +4 seconds## |
| teacher1 | Social forum | Forum Post 6 | This is forum post six | ##now +5 seconds## | ##now +5 seconds## |
| teacher1 | Social forum | Forum Post 5 | This is forum post five | ##now +6 seconds## | ##now +6 seconds## |
| teacher1 | Social forum | Forum Post 4 | This is forum post four | ##now +7 seconds## | ##now +7 seconds## |
| teacher1 | Social forum | Forum Post 3 | This is forum post three | ##now +8 seconds## | ##now +8 seconds## |
| teacher1 | Social forum | Forum Post 2 | This is forum post two | ##now +9 seconds## | ##now +9 seconds## |
| teacher1 | Social forum | Forum Post 1 | This is forum post one | ##now +10 seconds## | ##now +10 seconds## |
And I am on the "C1" "course editing" page logged in as teacher1
Scenario: When number of discussions is decreased fewer discussions appear
Given I set the following fields to these values:
| numdiscussions | 5 |
When I press "Save and display"
Then I should see "This is forum post one"
And I should see "This is forum post five"
And I should not see "This is forum post six"
Scenario: When number of discussions is decreased to less than 1 only 1 discussion should appear
Given I set the following fields to these values:
| numdiscussions | -1 |
When I press "Save and display"
Then I should see "This is forum post one"
And I should not see "This is forum post two"
And I should not see "This is forum post ten"
Scenario: When number of discussions is increased more discussions appear
Given I set the following fields to these values:
| numdiscussions | 9 |
When I press "Save and display"
Then I should see "This is forum post one"
And I should see "This is forum post five"
And I should see "This is forum post nine"
And I should not see "This is forum post ten"
@@ -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_social;
/**
* Social course format related unit tests.
*
* @package format_social
* @copyright 2023 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \format_social
*/
class format_social_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' => 'social']);
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' => 'social']);
$format = course_get_format($course);
$this->assertEmpty($format->get_required_jsfiles());
}
}