Skip to content

Commit

Permalink
Merge branch 'MDL-46755_m29-2' of https://github.com/sbourget/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 27, 2015
2 parents 0d98b0f + 7ce40bc commit d927bc0
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 3 deletions.
7 changes: 6 additions & 1 deletion course/format/social/format.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@format @format_social
Feature: Change number of discussions displayed
In order to change the number of discussions displayed
As a teacher
I need to edit the course and change the number of sections displayed.

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
And the following "courses" exist:
| fullname | shortname | category | format |
| Course 1 | C1 | 0 | social |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 10 |
| Message | This is forum post ten |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 9 |
| Message | This is forum post nine |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 8 |
| Message | This is forum post eight |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 7 |
| Message | This is forum post seven |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 6 |
| Message | This is forum post six |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 5 |
| Message | This is forum post five |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 4 |
| Message | This is forum post four |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 3 |
| Message | This is forum post three |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 2 |
| Message | This is forum post two |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"
And I press "Add a new discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 1 |
| Message | This is forum post one |
And I press "Post to forum"
And I wait to be redirected
And I follow "Course 1"

Scenario: When number of discussions is decreased fewer discussions appear
Given I click on "Edit settings" "link" in the "Administration" "block"
And I set the following fields to these values:
| numdiscussions | 5 |
When I press "Save and display"
Then I should see "This is forum post five"
And I should not see "This is forum post six"

Scenario: When number of discussions is decreased to less than 1 only 1 discussion should appear
Given I click on "Edit settings" "link" in the "Administration" "block"
And I set the following fields to these values:
| numdiscussions | -1 |
When I press "Save and display"
Then I should see "This is forum post one"
And I should not see "This is forum post two"

Scenario: When number of discussions is increased more discussions appear
Given I click on "Edit settings" "link" in the "Administration" "block"
And I set the following fields to these values:
| numdiscussions | 9 |
When I press "Save and display"
Then I should see "This is forum post five"
And I should see "This is forum post nine"
And I should not see "This is forum post ten"
2 changes: 1 addition & 1 deletion course/format/social/version.php
Original file line number Diff line number Diff line change
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 d927bc0

Please sign in to comment.