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
+157
View File
@@ -0,0 +1,157 @@
<?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/>.
/**
* Recent Blog Entries Block page.
*
* @package block_blog_recent
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* This block simply outputs a list of links to recent blog entries, depending on
* the context of the current page.
*/
class block_blog_recent extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_blog_recent');
$this->content_type = BLOCK_TYPE_TEXT;
}
function applicable_formats() {
return array('all' => true, 'my' => false, 'tag' => false);
}
function instance_allow_config() {
return true;
}
function get_content() {
global $CFG;
if ($this->content !== NULL) {
return $this->content;
}
// verify blog is enabled
if (empty($CFG->enableblogs)) {
$this->content = new stdClass();
$this->content->text = '';
if ($this->page->user_is_editing()) {
$this->content->text = get_string('blogdisable', 'blog');
}
return $this->content;
} else if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL and (!isloggedin() or isguestuser())) {
$this->content = new stdClass();
$this->content->text = '';
return $this->content;
}
require_once($CFG->dirroot .'/blog/lib.php');
require_once($CFG->dirroot .'/blog/locallib.php');
if (empty($this->config)) {
$this->config = new stdClass();
}
if (empty($this->config->recentbloginterval)) {
$this->config->recentbloginterval = 8400;
}
if (empty($this->config->numberofrecentblogentries)) {
$this->config->numberofrecentblogentries = 4;
}
$this->content = new stdClass();
$this->content->footer = '';
$this->content->text = '';
$context = $this->page->context;
$url = new moodle_url('/blog/index.php');
$filter = array();
if ($context->contextlevel == CONTEXT_MODULE) {
$filter['module'] = $context->instanceid;
$a = new stdClass;
$a->type = get_string('modulename', $this->page->cm->modname);
$strview = get_string('viewallmodentries', 'blog', $a);
$url->param('modid', $context->instanceid);
} else if ($context->contextlevel == CONTEXT_COURSE) {
$filter['course'] = $context->instanceid;
$a = new stdClass;
$a->type = get_string('course');
$strview = get_string('viewblogentries', 'blog', $a);
$url->param('courseid', $context->instanceid);
} else {
$strview = get_string('viewsiteentries', 'blog');
}
$filter['since'] = $this->config->recentbloginterval;
$bloglisting = new blog_listing($filter);
$entries = $bloglisting->get_entries(0, $this->config->numberofrecentblogentries, 4);
if (!empty($entries)) {
$entrieslist = array();
$viewblogurl = new moodle_url('/blog/index.php');
foreach ($entries as $entryid => $entry) {
$viewblogurl->param('entryid', $entryid);
$entrylink = html_writer::link($viewblogurl, shorten_text(format_string($entry->subject, true,
['context' => $context])));
$entrieslist[] = $entrylink;
}
$this->content->text .= html_writer::alist($entrieslist, array('class'=>'list'));
$viewallentrieslink = html_writer::link($url, $strview);
$this->content->text .= $viewallentrieslink;
} else {
$this->content->text .= get_string('norecentblogentries', 'block_blog_recent');
}
}
/**
* Return the plugin config settings for external functions.
*
* @return stdClass the configs for both the block instance and plugin
* @since Moodle 3.8
*/
public function get_config_for_external() {
// Return all settings for all users since it is safe (no private keys, etc..).
$configs = !empty($this->config) ? $this->config : new stdClass();
return (object) [
'instance' => $configs,
'plugin' => new stdClass(),
];
}
/**
* This block shouldn't be added to a page if the blogs advanced feature is disabled.
*
* @param moodle_page $page
* @return bool
*/
public function can_block_be_added(moodle_page $page): bool {
global $CFG;
return $CFG->enableblogs;
}
}
@@ -0,0 +1,46 @@
<?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 block_blog_recent.
*
* @package block_blog_recent
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_blog_recent\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_blog_recent implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@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';
}
}
+41
View File
@@ -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/>.
/**
* Blog recent block caps.
*
* @package block_blog_recent
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/blog_recent:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
+61
View File
@@ -0,0 +1,61 @@
<?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/>.
/**
* Form for editing tag block instances.
*
* @package block_blog_recent
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Form for editing tag block instances.
*
* @package block_blog_recent
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_blog_recent_edit_form extends block_edit_form {
protected function specific_definition($mform) {
// Fields for editing HTML block title and contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$numberofentries = array();
for ($i = 1; $i <= 20; $i++) {
$numberofentries[$i] = $i;
}
$mform->addElement('select', 'config_numberofrecentblogentries', get_string('numentriestodisplay', 'block_blog_recent'), $numberofentries);
$mform->setDefault('config_numberofrecentblogentries', 4);
$intervals = array(
7200 => get_string('numhours', '', 2),
14400 => get_string('numhours', '', 4),
21600 => get_string('numhours', '', 6),
43200 => get_string('numhours', '', 12),
86400 => get_string('numhours', '', 24),
172800 => get_string('numdays', '', 2),
604800 => get_string('numdays', '', 7)
);
$mform->addElement('select', 'config_recentbloginterval', get_string('recentinterval', 'block_blog_recent'), $intervals);
$mform->setDefault('config_recentbloginterval', 86400);
}
}
@@ -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 'block_blog_recent', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_blog_recent
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['blog_recent:addinstance'] = 'Add a new recent blog entries block';
$string['norecentblogentries'] = 'No recent entries';
$string['numentriestodisplay'] = 'Number of recent entries to display';
$string['pluginname'] = 'Recent blog entries';
$string['recentinterval'] = 'Interval of time considered "recent"';
$string['privacy:metadata'] = 'The Recent blog entries block only shows data stored in other locations.';
@@ -0,0 +1,31 @@
@block @block_blog_recent
Feature: Feature: Users can use the recent blog entries block to view recent blog entries.
In order to enable the recent blog entries in a course
As a teacher
I can add recent blog entries block to a course
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Scenario: Add the recent blogs block to a course when blogs are disabled
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I add the "Recent blog entries" block
And the following config values are set as admin:
| enableblogs | 0 |
And I reload the page
Then I should see "Blogging is disabled!" in the "Recent blog entries" "block"
Scenario: Add the recent blogs block to a course when there are not any blog posts
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I add the "Recent blog entries" block
Then I should see "No recent entries" in the "Recent blog entries" "block"
@@ -0,0 +1,113 @@
@block @block_blog_menu @mod_assign @block_blog_recent
Feature: Students can use the recent blog entries block to view recent entries on an activity page
In order to enable the recent blog entries block an activity page
As a teacher
I can add the recent blog entries block to an activity page
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment 1 |
| intro | Offline text |
| section | 1 |
| assignsubmission_file_enabled | 0 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | Activity module | 0001 | mod-assign-view | side-pre |
| blog_recent | Activity module | 0001 | mod-assign-view | side-pre |
Scenario: Students use the recent blog entries block to view blogs
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
When I set the following fields to these values:
| Entry title | S1 First Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
Then I should see "S1 First Blog"
And I should see "This is my awesome blog!"
And I follow "Test assignment 1"
And I should see "S1 First Blog"
And I follow "S1 First Blog"
And I should see "This is my awesome blog!"
Scenario: Students only see a few entries in the recent blog entries block
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
# Blog 1 of 5
And I set the following fields to these values:
| Entry title | S1 First Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I follow "Test assignment 1"
And I follow "Add an entry about this Assignment"
# Blog 2 of 5
And I set the following fields to these values:
| Entry title | S1 Second Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Second Blog"
And I should see "This is my awesome blog!"
And I follow "Test assignment 1"
And I follow "Add an entry about this Assignment"
# Blog 3 of 5
And I set the following fields to these values:
| Entry title | S1 Third Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Third Blog"
And I should see "This is my awesome blog!"
And I follow "Test assignment 1"
And I follow "Add an entry about this Assignment"
# Blog 4 of 5
And I set the following fields to these values:
| Entry title | S1 Fourth Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Fourth Blog"
And I should see "This is my awesome blog!"
And I follow "Test assignment 1"
And I follow "Add an entry about this Assignment"
# Blog 5 of 5
And I set the following fields to these values:
| Entry title | S1 Fifth Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I should see "S1 Fifth Blog"
And I should see "This is my awesome blog!"
When I follow "Test assignment 1"
And I should not see "S1 First Blog"
And I should see "S1 Second Blog"
And I should see "S1 Third Blog"
And I should see "S1 Fourth Blog"
And I should see "S1 Fifth Blog"
And I follow "S1 Fifth Blog"
And I should see "This is my awesome blog!"
Then I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test assignment 1"
And I configure the "Recent blog entries" block
And I set the following fields to these values:
| config_numberofrecentblogentries | 2 |
And I press "Save changes"
And I should see "S1 Fourth Blog"
And I should see "S1 Fifth Blog"
@@ -0,0 +1,104 @@
@block @block_blog_menu @block_blog_recent
Feature: Students can use the recent blog entries block to view recent entries on a course page
In order to enable the recent blog entries block a course page
As a teacher
I can add the recent blog entries block to a course page
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | Course | C1 | course-view-* | side-pre |
| blog_recent | Course | C1 | course-view-* | side-pre |
And the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
Scenario: Students use the recent blog entries block to view blogs
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
When I set the following fields to these values:
| Entry title | S1 First Blog <span lang="RU" class="multilang">RUSSIAN</span><span lang="EN" class="multilang">ENGLISH</span> |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
Then I should see "S1 First Blog ENGLISH"
And I should see "This is my awesome blog!"
And I am on "Course 1" course homepage
And I should see "S1 First Blog ENGLISH"
And I follow "S1 First Blog"
And I should see "This is my awesome blog!"
Scenario: Students only see a few entries in the recent blog entries block
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
# Blog 1 of 5
And I set the following fields to these values:
| Entry title | S1 First Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I am on "Course 1" course homepage
And I follow "Add an entry about this course"
# Blog 2 of 5
And I set the following fields to these values:
| Entry title | S1 Second Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Second Blog"
And I should see "This is my awesome blog!"
And I am on "Course 1" course homepage
And I follow "Add an entry about this course"
# Blog 3 of 5
And I set the following fields to these values:
| Entry title | S1 Third Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Third Blog"
And I should see "This is my awesome blog!"
And I am on "Course 1" course homepage
And I follow "Add an entry about this course"
# Blog 4 of 5
And I set the following fields to these values:
| Entry title | S1 Fourth Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Fourth Blog"
And I should see "This is my awesome blog!"
And I am on "Course 1" course homepage
And I follow "Add an entry about this course"
# Blog 5 of 5
And I set the following fields to these values:
| Entry title | S1 Fifth Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I should see "S1 Fifth Blog"
And I should see "This is my awesome blog!"
When I am on "Course 1" course homepage
And I should not see "S1 First Blog"
And I should see "S1 Second Blog"
And I should see "S1 Third Blog"
And I should see "S1 Fourth Blog"
And I should see "S1 Fifth Blog"
And I follow "S1 Fifth Blog"
And I should see "This is my awesome blog!"
Then I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I configure the "Recent blog entries" block
And I set the following fields to these values:
| config_numberofrecentblogentries | 2 |
And I press "Save changes"
And I should see "S1 Fourth Blog"
And I should see "S1 Fifth Blog"
@@ -0,0 +1,102 @@
@block @block_blog_recent
Feature: Feature: Students can use the recent blog entries block to view recent entries on the frontpage
In order to enable the recent blog entries block on the frontpage
As an admin
I can add the recent blog entries block to the frontpage
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_recent | System | 1 | site-index | side-pre |
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
# TODO MDL-57120 site "Blogs" link not accessible without navigation block.
And I add the "Navigation" block if not present
And I log out
Scenario: Students use the recent blog entries block to view blogs
Given I log in as "student1"
And I am on site homepage
And I click on "Site blogs" "link" in the "Navigation" "block"
And I follow "Add a new entry"
When I set the following fields to these values:
| Entry title | S1 First Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
Then I should see "S1 First Blog"
And I should see "This is my awesome blog!"
And I am on site homepage
And I should see "S1 First Blog"
And I follow "S1 First Blog"
And I should see "This is my awesome blog!"
Scenario: Students only see a few entries in the recent blog entries block
Given I log in as "student1"
And I am on site homepage
And I click on "Site blogs" "link" in the "Navigation" "block"
And I follow "Add a new entry"
# Blog 1 of 5
And I set the following fields to these values:
| Entry title | S1 First Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I follow "Add a new entry"
# Blog 2 of 5
And I set the following fields to these values:
| Entry title | S1 Second Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Second Blog"
And I should see "This is my awesome blog!"
And I follow "Add a new entry"
# Blog 3 of 5
And I set the following fields to these values:
| Entry title | S1 Third Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Third Blog"
And I should see "This is my awesome blog!"
And I follow "Add a new entry"
# Blog 4 of 5
And I set the following fields to these values:
| Entry title | S1 Fourth Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I wait "1" seconds
And I should see "S1 Fourth Blog"
And I should see "This is my awesome blog!"
And I follow "Add a new entry"
# Blog 5 of 5
And I set the following fields to these values:
| Entry title | S1 Fifth Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
And I should see "S1 Fifth Blog"
And I should see "This is my awesome blog!"
When I am on site homepage
And I should not see "S1 First Blog"
And I should see "S1 Second Blog"
And I should see "S1 Third Blog"
And I should see "S1 Fourth Blog"
And I should see "S1 Fifth Blog"
And I follow "S1 Fifth Blog"
And I should see "This is my awesome blog!"
Then I log out
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I configure the "Recent blog entries" block
And I set the following fields to these values:
| config_numberofrecentblogentries | 2 |
And I press "Save changes"
And I should see "S1 Fourth Blog"
And I should see "S1 Fifth Blog"
@@ -0,0 +1,63 @@
<?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 block_blog_recent;
use advanced_testcase;
use block_blog_recent;
use context_course;
/**
* PHPUnit block_blog_recent tests
*
* @package block_blog_recent
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \block_blog_recent
*/
class blog_recent_test extends advanced_testcase {
public static function setUpBeforeClass(): void {
require_once(__DIR__ . '/../../moodleblock.class.php');
require_once(__DIR__ . '/../block_blog_recent.php');
}
/**
* Test the behaviour of can_block_be_added() method.
*
* @covers ::can_block_be_added
*/
public function test_can_block_be_added(): void {
$this->resetAfterTest();
$this->setAdminUser();
// Create a course and prepare the page where the block will be added.
$course = $this->getDataGenerator()->create_course();
$page = new \moodle_page();
$page->set_context(context_course::instance($course->id));
$page->set_pagelayout('course');
$block = new block_blog_recent();
// If blogs advanced feature is enabled, the method should return true.
set_config('enableblogs', true);
$this->assertTrue($block->can_block_be_added($page));
// However, if the blogs advanced feature is disabled, the method should return false.
set_config('enableblogs', false);
$this->assertFalse($block->can_block_be_added($page));
}
}
+29
View File
@@ -0,0 +1,29 @@
<?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 block_blog_recent
* @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 = 'block_blog_recent'; // Full name of the plugin (used for diagnostics)