+
{{#showsettings}}
{{/showsettings}}
-
+
{{#sections}}
{{> core_courseformat/local/content/section }}
{{/sections}}
+{{#js}}
+{{! The home page should be as fast as possible, we only load the editor when needed.}}
+{{#editing}}
+require(['core_courseformat/local/content'], function(component) {
+ component.init('courseformat-frontpage-main-topic', {});
+});
+{{/editing}}
+{{/js}}
diff --git a/course/format/tests/base_test.php b/course/format/tests/base_test.php
index 859355ca2b4..8af784aee93 100644
--- a/course/format/tests/base_test.php
+++ b/course/format/tests/base_test.php
@@ -997,6 +997,31 @@ class base_test extends advanced_testcase {
$this->assertFalse($format->is_section_visible($modinfostudent->get_section_info(2)));
}
+ /**
+ * Test for the get_generic_section_name method.
+ *
+ * @covers ::get_generic_section_name
+ */
+ public function test_get_generic_section_name(): void {
+ $this->resetAfterTest();
+
+ $generator = $this->getDataGenerator();
+ $course1 = $generator->create_course(['format' => 'topics']);
+ $course2 = $generator->create_course(['format' => 'theunittest']);
+
+ $format = course_get_format($course1);
+ $this->assertEquals(
+ get_string('sectionname', 'format_topics'),
+ $format->get_generic_section_name()
+ );
+
+ $format = course_get_format($course2);
+ $this->assertEquals(
+ get_string('section'),
+ $format->get_generic_section_name()
+ );
+ }
+
/**
* Test can_sections_be_removed_from_navigation().
*
diff --git a/course/lib.php b/course/lib.php
index 1d9265d3c3e..e526417dcb4 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -2867,7 +2867,7 @@ function include_course_editor(course_format $format) {
$course = $format->get_course();
- if ($SITE->id === $course->id) {
+ if (!$format->supports_ajax()?->capable) {
return;
}
diff --git a/course/resources.php b/course/resources.php
index 350c9bd65d7..43f053938f1 100644
--- a/course/resources.php
+++ b/course/resources.php
@@ -99,7 +99,8 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
diff --git a/course/section.php b/course/section.php
index 0fe81a5b6e2..e1f6162acbd 100644
--- a/course/section.php
+++ b/course/section.php
@@ -148,8 +148,8 @@ $editingtitle = '';
if ($PAGE->user_is_editing()) {
$editingtitle = 'editing';
}
-$sectionname = get_string('sectionname', "format_$course->format");
-$sectiontitle = get_section_name($course, $section);
+$sectionname = $format->get_generic_section_name();
+$sectiontitle = $format->get_section_name($section);
$PAGE->set_title(
get_string(
'coursesectiontitle' . $editingtitle,
diff --git a/course/tests/behat/frontpage_topic_section.feature b/course/tests/behat/frontpage_topic_section.feature
index 646bb1d1c8f..1f1fa00c3f1 100644
--- a/course/tests/behat/frontpage_topic_section.feature
+++ b/course/tests/behat/frontpage_topic_section.feature
@@ -42,3 +42,75 @@ Feature: Site home activities section
And I should see "New section description" in the "region-main" "region"
Then I turn editing mode off
And I should see "New section description" in the "region-main" "region"
+
+ @javascript
+ Scenario: Admin can change the activity visibility in the frontpage
+ Given the following config values are set as admin:
+ | allowstealth | 1 |
+ And the following "activities" exist:
+ | activity | course | section | name | intro | idnumber |
+ | assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 |
+ When I log in as "admin"
+ And I am on site homepage
+ And I turn editing mode on
+ And I should see "Frontpage assignment" in the "region-main" "region"
+ Then I open "Frontpage assignment" actions menu
+ And I choose "Availability > Make available but don't show on course page" in the open action menu
+ And I should see "Available but not shown on course page" in the "Frontpage assignment" "core_courseformat > Activity visibility"
+ And I open "Frontpage assignment" actions menu
+ And I choose "Availability > Show on course page" in the open action menu
+ And I should not see "Available but not shown on course page" in the "Frontpage assignment" "activity"
+ And I should not see "Hidden from students" in the "Frontpage assignment" "activity"
+ And I open "Frontpage assignment" actions menu
+ And I choose "Availability > Hide on course page" in the open action menu
+ And I should not see "Available but not shown on course page" in the "Frontpage assignment" "activity"
+ And I should see "Hidden from students" in the "Frontpage assignment" "core_courseformat > Activity visibility"
+
+ @javascript
+ Scenario: Admin can delete an activity in the frontpage
+ Given the following "activities" exist:
+ | activity | course | section | name | intro | idnumber |
+ | assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 |
+ When I log in as "admin"
+ And I am on site homepage
+ And I turn editing mode on
+ And I should see "Frontpage assignment" in the "region-main" "region"
+ Then I open "Frontpage assignment" actions menu
+ And I choose "Delete" in the open action menu
+ And I click on "Delete" "button" in the "Delete activity?" "dialogue"
+ And I should not see "Frontpage assignment" in the "region-main" "region"
+
+ @javascript
+ Scenario: Admin can duplicate an activity in the frontpage
+ Given the following "activities" exist:
+ | activity | course | section | name | intro | idnumber |
+ | assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 |
+ When I log in as "admin"
+ And I am on site homepage
+ And I turn editing mode on
+ And I should see "Frontpage assignment" in the "region-main" "region"
+ Then I open "Frontpage assignment" actions menu
+ And I choose "Duplicate" in the open action menu
+ And I should see "Frontpage assignment (copy)" in the "region-main" "region"
+
+ @javascript
+ Scenario: Admin can move an activity lefts and right in the frontpage
+ Given the following "activities" exist:
+ | activity | course | section | name | intro | idnumber |
+ | assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 |
+ | assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign1 |
+ And I log in as "admin"
+ And I am on site homepage
+ And I turn editing mode on
+ And I should see "Frontpage assignment" in the "region-main" "region"
+ When I open "Frontpage assignment" actions menu
+ And "Move right" "link" should be visible
+ And "Move left" "link" should not be visible
+ And I choose "Move right" in the open action menu
+ Then I open "Frontpage assignment" actions menu
+ And "Move right" "link" should not be visible
+ And "Move left" "link" should be visible
+ And I choose "Move left" in the open action menu
+ And I open "Frontpage assignment" actions menu
+ And "Move right" "link" should be visible
+ And "Move left" "link" should not be visible
diff --git a/course/view.php b/course/view.php
index 900607f0112..ecf7fa4ed9b 100644
--- a/course/view.php
+++ b/course/view.php
@@ -284,8 +284,8 @@ if ($PAGE->user_is_editing()) {
// If viewing a section, make the title more specific.
if ($section && $section > 0 && course_format_uses_sections($course->format)) {
- $sectionname = get_string('sectionname', "format_$course->format");
- $sectiontitle = get_section_name($course, $section);
+ $sectionname = $format->get_generic_section_name();
+ $sectiontitle = $format->get_section_name($section);
$PAGE->set_title(
get_string(
'coursesectiontitle' . $editingtitle,
diff --git a/index.php b/index.php
index b7076287727..801ffcf1dd3 100644
--- a/index.php
+++ b/index.php
@@ -109,6 +109,14 @@ $PAGE->set_title(get_string('home'));
$PAGE->set_heading($SITE->fullname);
$PAGE->set_secondary_active_tab('coursehome');
+$siteformatoptions = course_get_format($SITE)->get_format_options();
+$modinfo = get_fast_modinfo($SITE);
+$modnamesused = $modinfo->get_used_module_names();
+
+// The home page can have acitvities in the block aside. We should
+// initialize the course editor before the page structure is rendered.
+include_course_ajax($SITE, $modnamesused);
+
$courserenderer = $PAGE->get_renderer('core', 'course');
if ($hassiteconfig) {
@@ -119,10 +127,6 @@ if ($hassiteconfig) {
echo $OUTPUT->header();
-$siteformatoptions = course_get_format($SITE)->get_format_options();
-$modinfo = get_fast_modinfo($SITE);
-$modnamesused = $modinfo->get_used_module_names();
-
// Print Section or custom info.
if (!empty($CFG->customfrontpageinclude)) {
// Pre-fill some variables that custom front page might use.
@@ -135,8 +139,6 @@ if (!empty($CFG->customfrontpageinclude)) {
} else if ($siteformatoptions['numsections'] > 0) {
echo $courserenderer->frontpage_section1();
}
-// Include course AJAX.
-include_course_ajax($SITE, $modnamesused);
echo $courserenderer->frontpage();
diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php
index 46588ccbd1f..cd05752a2e8 100644
--- a/mod/assign/locallib.php
+++ b/mod/assign/locallib.php
@@ -3280,7 +3280,7 @@ class assign {
$modinfo = get_fast_modinfo($course);
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$sections = $modinfo->get_section_info_all();
}
$courseindexsummary = new assign_course_index_summary($usesections, $strsectionname);
diff --git a/mod/bigbluebuttonbn/classes/output/index.php b/mod/bigbluebuttonbn/classes/output/index.php
index 2bc8012bcbd..c57e6f875c9 100644
--- a/mod/bigbluebuttonbn/classes/output/index.php
+++ b/mod/bigbluebuttonbn/classes/output/index.php
@@ -61,7 +61,7 @@ class index implements renderable {
$table = new html_table();
if (course_format_uses_sections($this->course->format)) {
- $sectionheading = get_string('sectionname', "format_{$this->course->format}");
+ $sectionheading = course_get_format($this->course)->get_generic_section_name();
} else {
$sectionheading = '';
}
diff --git a/mod/book/index.php b/mod/book/index.php
index 3c91e8ed892..6fc2867c5b1 100644
--- a/mod/book/index.php
+++ b/mod/book/index.php
@@ -61,7 +61,7 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
diff --git a/mod/chat/index.php b/mod/chat/index.php
index be83bd57595..3c89547d889 100644
--- a/mod/chat/index.php
+++ b/mod/chat/index.php
@@ -62,7 +62,7 @@ $strname = get_string('name');
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname);
$table->align = array ('center', 'left');
} else {
@@ -103,4 +103,3 @@ echo html_writer::table($table);
// Finish the page.
echo $OUTPUT->footer();
-
diff --git a/mod/choice/index.php b/mod/choice/index.php
index 5616a1c89fa..2ed8ea84621 100644
--- a/mod/choice/index.php
+++ b/mod/choice/index.php
@@ -51,7 +51,7 @@
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, get_string("question"), get_string("answer"));
$table->align = array ("center", "left", "left");
} else {
@@ -103,5 +103,3 @@
echo html_writer::table($table);
echo $OUTPUT->footer();
-
-
diff --git a/mod/data/index.php b/mod/data/index.php
index b2c603c678e..8cbf07dad72 100644
--- a/mod/data/index.php
+++ b/mod/data/index.php
@@ -75,7 +75,7 @@ $strnumnotapproved = get_string('numnotapproved', 'data');
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strdescription, $strentries, $strnumnotapproved);
$table->align = array ('center', 'center', 'center', 'center', 'center');
} else {
@@ -149,4 +149,3 @@ foreach ($datas as $data) {
echo "
";
echo html_writer::tag('div', html_writer::table($table), array('class'=>'no-overflow'));
echo $OUTPUT->footer();
-
diff --git a/mod/feedback/index.php b/mod/feedback/index.php
index 704b74a4e46..3f582171f81 100644
--- a/mod/feedback/index.php
+++ b/mod/feedback/index.php
@@ -77,7 +77,7 @@ $strresponses = get_string('responses', 'feedback');
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
if (has_capability('mod/feedback:viewreports', $context)) {
$table->head = array ($strsectionname, $strname, $strresponses);
$table->align = array ("center", "left", 'center');
diff --git a/mod/folder/index.php b/mod/folder/index.php
index 7bafe8c1987..f5e567fedf3 100644
--- a/mod/folder/index.php
+++ b/mod/folder/index.php
@@ -66,7 +66,7 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
diff --git a/mod/forum/index.php b/mod/forum/index.php
index 0b2191c7c94..b16354094a6 100644
--- a/mod/forum/index.php
+++ b/mod/forum/index.php
@@ -349,7 +349,7 @@ if ($show_rss = (($showsubscriptioncolumns || $course->id == SITEID) &&
// Now let's process the learning forums.
if ($course->id != SITEID) { // Only real courses have learning forums
// 'format_.'$course->format only applicable when not SITEID (format_site is not a format)
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
// Add extra field for section number, at the front
array_unshift($learningtable->head, $strsectionname);
array_unshift($learningtable->align, 'center');
diff --git a/mod/glossary/index.php b/mod/glossary/index.php
index 50245774733..fafb91eb1ec 100644
--- a/mod/glossary/index.php
+++ b/mod/glossary/index.php
@@ -58,7 +58,7 @@ $strentries = get_string("entries", "glossary");
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strentries);
$table->align = array ('center', 'left', 'center');
} else {
@@ -139,4 +139,3 @@ echo html_writer::table($table);
/// Finish the page
echo $OUTPUT->footer();
-
diff --git a/mod/imscp/index.php b/mod/imscp/index.php
index f2c7257ceb7..2c78249cf28 100644
--- a/mod/imscp/index.php
+++ b/mod/imscp/index.php
@@ -61,7 +61,7 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
diff --git a/mod/lesson/index.php b/mod/lesson/index.php
index 3da15f96df3..10fed60a097 100644
--- a/mod/lesson/index.php
+++ b/mod/lesson/index.php
@@ -78,7 +78,7 @@ $strnodeadline = get_string("nodeadline", "lesson");
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strgrade, $strdeadline);
$table->align = array ("center", "left", "center", "center");
} else {
diff --git a/mod/lti/index.php b/mod/lti/index.php
index 1a0e97b6b62..f3582f41966 100644
--- a/mod/lti/index.php
+++ b/mod/lti/index.php
@@ -87,7 +87,7 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname);
$table->align = array ("center", "left");
} else {
diff --git a/mod/page/index.php b/mod/page/index.php
index 53138b2b945..108aa86f8f2 100644
--- a/mod/page/index.php
+++ b/mod/page/index.php
@@ -60,7 +60,7 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
diff --git a/mod/quiz/index.php b/mod/quiz/index.php
index 640bddaf3a9..766549c8933 100644
--- a/mod/quiz/index.php
+++ b/mod/quiz/index.php
@@ -74,7 +74,7 @@ array_push($headings, get_string('quizcloses', 'quiz'));
array_push($align, 'left');
if (course_format_uses_sections($course->format)) {
- array_unshift($headings, get_string('sectionname', 'format_'.$course->format));
+ array_unshift($headings, course_get_format($course)->get_generic_section_name());
} else {
array_unshift($headings, '');
}
diff --git a/mod/resource/index.php b/mod/resource/index.php
index 17598411545..e176a103a5e 100644
--- a/mod/resource/index.php
+++ b/mod/resource/index.php
@@ -41,7 +41,7 @@ $event->trigger();
$strresource = get_string('modulename', 'resource');
$strresources = get_string('modulenameplural', 'resource');
-$strsectionname = get_string('sectionname', 'format_'.$course->format);
+$strsectionname = course_get_format($course)->get_generic_section_name();
$strname = get_string('name');
$strintro = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');
diff --git a/mod/scorm/index.php b/mod/scorm/index.php
index 95e9f9da295..cca951a4991 100644
--- a/mod/scorm/index.php
+++ b/mod/scorm/index.php
@@ -65,7 +65,7 @@ if (! $scorms = get_all_instances_in_course("scorm", $course)) {
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strsummary, $strreport);
$table->align = array ("center", "left", "left", "left");
} else {
@@ -116,4 +116,4 @@ echo html_writer::empty_tag('br');
echo html_writer::table($table);
-echo $OUTPUT->footer();
\ No newline at end of file
+echo $OUTPUT->footer();
diff --git a/mod/survey/index.php b/mod/survey/index.php
index edbdf079d74..f979543b6c7 100644
--- a/mod/survey/index.php
+++ b/mod/survey/index.php
@@ -44,7 +44,7 @@
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strstatus);
} else {
$table->head = array ($strname, $strstatus);
@@ -89,5 +89,3 @@
echo "
";
echo html_writer::table($table);
echo $OUTPUT->footer();
-
-
diff --git a/mod/url/index.php b/mod/url/index.php
index 869eed21a3e..e44411e55e2 100644
--- a/mod/url/index.php
+++ b/mod/url/index.php
@@ -65,7 +65,7 @@ $table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname, $strintro);
$table->align = array ('center', 'left', 'left');
} else {
diff --git a/mod/wiki/index.php b/mod/wiki/index.php
index b9039bb8aff..0bdcc8b4c69 100644
--- a/mod/wiki/index.php
+++ b/mod/wiki/index.php
@@ -75,7 +75,7 @@ $strname = get_string("name");
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_' . $course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array($strsectionname, $strname);
} else {
$table->head = array($strname);
diff --git a/mod/workshop/index.php b/mod/workshop/index.php
index eba17ae1627..281a526ebf2 100644
--- a/mod/workshop/index.php
+++ b/mod/workshop/index.php
@@ -63,7 +63,7 @@ $strname = get_string('name');
$table = new html_table();
if ($usesections) {
- $strsectionname = get_string('sectionname', 'format_'.$course->format);
+ $strsectionname = course_get_format($course)->get_generic_section_name();
$table->head = array ($strsectionname, $strname);
$table->align = array ('center', 'left');
} else {