Skip to content

Commit

Permalink
MDL-82351 format_social: migrate to reactive course editor
Browse files Browse the repository at this point in the history
The commit adds all the necessary methods to allow social format to use
the course editor. The code is similar to the one used in the frontpage
format. The commit does not include the migration of the
social_activities blocks.
  • Loading branch information
ferranrecio committed Oct 25, 2024
1 parent 4394c38 commit 9f544e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
5 changes: 4 additions & 1 deletion course/format/social/lang/en/format_social.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['hidefromothers'] = 'Hide';
$string['numberdiscussions'] = 'Number of discussions';
$string['numberdiscussions_help'] = 'This setting specifies how many discussions should be displayed.';
$string['pluginname'] = 'Social';
$string['plugin_description'] = 'The course is centred around a main forum on the course page. Additional activities and resources can be added using the Social activities block.';
$string['sectionname'] = 'section';
$string['privacy:metadata'] = 'The Social format plugin does not store any personal data.';
$string['sectionname'] = 'section';
$string['socialactivities'] = 'Social activities';
$string['showfromothers'] = 'Show';
40 changes: 31 additions & 9 deletions course/format/social/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,40 @@ public function get_config_for_external() {
return $this->get_format_options();
}

/**
* Returns the information about the ajax support in the given source format.
*
* The returned object's property (boolean)capable indicates that
* the course format supports Moodle course ajax features.
*
* @return stdClass
*/
public function supports_ajax() {
// All home page is rendered in the backend, we only need an ajax editor components in edit mode.
// This will also prevent redirectng to the login page when a guest tries to access the site,
// and will make the home page loading faster.
$ajaxsupport = new stdClass();
$ajaxsupport->capable = true;
$ajaxsupport->capable = $this->show_editor();
return $ajaxsupport;
}

public function supports_components() {
return true;
}

public function uses_sections() {
return true;
}

public function get_section_name($section) {
return get_string('socialactivities', 'format_social');
}

/**
* Social format uses only section 0.
*
* @return int
*/
public function get_sectionnum(): int {
return 0;
}


#[\Override]
public function get_max_sections() {
// Social ony uses one section.
return 1;
}
}

0 comments on commit 9f544e7

Please sign in to comment.