first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace format_social\output;
use core_courseformat\output\section_renderer;
/**
* Renderer for outputting the social course format.
*
* @package format_social
* @copyright 2021 Ferran Recio <ferran@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends section_renderer {
}
@@ -0,0 +1,41 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for format_social.
*
* @package format_social
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace format_social\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for format_social implementing null_provider.
*
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+78
View File
@@ -0,0 +1,78 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Course format featuring social forum.
*
* @package format_social
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$pageno = optional_param('p', 0, PARAM_INT);
require_once($CFG->dirroot.'/mod/forum/lib.php');
$forum = forum_get_course_forum($course->id, 'social');
if (empty($forum)) {
echo $OUTPUT->notification('Could not find or create a social forum here');
}
$coursemodule = get_coursemodule_from_instance('forum', $forum->id);
$modcontext = context_module::instance($coursemodule->id);
$entityfactory = mod_forum\local\container::get_entity_factory();
$forumentity = $entityfactory->get_forum_from_stdclass($forum, $modcontext, $coursemodule, $course);
// Print forum intro above posts MDL-18483.
if (trim($forum->intro) != '') {
$options = (object) [
'para' => false,
];
$introcontent = format_module_intro('forum', $forum, $coursemodule->id);
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $modcontext)) {
$stredit = get_string('edit');
$introcontent .= html_writer::start_div('editinglink');
$introcontent .= html_writer::link(
new moodle_url('/course/modedit.php', [
'update' => $coursemodule->id,
'sesskey' => sesskey(),
]),
$OUTPUT->pix_icon('t/edit', $stredit),
[
'title' => $stredit,
]
);
$introcontent .= html_writer::end_div();
}
echo $OUTPUT->box($introcontent, 'generalbox', 'intro');
}
echo html_writer::div(forum_get_subscribe_link($forum, $modcontext), 'subscribelink');
$numdiscussions = course_get_format($course)->get_course()->numdiscussions;
if ($numdiscussions < 1) {
// Make sure that the value is at least one.
$numdiscussions = 1;
}
$rendererfactory = mod_forum\local\container::get_renderer_factory();
$discussionsrenderer = $rendererfactory->get_social_discussion_list_renderer($forumentity);
$cm = \cm_info::create($coursemodule);
echo $discussionsrenderer->render($USER, $cm, null, null, $pageno, $numdiscussions);
@@ -0,0 +1,31 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'format_social', language 'en', branch 'MOODLE_20_STABLE'
*
* @package format_social
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$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.';
+146
View File
@@ -0,0 +1,146 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains main class for the course format Social
*
* @since Moodle 2.0
* @package format_social
* @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot. '/course/format/lib.php');
/**
* Main class for the Social course format
*
* @package format_social
* @copyright 2012 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class format_social extends core_courseformat\base {
/**
* 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) ignored by this format
* 'sr' (int) ignored by this format
* @return null|moodle_url
*/
public function get_view_url($section, $options = array()) {
return new moodle_url('/course/view.php', ['id' => $this->courseid]);
}
/**
* 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
}
/**
* 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('social_activities')
);
}
/**
* 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;
}
/**
* Returns whether this course format allows the activity to
* have "triple visibility state" - visible always, hidden on course page but available, hidden.
*
* @param stdClass|cm_info $cm course module (may be null if we are displaying a form for adding a module)
* @param stdClass|section_info $section section where this module is located or will be added to
* @return bool
*/
public function allow_stealth_module_visibility($cm, $section) {
return true;
}
/**
* Return the plugin configs for external functions.
*
* @return array the list of configuration settings
* @since Moodle 3.5
*/
public function get_config_for_external() {
// Return everything (nothing to hide).
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() {
$ajaxsupport = new stdClass();
$ajaxsupport->capable = true;
return $ajaxsupport;
}
}
@@ -0,0 +1,54 @@
@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@example.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 the following "mod_forum > discussions" exist:
| user | forum | subject | message | created | timemodified |
| teacher1 | Social forum | Forum Post 10 | This is forum post ten | ##now +1 second## | ##now +1 second## |
| teacher1 | Social forum | Forum Post 9 | This is forum post nine | ##now +2 seconds## | ##now +2 seconds## |
| teacher1 | Social forum | Forum Post 8 | This is forum post eight | ##now +3 seconds## | ##now +3 seconds## |
| teacher1 | Social forum | Forum Post 7 | This is forum post seven | ##now +4 seconds## | ##now +4 seconds## |
| teacher1 | Social forum | Forum Post 6 | This is forum post six | ##now +5 seconds## | ##now +5 seconds## |
| teacher1 | Social forum | Forum Post 5 | This is forum post five | ##now +6 seconds## | ##now +6 seconds## |
| teacher1 | Social forum | Forum Post 4 | This is forum post four | ##now +7 seconds## | ##now +7 seconds## |
| teacher1 | Social forum | Forum Post 3 | This is forum post three | ##now +8 seconds## | ##now +8 seconds## |
| teacher1 | Social forum | Forum Post 2 | This is forum post two | ##now +9 seconds## | ##now +9 seconds## |
| teacher1 | Social forum | Forum Post 1 | This is forum post one | ##now +10 seconds## | ##now +10 seconds## |
And I am on the "C1" "course editing" page logged in as teacher1
Scenario: When number of discussions is decreased fewer discussions appear
Given I set the following fields to these values:
| numdiscussions | 5 |
When I press "Save and display"
Then I should see "This is forum post one"
And 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 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"
And I should not see "This is forum post ten"
Scenario: When number of discussions is increased more discussions appear
Given I set the following fields to these values:
| numdiscussions | 9 |
When I press "Save and display"
Then I should see "This is forum post one"
And 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"
@@ -0,0 +1,77 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace format_social;
/**
* Social course format related unit tests.
*
* @package format_social
* @copyright 2023 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \format_social
*/
class format_social_test extends \advanced_testcase {
/**
* Test for get_view_url().
*
* @covers ::get_view_url
*/
public function test_get_view_url(): void {
global $CFG;
$this->resetAfterTest();
// Generate a course with two sections (0 and 1) and two modules.
$generator = $this->getDataGenerator();
$course1 = $generator->create_course(['format' => 'social']);
course_create_sections_if_missing($course1, [0, 1]);
$data = (object)['id' => $course1->id];
$format = course_get_format($course1);
$format->update_course_format_options($data);
// In page.
$this->assertNotEmpty($format->get_view_url(null));
$this->assertNotEmpty($format->get_view_url(0));
$this->assertNotEmpty($format->get_view_url(1));
// Navigation.
$this->assertStringContainsString('course/view.php', $format->get_view_url(0));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1));
$this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['navigation' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['navigation' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['sr' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['sr' => 1]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['sr' => 0]));
$this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['sr' => 0]));
}
/**
* Test get_required_jsfiles().
*
* @covers ::get_required_jsfiles
*/
public function test_get_required_jsfiles(): void {
$this->resetAfterTest();
$generator = $this->getDataGenerator();
$course = $generator->create_course(['format' => 'social']);
$format = course_get_format($course);
$this->assertEmpty($format->get_required_jsfiles());
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
*
* @package format
* @subpackage social
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'format_social'; // Full name of the plugin (used for diagnostics)