initial commit (da)

This commit is contained in:
Raphael Dannecker 2020-09-03 21:25:42 +02:00
commit 634dceef57
26 changed files with 2592 additions and 0 deletions

34
db/install.php Normal file
View file

@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Code to be executed after the plugin's database scheme has been installed is defined here.
*
* @package mod_timetable
* @category upgrade
* @copyright 2020 Raphael Dannecker <raphael.dannecker@steinbeisschule-reutlingen.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Custom code to be run on installing the plugin.
*/
function xmldb_timetable_install() {
return true;
}

101
db/install.xml Normal file
View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/timetable/db" VERSION="20200826" COMMENT="XMLDB file for Moodle mod_timetable"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="timetable" COMMENT="Stores the timetable activity module instances.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="ID of the course this activity is part of."/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The name of the activity module instance"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Timestamp of when the instance was added to the course."/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Timestamp of when the instance was last modified."/>
<FIELD NAME="intro" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Activity description."/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the intro field."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="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>
<TABLE NAME="timetable_substitution" COMMENT="Substitutions">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="date" TYPE="char" LENGTH="8" NOTNULL="false" SEQUENCE="false" COMMENT="date of substitution"/>
<FIELD NAME="period" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="period of day"/>
<FIELD NAME="absence" TYPE="int" LENGTH="6" NOTNULL="false" SEQUENCE="false" COMMENT="number of absence"/>
<FIELD NAME="lesson" TYPE="int" LENGTH="6" NOTNULL="false" SEQUENCE="false" COMMENT="number of lessen"/>
<FIELD NAME="teachera" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="absent teacher"/>
<FIELD NAME="teacherb" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="substitution teacher"/>
<FIELD NAME="subjecta" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="subject"/>
<FIELD NAME="statistica" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="statistic flag subject a"/>
<FIELD NAME="subjectb" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="subject"/>
<FIELD NAME="statisticb" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="statistic flag subject b"/>
<FIELD NAME="rooma" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="rooma"/>
<FIELD NAME="roomb" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="roomb"/>
<FIELD NAME="statisticflag" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="statistic flag"/>
<FIELD NAME="classa" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="classesa"/>
<FIELD NAME="reason" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="reason of substitition"/>
<FIELD NAME="text" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="text"/>
<FIELD NAME="type" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="type"/>
<FIELD NAME="classb" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="classesb"/>
<FIELD NAME="substitutiontype" TYPE="char" LENGTH="1" NOTNULL="false" SEQUENCE="false" COMMENT="type of substitution"/>
<FIELD NAME="changetime" TYPE="int" LENGTH="12" NOTNULL="false" SEQUENCE="false" COMMENT="timestamp"/>
<FIELD NAME="unknown" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="undocumented field"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="timetable_teacher" COMMENT="Teachers">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="teacher" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="Teachers name"/>
<FIELD NAME="surname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Teachers surname"/>
<FIELD NAME="firstname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Teachers firstname"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="timetable_room" COMMENT="Rooms">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="room" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="Room"/>
<FIELD NAME="description" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Rooms description"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="timetable_class" COMMENT="Classes">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="class" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="Coom"/>
<FIELD NAME="description" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Class description"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>

53
db/services.php Normal file
View file

@ -0,0 +1,53 @@
<?php
// 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/>.
/**
* Web service local plugin template external functions and service definitions.
*
* @package mod_timetable
* @copyright 2020 Raphael Dannecker <raphael.dannecker@steinbeisschule-reutlingen.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// We defined the web service functions to install.
$functions = array(
'mod_timetable_search' => array(
'classname' => 'mod_timetable_external',
'methodname' => 'search',
'classpath' => 'mod/timetable/externallib.php',
'description' => 'Return search result of timetable search',
'type' => 'read',
'ajax' => true,
'capabilities' => array(), // capabilities required by the function.
),
'mod_timetable_get' => array(
'classname' => 'mod_timetable_external',
'methodname' => 'get',
'classpath' => 'mod/timetable/externallib.php',
'description' => 'Return timetable data',
'type' => 'read',
'ajax' => true,
'capabilities' => array(), // capabilities required by the function.
)
);
// We define the services to install as pre-build services. A pre-build service is not editable by administrator.
$services = array(
'My service' => array(
'functions' => array ('mod_timetable_search','mod_timetable_get'),
'restrictedusers' => 0,
'enabled'=>1,
)
);

16
db/tasks.php Executable file
View file

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

34
db/uninstall.php Normal file
View file

@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Code that is executed before the tables and data are dropped during the plugin uninstallation.
*
* @package mod_timetable
* @category upgrade
* @copyright 2020 Raphael Dannecker <raphael.dannecker@steinbeisschule-reutlingen.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Custom uninstallation procedure.
*/
function xmldb_timetable_uninstall() {
return true;
}

183
db/upgrade.php Normal file
View file

@ -0,0 +1,183 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Plugin upgrade steps are defined here.
*
* @package mod_timetable
* @category upgrade
* @copyright 2020 Raphael Dannecker <raphael.dannecker@steinbeisschule-reutlingen.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Execute mod_timetable upgrade from the given old version.
*
* @param int $oldversion
* @return bool
*/
function xmldb_timetable_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();
// For further information please read the Upgrade API documentation:
// https://docs.moodle.org/dev/Upgrade_API
//
// You will also have to create the db/install.xml file by using the XMLDB Editor.
// Documentation for the XMLDB Editor can be found at:
// https://docs.moodle.org/dev/XMLDB_editor
if ($oldversion < 2020082903) {
// Define table timetable to be created.
$table = new xmldb_table('timetable');
// Adding fields to table timetable.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('intro', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table timetable.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
$table->add_key('fk_course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']);
// Conditionally launch create table for 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);
}
// Define table timetable_substitution to be created.
$table = new xmldb_table('timetable_substitution');
// Adding fields to table timetable_substitution.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('date', XMLDB_TYPE_CHAR, '8', null, null, null, null);
$table->add_field('period', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
$table->add_field('absence', XMLDB_TYPE_INTEGER, '6', null, null, null, null);
$table->add_field('lesson', XMLDB_TYPE_INTEGER, '6', null, null, null, null);
$table->add_field('teachera', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('teacherb', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('subjecta', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('statistica', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('subjectb', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('statisticb', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('rooma', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('roomb', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('statisticflag', XMLDB_TYPE_CHAR, '10', null, null, null, null);
$table->add_field('classa', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('reason', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('text', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('classb', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('substitutiontype', XMLDB_TYPE_CHAR, '1', null, null, null, null);
$table->add_field('changetime', XMLDB_TYPE_INTEGER, '12', null, null, null, null);
$table->add_field('unknown', XMLDB_TYPE_CHAR, '10', null, null, null, null);
// Adding keys to table timetable_substitution.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for timetable_substitution.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table timetable_teacher to be created.
$table = new xmldb_table('timetable_teacher');
// Adding fields to table timetable_teacher.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('teacher', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
$table->add_field('surname', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('firstname', XMLDB_TYPE_CHAR, '255', null, null, null, null);
// Adding keys to table timetable_teacher.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for timetable_teacher.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table timetable_room to be created.
$table = new xmldb_table('timetable_room');
// Adding fields to table timetable_room.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('room', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
$table->add_field('description', XMLDB_TYPE_CHAR, '255', null, null, null, null);
// Adding keys to table timetable_room.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for timetable_room.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table timetable_class to be created.
$table = new xmldb_table('timetable_class');
// Adding fields to table timetable_class.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('class', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
$table->add_field('description', XMLDB_TYPE_CHAR, '255', null, null, null, null);
// Adding keys to table timetable_class.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
// Conditionally launch create table for timetable_class.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Timetable savepoint reached.
upgrade_mod_savepoint(true, 2020082903, 'timetable');
}
return true;
}