Merge branch 'MDL-85404-500' of https://github.com/ferranrecio/moodle into MOODLE_500_STABLE

This commit is contained in:
Sara Arjona
2025-05-26 11:27:45 +02:00
3 changed files with 28 additions and 9 deletions
@@ -66,7 +66,9 @@
{{! The block should be fast to load, we only load the editor when needed.}}
{{#editing}}
require(['core_courseformat/local/content'], function(component) {
component.init('block_social_activities_section', {});
// We want to include both block content and block footer in the selector
// because the footer has the add activity button.
component.init('.block_social_activities', {});
});
{{/editing}}
{{/js}}
@@ -139,3 +139,20 @@ Feature: Edit activities in social activities block
And I open "Social forum" actions menu
And "Move right" "link" should be visible
And "Move left" "link" should not be visible
@javascript
Scenario: Social activities block can have subsections
Given the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Assignment name |
| section | 0 |
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I click on "Add content" "button" in the ".block_social_activities .footer" "css_element"
And I click on "Subsection" "link" in the ".dropdown-menu.show" "css_element"
Then I should see "New subsection" in the "Social activities" "block"
And I open "Assignment name" actions menu
And I click on "Move" "link" in the "Assignment name" activity
And I click on "New subsection" "link" in the "Move activity" "dialogue"
Then I should see "Assignment name" in the "New subsection" "section"
+8 -8
View File
@@ -151,6 +151,11 @@ class format_social extends core_courseformat\base {
#[\Override]
public function get_section_name($section) {
$section = $this->get_section($section);
if ($section->is_delegated()) {
return $section->name;
}
// Social format only uses one section inside the social activities block.
return get_string('socialactivities', 'format_social');
}
@@ -164,13 +169,6 @@ class format_social extends core_courseformat\base {
return 0;
}
#[\Override]
public function get_max_sections() {
// Social ony uses one section.
return 1;
}
/**
* Returns if a specific section is visible to the current user.
*
@@ -184,6 +182,8 @@ class format_social extends core_courseformat\base {
#[\Override]
public function is_section_visible(section_info $section): bool {
$visible = parent::is_section_visible($section);
return $visible && $section->section == 0;
// Social format does only use section 0 as a normal section.
// Any other included section should be a delegated one (subsections).
return $visible && ($section->sectionnum == 0 || $section->is_delegated());
}
}