mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
MDL-71779 core_courseformat: reactive add and delete sections
This commit is contained in:
parent
a9d44b0f75
commit
3d2a6eacae
57 changed files with 883 additions and 140 deletions
45
course/format/topics/classes/output/courseformat/content.php
Normal file
45
course/format/topics/classes/output/courseformat/content.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains the default content output class.
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace format_topics\output\courseformat;
|
||||
|
||||
use core_courseformat\output\local\content as content_base;
|
||||
|
||||
/**
|
||||
* Base class to render a course content.
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class content extends content_base {
|
||||
|
||||
/**
|
||||
* @var bool Topic format has add section after each topic.
|
||||
*
|
||||
* The responsible for the buttons is core_courseformat\output\local\content\section.
|
||||
*/
|
||||
protected $hasaddsection = false;
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains the default section controls output class.
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace format_topics\output\courseformat\content;
|
||||
|
||||
use core_courseformat\base as course_format;
|
||||
use core_courseformat\output\local\content\section as section_base;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Base class to render a course section.
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class section extends section_base {
|
||||
|
||||
/** @var course_format the course format */
|
||||
protected $format;
|
||||
|
||||
public function export_for_template(\renderer_base $output): stdClass {
|
||||
$format = $this->format;
|
||||
|
||||
$data = parent::export_for_template($output);
|
||||
|
||||
if (!$this->format->get_section_number()) {
|
||||
$addsectionclass = $format->get_output_classname('content\\addsection');
|
||||
$addsection = new $addsectionclass($format);
|
||||
$data->numsections = $addsection->export_for_template($output);
|
||||
$data->insertafter = true;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['addsections'] = 'Add topics';
|
||||
$string['addsections'] = 'Add topic after';
|
||||
$string['currentsection'] = 'This topic';
|
||||
$string['editsection'] = 'Edit topic';
|
||||
$string['editsectionname'] = 'Edit topic name';
|
||||
|
|
|
@ -29,10 +29,11 @@ Feature: Sections can be edited and deleted in topics format
|
|||
And the field "New value for Section name" matches value "General"
|
||||
|
||||
Scenario: Edit the default name of the general section in topics format
|
||||
Given I should see "General" in the "General" "section"
|
||||
When I edit the section "0" and I fill the form with:
|
||||
| Custom | 1 |
|
||||
| New value for Section name | This is the general section |
|
||||
Then I should see "This is the general section" in the "li#section-0" "css_element"
|
||||
Then I should see "This is the general section" in the "This is the general section" "section"
|
||||
|
||||
Scenario: View the default name of the second section in topics format
|
||||
When I edit the section "2"
|
||||
|
@ -42,24 +43,24 @@ Feature: Sections can be edited and deleted in topics format
|
|||
Scenario: Edit section summary in topics format
|
||||
When I edit the section "2" and I fill the form with:
|
||||
| Summary | Welcome to section 2 |
|
||||
Then I should see "Welcome to section 2" in the "li#section-2" "css_element"
|
||||
Then I should see "Welcome to section 2" in the "Topic 2" "section"
|
||||
|
||||
Scenario: Edit section default name in topics format
|
||||
When I edit the section "2" and I fill the form with:
|
||||
| Custom | 1 |
|
||||
| New value for Section name | This is the second topic |
|
||||
Then I should see "This is the second topic" in the "li#section-2" "css_element"
|
||||
And I should not see "Topic 2" in the "li#section-2" "css_element"
|
||||
Then I should see "This is the second topic" in the "This is the second topic" "section"
|
||||
And I should not see "Topic 2" in the "region-main" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: Inline edit section name in topics format
|
||||
When I set the field "Edit topic name" in the "li#section-1" "css_element" to "Midterm evaluation"
|
||||
When I set the field "Edit topic name" in the "Topic 1" "section" to "Midterm evaluation"
|
||||
Then I should not see "Topic 1" in the "region-main" "region"
|
||||
And "New name for topic" "field" should not exist
|
||||
And I should see "Midterm evaluation" in the "li#section-1" "css_element"
|
||||
And I should see "Midterm evaluation" in the "Midterm evaluation" "section"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should not see "Topic 1" in the "region-main" "region"
|
||||
And I should see "Midterm evaluation" in the "li#section-1" "css_element"
|
||||
And I should see "Midterm evaluation" in the "Midterm evaluation" "section"
|
||||
|
||||
Scenario: Deleting the last section in topics format
|
||||
When I delete section "5"
|
||||
|
@ -73,20 +74,18 @@ Feature: Sections can be edited and deleted in topics format
|
|||
And I press "Delete"
|
||||
Then I should not see "Topic 5"
|
||||
And I should not see "Test chat name"
|
||||
And I should see "Test choice name" in the "li#section-4" "css_element"
|
||||
And I should see "Test choice name" in the "Topic 4" "section"
|
||||
And I should see "Topic 4"
|
||||
|
||||
@javascript
|
||||
Scenario: Adding sections in topics format
|
||||
When I follow "Add topics"
|
||||
Then the field "Number of sections" matches value "1"
|
||||
And I press "Add topics"
|
||||
And I should see "Topic 6" in the "li#section-6" "css_element"
|
||||
And "li#section-7" "css_element" should not exist
|
||||
And I follow "Add topics"
|
||||
And I set the field "Number of sections" to "3"
|
||||
And I press "Add topics"
|
||||
And I should see "Topic 7" in the "li#section-7" "css_element"
|
||||
And I should see "Topic 8" in the "li#section-8" "css_element"
|
||||
And I should see "Topic 9" in the "li#section-9" "css_element"
|
||||
And "li#section-10" "css_element" should not exist
|
||||
Scenario: Adding sections at the end of a topics format
|
||||
When I click on "Add topic after" "link" in the "Topic 5" "section"
|
||||
Then I should see "Topic 6" in the "Topic 6" "section"
|
||||
And I should see "Test choice name" in the "Topic 5" "section"
|
||||
|
||||
@javascript
|
||||
Scenario: Adding sections between topics in topics format
|
||||
When I click on "Add topic after" "link" in the "Topic 4" "section"
|
||||
Then I should see "Topic 6" in the "Topic 6" "section"
|
||||
And I should not see "Test choice name" in the "Topic 5" "section"
|
||||
And I should see "Test choice name" in the "Topic 6" "section"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue