Initial commit of timetable-Module (rd)

This commit is contained in:
root 2020-06-26 11:30:19 +00:00
commit 784cb23da3
14 changed files with 723 additions and 0 deletions

51
db/access.php Normal file
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/>.
/**
* Newblock block caps.
*
* @package block_timetable
* @copyright Daniel Neis <danielneis@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/timetable:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/timetable:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);

34
db/install.xml Normal file
View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/timetable/db" VERSION="20200624" COMMENT="XMLDB file for Moodle blocks/timetable"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="block_timetable" COMMENT="Default comment for block_timetable, please edit me">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="timetable_lesson" COMMENT="lessons">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="teacher" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="Teachers name"/>
<FIELD NAME="day" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="day of week"/>
<FIELD NAME="period" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="period"/>
<FIELD NAME="subject" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="subject"/>
<FIELD NAME="room" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="room"/>
<FIELD NAME="lessonid" TYPE="int" LENGTH="7" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="flag" TYPE="int" LENGTH="7" NOTNULL="false" SEQUENCE="false" COMMENT="internal untis flag"/>
<FIELD NAME="class" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="name of class"/>
<FIELD NAME="week" TYPE="char" LENGTH="53" NOTNULL="false" SEQUENCE="false" COMMENT="week of schoolyear"/>
<FIELD NAME="unknown" TYPE="int" LENGTH="7" NOTNULL="false" SEQUENCE="false" COMMENT="undocumented field in untis txt-export"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>

16
db/tasks.php Normal file
View file

@ -0,0 +1,16 @@
<?php
defined('MOODLE_INTERNAL') || die();
$tasks = [
[
'classname' => '\block_timetable\task\import_data',
'blocking' => 0,
'minute' => '*/10',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*',
],
];

60
db/upgrade.php Normal file
View file

@ -0,0 +1,60 @@
<?php
function xmldb_block_timetable_upgrade($oldversion) {
global $CFG;
$result = TRUE;
global $DB;
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
if ($oldversion < 2020062400) {
// Define table block_timetable to be created.
$table = new xmldb_table('block_timetable');
// Adding fields to table block_timetable.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
// Adding keys to table block_timetable.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for block_timetable.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table timetable_lesson to be created.
$table = new xmldb_table('timetable_lesson');
// Adding fields to table timetable_lesson.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('teacher', XMLDB_TYPE_CHAR, '20', null, null, null, null);
$table->add_field('day', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
$table->add_field('period', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
$table->add_field('subject', XMLDB_TYPE_CHAR, '20', null, null, null, null);
$table->add_field('room', XMLDB_TYPE_CHAR, '20', null, null, null, null);
$table->add_field('lessonid', XMLDB_TYPE_INTEGER, '7', null, null, null, null);
$table->add_field('flag', XMLDB_TYPE_INTEGER, '7', null, null, null, null);
$table->add_field('class', XMLDB_TYPE_CHAR, '20', null, null, null, null);
$table->add_field('week', XMLDB_TYPE_CHAR, '53', null, null, null, null);
$table->add_field('unknown', XMLDB_TYPE_INTEGER, '7', null, null, null, null);
// Adding keys to table timetable_lesson.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for timetable_lesson.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Timetable savepoint reached.
upgrade_block_savepoint(true, 2020062400, 'timetable');
}
return $result;
}
?>