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,76 @@
<?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/>.
/**
* Handles displaying the calendar block.
*
* @package block_calendar_month
* @copyright 2004 Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_calendar_month extends block_base {
/**
* Initialise the block.
*/
public function init() {
$this->title = get_string('pluginname', 'block_calendar_month');
}
/**
* Return the content of this block.
*
* @return stdClass the content
*/
public function get_content() {
global $CFG;
require_once($CFG->dirroot.'/calendar/lib.php');
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass;
$this->content->footer = '';
$renderer = $this->page->get_renderer('core_calendar');
$this->content->text = $renderer->start_layout();
$courseid = $this->page->course->id;
$categoryid = ($this->page->context->contextlevel === CONTEXT_COURSECAT && !empty($this->page->category)) ?
$this->page->category->id : null;
$calendar = \calendar_information::create(time(), $courseid, $categoryid);
list($data, $template) = calendar_get_view($calendar, 'monthblock', isloggedin());
// Add a flag that this is coming from calendar block.
$data->iscalendarblock = true;
$renderer = $this->page->get_renderer('core_calendar');
$this->content->text .= $renderer->render_from_template($template, $data);
$options = [
'showfullcalendarlink' => true
];
list($footerdata, $footertemplate) = calendar_get_footer_options($calendar, $options);
$this->content->footer .= $renderer->render_from_template($footertemplate, $footerdata);
$this->content->text .= $renderer->complete_layout();
$this->page->requires->js_call_amd('core_calendar/popover');
return $this->content;
}
}
@@ -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_calendar_month.
*
* @package block_calendar_month
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_calendar_month\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_calendar_month 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';
}
}
+51
View File
@@ -0,0 +1,51 @@
<?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/>.
/**
* Calendar month block caps.
*
* @package block_calendar_month
* @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/calendar_month:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/calendar_month:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
+59
View File
@@ -0,0 +1,59 @@
<?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 calendar_month 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.8
* @package block_calendar_month
* @copyright 2014 Andrew Davis
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Upgrade the calendar_month block
* @param int $oldversion
* @param object $block
*/
function xmldb_block_calendar_month_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,28 @@
<?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_calendar_month', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_calendar_month
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['calendar_month:addinstance'] = 'Add a new calendar block';
$string['calendar_month:myaddinstance'] = 'Add a new calendar block to Dashboard';
$string['pluginname'] = 'Calendar';
$string['privacy:metadata'] = 'The Calendar block only displays existing calendar data.';
@@ -0,0 +1,111 @@
@block @block_calendar_month
Feature: Enable the calendar block in a course and test it's functionality
In order to enable the calendar block in a course
As a teacher
I can add the calendar block to a course
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 |
Scenario: Add the block to a the course
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I add the "Calendar" block
Then "Calendar" "block" should exist
@javascript
Scenario: View a site event in the calendar block
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | Site Event |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Calendar" block
And I hover over today in the mini-calendar block
Then I should see "Site Event"
@javascript
Scenario: View a course event in the calendar block
Given I log in as "teacher1"
And I create a calendar event with form data:
| Type of event | course |
| Course | Course 1 |
| Event title | Course Event |
When I am on "Course 1" course homepage with editing mode on
And I add the "Calendar" block
And I hover over today in the mini-calendar block
Then I should see "Course Event"
@javascript
Scenario: View a user event in the calendar block
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| calendar_month | Course | C1 | course-view-* | side-pre |
And I log in as "teacher1"
And I create a calendar event with form data:
| id_eventtype | User |
| id_name | User Event |
When I am on "Course 1" course homepage
And I hover over today in the mini-calendar block
Then I should see "User Event"
@javascript
Scenario: View a group event in the calendar block
Given the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G2 |
When I am on the "Course 1" "course editing" page logged in as teacher1
And I set the following fields to these values:
| id_groupmode | Separate groups |
| id_groupmodeforce | Yes |
And I press "Save and display"
And I turn editing mode on
And I add the "Calendar" block
And I click on "Course calendar" "link"
And I create a calendar event:
| Type of event | group |
| Group | Group 1 |
| Event title | Group Event |
And I am on the "Course 1" course page logged in as student1
And I hover over today in the mini-calendar block
Then I should see "Group Event"
And I am on the "Course 1" course page logged in as student2
And I should not see "Group Event"
@javascript
Scenario: Click on today's course event on the calendar view page's calendar block
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | Site Event |
And I am on site homepage
And I turn editing mode on
And I add the "Calendar" block
And I configure the "Calendar" block
And I set the following fields to these values:
| Page contexts | Display throughout the entire site |
And I press "Save changes"
When I am on "Course 1" course homepage
And I follow "Course calendar"
And I click on today in the mini-calendar block to view the detail
Then I should see "Site Event" in the "Calendar" "block"
And ".popover" "css_element" should not exist
@@ -0,0 +1,27 @@
@block @block_calendar_month
Feature: Enable the calendar block in a course
In order to enable the calendar block in a course
As a teacher
I can add the calendar block to a course
@javascript
Scenario: View a site event in the calendar block in a course
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 |
When I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | Site Event |
And I log out
Then I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Calendar" block
And I hover over today in the mini-calendar block
And I should see "Site Event"
@@ -0,0 +1,33 @@
@block @block_calendar_month
Feature: View a site event on the dashboard
In order to view a site event
As a student
I can view the event in the calendar
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | Site Event |
And I log out
@javascript
Scenario: View a site event in the calendar block on the dashboard
Given I log in as "student1"
When I hover over today in the mini-calendar block
Then I should see "Site Event"
@javascript
Scenario: The calendar block on the dashboard should be responsive
Given I log in as "student1"
When I change viewport size to "1200x1000"
Then I should see "Site Event"
And I change viewport size to "600x1000"
# We need to give the browser a couple seconds to re-render the page after the screen has been resized.
And I wait "1" seconds
And I should not see "Site Event"
When I hover over today in the mini-calendar block responsive view
And I should see "Site Event"
@@ -0,0 +1,23 @@
@block @block_calendar_month
Feature: Enable the calendar block on the site front page
In order to enable the calendar block on the site front page
As an admin
I can add the calendar block on the site front page
@javascript
Scenario: View a site event in the calendar block on the front page
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 |
| calendar_month | System | 1 | site-index | side-pre |
And I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | Site Event |
And I log out
When I log in as "student1"
And I am on site homepage
And I hover over today in the mini-calendar block
Then I should see "Site Event"
+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_calendar_month
* @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_calendar_month'; // Full name of the plugin (used for diagnostics)