Skip to content

Commit ace97b5

Browse files
authored
Merge pull request davidherney#246 from davidherney/master
Fixed: davidherney#243. New subtopic visibility test.
2 parents 541cbda + 2ba1a1d commit ace97b5

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

lang/es/format_onetopic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
$string['tablabelhighlighted'] = 'Resaltada';
137137
$string['tablabelparent'] = 'Padre';
138138
$string['tabsectionbackground'] = 'Fondo del contenido de la sección';
139-
$string['tabsectionbackground_help'] = 'Se utiliza para cambiar el fondo del contenido de la sección. El valor puede ser un color en una representación válida de CSS, por ejemplo: <ul><li>Hexadecimal: #ffffff</li><li>RGB: rgb(0,255,0)</li><li>Nombre: verde</li></ul>
139+
$string['tabsectionbackground_help'] = 'Se utiliza para cambiar el fondo del contenido de la sección. El valor puede ser un color en una representación válida de CSS, por ejemplo: <ul><li>Hexadecimal: #ffffff</li><li>RGB: rgb(0,255,0)</li><li>Nombre: green</li></ul>
140140
También puede ser un atributo de URL y otras opciones de fondo de CSS.';
141141
$string['tabstylebuttons_help'] = 'Haga clic en cada botón para configurar la apariencia de la pestaña en cada uno de sus posibles estados.';
142142
$string['tabstyleclear'] = 'Borrar estilos';

lib.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,9 +1203,14 @@ public function fot_get_sections_extra() {
12031203
* @param string $availableinfo the 'availableinfo' propery of the section_info as it was evaluated by conditional availability.
12041204
*/
12051205
public function section_get_available_hook(section_info $section, &$available, &$availableinfo) {
1206+
try {
1207+
$level = $section->level;
1208+
} catch (Exception $notused) {
1209+
return;
1210+
}
12061211

12071212
// Only check childs tabs visibility.
1208-
if (!property_exists($section, 'level') || $section->level == 0) {
1213+
if (empty($level)) {
12091214
return;
12101215
}
12111216

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@format @format_onetopic
2+
Feature: Testing subtopics_visibility in format_onetopic
3+
In order to keep subtopics aligned with their parents
4+
As a student I should not see subtopics of hidden parent sections
5+
6+
Background:
7+
Given the following "users" exist:
8+
| username | firstname | lastname | email |
9+
| teacher1 | Teacher | 1 | teacher1@example.com |
10+
| student1 | Student | 1 | student1@example.com |
11+
And the following "courses" exist:
12+
| fullname | shortname | format | coursedisplay | numsections | hiddensections |
13+
| Course 1 | C1 | onetopic | 0 | 5 | 1 |
14+
And the following "course enrolments" exist:
15+
| user | course | role |
16+
| teacher1 | C1 | editingteacher |
17+
| student1 | C1 | student |
18+
And I log in as "teacher1"
19+
20+
@javascript
21+
Scenario: Subtopics of hidden parent sections are not visible to students
22+
Given I am on "Course 1" course homepage with editing mode on
23+
When I click on "Topic 2" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
24+
And I edit the section "2" and I fill the form with:
25+
| Level | Child of previous tab |
26+
And I click on "Topic 4" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
27+
And I edit the section "4" and I fill the form with:
28+
| Level | Child of previous tab |
29+
And I click on "Topic 3" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
30+
And I open section "3" edit menu
31+
And I click on "Hide" "link"
32+
And I log out
33+
When I log in as "student1"
34+
And I am on "Course 1" course homepage
35+
And I click on "Topic 1" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
36+
Then I should see "Topic 2" in the "#page-content .onetopic-tab-body" "css_element"
37+
And I should not see "Topic 4" in the "#page-content .onetopic-tab-body" "css_element"

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
defined('MOODLE_INTERNAL') || die();
3535

36-
$plugin->version = 2025021903; // The current plugin version (Date: YYYYMMDDXX).
36+
$plugin->version = 2025021903.01; // The current plugin version (Date: YYYYMMDDXX).
3737
$plugin->requires = 2025021400; // Requires this Moodle version.
3838
$plugin->component = 'format_onetopic'; // Full name of the plugin (used for diagnostics).
3939
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)