MDL-35770 Converted social format to new course formats API
authorMarina Glancy <marina@moodle.com>
Wed, 14 Nov 2012 04:22:39 +0000 (12:22 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 14 Nov 2012 05:58:28 +0000 (13:58 +0800)
course/format/social/config.php [deleted file]
course/format/social/lib.php
course/format/social/version.php

diff --git a/course/format/social/config.php b/course/format/social/config.php
deleted file mode 100644 (file)
index ed05335..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-//
-// Optional course format configuration file
-//
-// This file contains any specific configuration settings for the
-// social format.
-//
-// The default blocks layout for this course format:
-    $format['defaultblocks'] = ':search_forums,calendar_upcoming,social_activities,recent_activity,course_list';
-
-
index 6a9629d..e645201 100644 (file)
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * This file contains general functions for the course format Social
+ * This file contains main class for the course format Social
  *
  *
- * @since 2.0
- * @package moodlecore
+ * @since     2.0
+ * @package   format_social
  * @copyright 2009 Sam Hemelryk
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
  * @copyright 2009 Sam Hemelryk
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 /**
- * Used to display the course structure for a course where format=social
+ * Main class for the Social course format
  *
  *
- * This is called automatically by {@link load_course()} if the current course
- * format = weeks.
- *
- * @param array $path An array of keys to the course node in the navigation
- * @param stdClass $modinfo The mod info object for the current course
- * @return bool Returns true
+ * @package    format_social
+ * @copyright  2012 Marina Glancy
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
  */
-function callback_social_load_content(&$navigation, $course, $coursenode) {
-    return $navigation->load_generic_course_sections($course, $coursenode, 'social');
-}
+class format_social extends format_base {
 
 
-/**
- * Used to display the course structure for a course where format=social
- *
- * This is called automatically by {@link load_course()} if the current course
- * format = weeks and the navigation was requested via AJAX
- *
- * @param array $path An array of keys to the course node in the navigation
- * @param stdClass $modinfo The mod info object for the current course
- * @return bool Returns true
- */
-function limited_load_section_social(&$navigation, $keys, $course, $section) {
-    $navigation->limited_load_section_generic($keys, $course, $section, get_string('social'), 'social');
-}
+    /**
+     * The URL to use for the specified course
+     *
+     * @param int|stdClass $section Section object from database or just field course_sections.section
+     *     if null the course view page is returned
+     * @param array $options options for view URL. At the moment core uses:
+     *     'navigation' (bool) if true and section has no separate page, the function returns null
+     *     'sr' (int) used by multipage formats to specify to which section to return
+     * @return null|moodle_url
+     */
+    public function get_view_url($section, $options = array()) {
+        if (!empty($options['navigation']) && $section !== null) {
+            return null;
+        }
+        return new moodle_url('/course/view.php', array('id' => $this->courseid));
+    }
 
 
-/**
- * Indicates this format uses sections.
- *
- * @return bool Returns true
- */
-function callback_social_uses_sections() {
-    return false;
-}
+    /**
+     * Loads all of the course sections into the navigation
+     *
+     * @param global_navigation $navigation
+     * @param navigation_node $node The course node within the navigation
+     */
+    public function extend_course_navigation($navigation, navigation_node $node) {
+        // Social course format does not extend navigation, it uses social_activities block instead
+    }
 
 
-/**
- * The string that is used to describe a section of the course
- * e.g. Topic, Week...
- *
- * @return string
- */
-function callback_social_definition() {
-    return get_string('topic');
-}
-
-/**
- * Toogle display of course contents (sections, activities)
- *
- * @return bool
- */
-function callback_social_display_content() {
-    return false;
+    /**
+     * Returns the list of blocks to be automatically added for the newly created course
+     *
+     * @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
+     *     each of values is an array of block names (for left and right side columns)
+     */
+    public function get_default_blocks() {
+        return array(
+            BLOCK_POS_LEFT => array(),
+            BLOCK_POS_RIGHT => array('search_forums', 'calendar_upcoming', 'social_activities',
+                'recent_activity', 'course_list')
+        );
+    }
 }
 }
-
-
index 7fe4f6a..2002e73 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires  = 2012061700;        // Requires this Moodle version
+$plugin->version   = 2012110900;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires  = 2012110900;        // Requires this Moodle version
 $plugin->component = 'format_social';   // Full name of the plugin (used for diagnostics)
 $plugin->component = 'format_social';   // Full name of the plugin (used for diagnostics)