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,79 @@
<?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 summary block
*
* @package block_course_summary
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_course_summary extends block_base {
/**
* @var bool Flag to indicate whether the header should be hidden or not.
*/
private $headerhidden = true;
function init() {
$this->title = get_string('pluginname', 'block_course_summary');
}
function applicable_formats() {
return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
}
function specialization() {
// Page type starts with 'course-view' and the page's course ID is not equal to the site ID.
if (strpos($this->page->pagetype, PAGE_COURSE_VIEW) === 0 && $this->page->course->id != SITEID) {
$this->title = get_string('coursesummary', 'block_course_summary');
$this->headerhidden = false;
}
}
function get_content() {
global $CFG, $OUTPUT;
require_once($CFG->libdir . '/filelib.php');
if($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return '';
}
$this->content = new stdClass();
$options = new stdClass();
$options->noclean = true; // Don't clean Javascripts etc
$options->overflowdiv = true;
$context = context_course::instance($this->page->course->id);
$this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
$this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
$this->content->footer = '';
return $this->content;
}
function hide_header() {
return $this->headerhidden;
}
}
@@ -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_course_summary.
*
* @package block_course_summary
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_course_summary\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_course_summary 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/>.
/**
* Course summary block caps.
*
* @package block_course_summary
* @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/course_summary:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
+33
View File
@@ -0,0 +1,33 @@
<?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 summary block installation.
*
* @package block_course_summary
* @copyright 2021 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Perform the post-install procedures.
*/
function xmldb_block_course_summary_install() {
global $DB;
// Disable course_summary on new installs by default.
$DB->set_field('block', 'visible', 0, ['name' => 'course_summary']);
}
+60
View File
@@ -0,0 +1,60 @@
<?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 keeps track of upgrades to the course summary block
*
* Sometimes, changes between versions involve alterations to database structures
* and other major things that may break installations.
*
* The upgrade function in this file will attempt to perform all the necessary
* actions to upgrade your older installation to the current version.
*
* If there's something it cannot do itself, it will tell you what you need to do.
*
* The commands in here will all be database-neutral, using the methods of
* database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @since Moodle 2.0
* @package block_course_summary
* @copyright 2012 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Handles upgrading instances of this block.
*
* @param int $oldversion
* @param object $block
*/
function xmldb_block_course_summary_upgrade($oldversion, $block) {
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v4.2.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v4.3.0 release upgrade line.
// Put any upgrade step following this.
// Automatically generated Moodle v4.4.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
@@ -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/>.
/**
* Strings for component 'block_course_summary', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_course_summary
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['coursesummary'] = 'Course summary';
$string['course_summary:addinstance'] = 'Add a new course/site summary block';
$string['pluginname'] = 'Course/site summary';
$string['privacy:metadata'] = 'The Course/site summary block only shows information about courses and does not store data itself.';
+7
View File
@@ -0,0 +1,7 @@
.block_course_summary .content {
padding: 10px;
}
.block_course_summary .editbutton {
text-align: right;
}
@@ -0,0 +1,34 @@
@block @block_course_summary
Feature: Course summary block used in a course
In order to help particpants know the summary of a course
As a teacher
I can add the course summary block to a course page
Background:
Given the following "courses" exist:
| fullname | shortname | summary | category |
| Course 1 | C101 | Proved the course summary block works! |0 |
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | Sam | Student | student1@example.com |
| teacher1 | Teacher | One | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C101 | student |
| teacher1 | C101 | editingteacher |
And I enable "course_summary" "block" plugin
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| course_summary | Course | C101 | course-view-* | side-pre |
Scenario: Student can view course summary
When I am on the "Course 1" course page logged in as student1
Then "Course summary" "block" should exist
And I should see "Course summary" in the "Course summary" "block"
And I should see "Proved the course summary block works!" in the "Course summary" "block"
Scenario: Teacher can not see edit icon when edit mode is off
When I am on the "Course 1" course page logged in as teacher1
Then I should see "Proved the course summary block works!" in the "Course summary" "block"
And I should see "Course summary" in the "Course summary" "block"
And "Edit" "link" should not exist in the "Course summary" "block"
@@ -0,0 +1,32 @@
@block @block_course_summary
Feature: Course summary block used on the frontpage
In order to help particpants know the summary of a site
As admin
I can use the course summary block on the frontpage
Background:
Given I log in as "admin"
And I enable "course_summary" "block" plugin
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| course_summary | System | 1 | site-index | side-pre |
And I am on site homepage
And I navigate to "Site home > Site home settings" in site administration
And I set the following fields to these values:
| summary | Proved the summary block works! |
And I press "Save changes"
And I log out
# The course summary block a default front page block, so no need to add it.
Scenario: Guest can view site summary
When I am on site homepage
Then "Course/site summary" "block" should exist
And I should not see "Course summary" in the "Course/site summary" "block"
And I should see "Proved the summary block works!" in the "Course/site summary" "block"
Scenario: Admin can not see edit icon when edit mode is off
When I log in as "admin"
And I am on site homepage
Then I should see "Proved the summary block works!" in the "Course/site summary" "block"
And I should not see "Course summary" in the "Course/site summary" "block"
And "Edit" "link" should not exist in the "Course/site summary" "block"
+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_course_summary
* @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_course_summary'; // Full name of the plugin (used for diagnostics)