Skip to content

Commit

Permalink
MDL-46755 format_social: Make discussion count configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourget committed Jan 21, 2015
1 parent da0ef2e commit 0d67ac8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
7 changes: 6 additions & 1 deletion course/format/social/format.php
Expand Up @@ -30,7 +30,12 @@
}

echo '<div class="subscribelink">', forum_get_subscribe_link($forum, $modcontext), '</div>';
forum_print_latest_discussions($course, $forum, 10, 'plain', '', false);

$numdiscussions = course_get_format($course)->get_course()->numdiscussions;
if ($numdiscussions < 1) {
$numdiscussions = 1; // Make sure that the value is at least zero.
}
forum_print_latest_discussions($course, $forum, $numdiscussions, 'plain', '', false);

} else {
echo $OUTPUT->notification('Could not find or create a social forum here');
Expand Down
4 changes: 3 additions & 1 deletion course/format/social/lang/en/format_social.php
Expand Up @@ -23,5 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['sectionname'] = 'section';
$string['numberdiscussions'] = 'Number of discussions';
$string['numberdiscussions_help'] = 'This setting specifies how many discussions should be dispalyed.';
$string['pluginname'] = 'Social format';
$string['sectionname'] = 'section';
34 changes: 34 additions & 0 deletions course/format/social/lib.php
Expand Up @@ -75,4 +75,38 @@ public function get_default_blocks() {
'recent_activity', 'course_list')
);
}

/**
* Definitions of the additional options that this course format uses for course
*
* social format uses the following options:
* - numdiscussions
*
* @param bool $foreditform
* @return array of options
*/
public function course_format_options($foreditform = false) {
static $courseformatoptions = false;
if ($courseformatoptions === false) {
$courseformatoptions = array(
'numdiscussions' => array(
'default' => 10,
'type' => PARAM_INT,
)
);
}

if ($foreditform && !isset($courseformatoptions['numdiscussions']['label'])) {
$courseformatoptionsedit = array(
'numdiscussions' => array(
'label' => new lang_string('numberdiscussions', 'format_social'),
'help' => 'numberdiscussions',
'help_component' => 'format_social',
'element_type' => 'text',
)
);
$courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
}
return $courseformatoptions;
}
}
2 changes: 1 addition & 1 deletion course/format/social/version.php
Expand Up @@ -25,6 +25,6 @@

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

$plugin->version = 2014111000; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2015102100; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2014110400; // Requires this Moodle version
$plugin->component = 'format_social'; // Full name of the plugin (used for diagnostics)

0 comments on commit 0d67ac8

Please sign in to comment.