first version
This commit is contained in:
parent
83a8dc5d90
commit
52f3f359af
10 changed files with 633 additions and 344 deletions
134
classes/lesson.php
Executable file
134
classes/lesson.php
Executable file
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* File containing lesson class.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace mod_timetable;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Class lesson
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
class lesson {
|
||||
|
||||
/** @var array the data of lesson */
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param object $lesson Lesson
|
||||
*/
|
||||
public function __construct($lesson) {
|
||||
$this->lessonid= $lesson->lessonid;
|
||||
$this->teacher = $lesson->teacher;
|
||||
$this->subject = $lesson->subject;
|
||||
$this->class = $lesson->class;
|
||||
$this->room = $lesson->room;
|
||||
$this->period = $lesson->period;
|
||||
$this->day = $lesson->day;
|
||||
$this->text = "";
|
||||
$this->substitution = "";
|
||||
$this->teachera = "";
|
||||
$this->subjecta = "";
|
||||
$this->classa = "";
|
||||
$this->rooma = "";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param object $substitution Substitution
|
||||
*/
|
||||
public function process_substitution($substitution) {
|
||||
// echo "Entering substitution! $this->teacher, $this->subject, $this->class, $this->room \n\t $substitution->teacherb, $substitution->subjectb, $substitution->classb, $substitution->roomb\n";
|
||||
if (//$this->lessonid == $substitution->lesson &&
|
||||
$this->teacher == $substitution->teacherb &&
|
||||
$this->subject == $substitution->subjectb &&
|
||||
$this->class == $substitution->classb &&
|
||||
$this->room == $substitution->roomb) {
|
||||
//preg_match("(^|~)$this->teacher($|~)", $substitution->teacherb) &&
|
||||
//preg_match("(^|~)$this->subject($|~)", $substitution->subjectb) &&
|
||||
//preg_match("(^|~)$this->class($|~)", $substitution->classb) &&
|
||||
//preg_match("(^|~)$this->room($|~)", $substitution->roomb)) {
|
||||
|
||||
// Append change info
|
||||
// if (!preg_match("(^|~)$this->teacher($|~)", $substitution->teachera)) $this->teachera = $substitution->teachera;
|
||||
// if (!preg_match("(^|~)$this->subject($|~)", $substitution->subjecta)) $this->subjecta = $substitution->subjecta;
|
||||
// if (!preg_match("(^|~)$this->class($|~)" , $substitution->classa )) $this->classa = $substitution->classa;
|
||||
// if (!preg_match("(^|~)$this->room($|~)" , $substitution->rooma )) $this->rooma = $substitution->rooma;
|
||||
if ($this->teacher != $substitution->teachera) $this->teachera = $substitution->teachera;
|
||||
if ($this->subject != $substitution->subjecta) $this->subjecta = $substitution->subjecta;
|
||||
if ($this->class != $substitution->classa ) $this->classa = $substitution->classa;
|
||||
if ($this->room != $substitution->rooma ) $this->rooma = $substitution->rooma;
|
||||
if ($substitution->text) $this->text .= $substitution->text;
|
||||
// echo "In substitution! $this->teachera, $this->subjecta, $this->classa, $this->rooma\n";
|
||||
$this->substitution = "1";
|
||||
return 1;
|
||||
} elseif (//$this->lessonid == $substitution->lesson &&
|
||||
$this->teacher == $substitution->teachera &&
|
||||
$this->subject == $substitution->subjecta &&
|
||||
$this->class == $substitution->classa &&
|
||||
$this->room == $substitution->rooma) {
|
||||
if ($substitution->text) $this->text .= $substitution->text;
|
||||
$this->type .= $substitution->type;
|
||||
// echo "In substitution! $this->teachera, $this->subjecta, $this->classa, $this->rooma\n";
|
||||
#$this->substitution = "1";
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param object $absence Absence
|
||||
*/
|
||||
public function process_absence($absence) {
|
||||
// echo "Process_absence: $absence->endperiod";
|
||||
if ((($absence->type == 'L' && $absence->name == $this->teacher) ||
|
||||
($absence->type == 'K' && $absence->name == $this->class) ||
|
||||
($absence->type == 'R' && $absence->name == $this->room)) &&
|
||||
$absence->startperiod <= $this->period &&
|
||||
$absence->endperiod >= $this->period) {
|
||||
$this->text .= $absence->text;
|
||||
$this->reason = $absence->reason;
|
||||
$this->startperiod = $absence->startperiod;
|
||||
$this->endperiod = $absence->endperiod;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function integrate($lesson) {
|
||||
if($this->lessonid == $lesson->lessonid &&
|
||||
//$this->teacher == $lesson->teacher &&
|
||||
$this->subject == $lesson->subject &&
|
||||
$this->room == $lesson->room &&
|
||||
$this->text == $lesson->text) {
|
||||
if ($this->class != $lesson->class) {
|
||||
$class1parts = explode("/", $this->class);
|
||||
$class2parts = explode("/", $lesson->class);
|
||||
if (count($class1parts)>1 && count($class2parts)==2) {
|
||||
$this->class .= "/".$class2parts[1];
|
||||
} else
|
||||
$this->class .= $lesson->class;
|
||||
}
|
||||
if ($this->teacher != $lesson->teacher) {
|
||||
$this->teacher .= "/".$lesson->teacher;
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -243,6 +243,118 @@ class import_data extends \core\task\scheduled_task {
|
|||
}
|
||||
}
|
||||
|
||||
private function read_absence() {
|
||||
global $DB,$CFG;
|
||||
$filehash = get_config('timetable', 'filehash_abs');
|
||||
$filename = get_config('timetable', 'fname_absence');
|
||||
|
||||
if (!$filename || !file_exists($filename)) return;
|
||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||
$hash = hash_file('md5', $filename);
|
||||
if ($hash == $filehash) return;
|
||||
try {
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
echo "before delete\n";
|
||||
$DB->delete_records_select("timetable_absence", "id>0");
|
||||
echo "after delete\n";
|
||||
$handle = @fopen($filename, "r");
|
||||
echo "after handle\n";
|
||||
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
||||
$dataobject = (object)array('id' => $data[0],
|
||||
'type' => $data[1],
|
||||
'name' => utf8_encode($data[2]),
|
||||
'startdate' => $data[3],
|
||||
'enddate' => $data[4],
|
||||
'startperiod' => $data[5],
|
||||
'endperiod' => $data[6],
|
||||
'reason' => utf8_encode($data[7]),
|
||||
'text' => utf8_encode($data[8]));
|
||||
//echo var_dump($dataobject);
|
||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
||||
if ($value=='') unset($dataobject->{$key});
|
||||
}
|
||||
$DB->insert_record("timetable_absence", $dataobject);
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
fclose($handle);
|
||||
set_config('filehash_abs', $hash, 'timetable');
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback($e);
|
||||
}
|
||||
}
|
||||
|
||||
private function read_absence_reason() {
|
||||
global $DB,$CFG;
|
||||
$filehash = get_config('timetable', 'filehash_absreas');
|
||||
$filename = get_config('timetable', 'fname_absence_reason');
|
||||
|
||||
if (!$filename || !file_exists($filename)) return;
|
||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||
$hash = hash_file('md5', $filename);
|
||||
if ($hash == $filehash) return;
|
||||
try {
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
echo "before delete\n";
|
||||
$DB->delete_records_select("timetable_absence_reason", "id>0");
|
||||
echo "after delete\n";
|
||||
$handle = @fopen($filename, "r");
|
||||
echo "after handle\n";
|
||||
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
||||
$dataobject = (object)array('reason' => utf8_encode($data[0]),
|
||||
'description' => utf8_encode($data[1]),
|
||||
'flag' => $data[2],
|
||||
'statistic' => $data[3]);
|
||||
//echo var_dump($dataobject);
|
||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
||||
if ($value=='') unset($dataobject->{$key});
|
||||
}
|
||||
$DB->insert_record("timetable_absence_reason", $dataobject);
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
fclose($handle);
|
||||
set_config('filehash_absreas', $hash, 'timetable');
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback($e);
|
||||
}
|
||||
}
|
||||
|
||||
private function read_times() {
|
||||
global $DB,$CFG;
|
||||
$filehash = get_config('timetable', 'filehash_times');
|
||||
$filename = get_config('timetable', 'fname_times');
|
||||
|
||||
if (!$filename || !file_exists($filename)) return;
|
||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||
$hash = hash_file('md5', $filename);
|
||||
if ($hash == $filehash) return;
|
||||
try {
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
echo "before delete\n";
|
||||
$DB->delete_records_select("timetable_time", "id>0");
|
||||
echo "after delete\n";
|
||||
$handle = @fopen($filename, "r");
|
||||
echo "after handle\n";
|
||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||
// echo $buffer;
|
||||
$buffer = utf8_encode(rtrim($buffer));
|
||||
$data = explode("\t", $buffer);
|
||||
|
||||
$dataobject = (object)array('day' => $data[0],
|
||||
'period' => $data[1],
|
||||
'maxperiod' => $data[2],
|
||||
'starttime' => $data[3],
|
||||
'endtime' => $data[4]);
|
||||
|
||||
$DB->insert_record("timetable_time", $dataobject);
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
fclose($handle);
|
||||
set_config('filehash_times', $hash, 'timetable');
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the task.
|
||||
*/
|
||||
|
@ -254,6 +366,9 @@ class import_data extends \core\task\scheduled_task {
|
|||
$this->read_teacher();
|
||||
$this->read_room();
|
||||
$this->read_class();
|
||||
$this->read_absence();
|
||||
$this->read_absence_reason();
|
||||
$this->read_times();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,44 +10,42 @@
|
|||
|
||||
namespace mod_timetable;
|
||||
|
||||
require_once('lesson.php');
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function super_unique($array) {
|
||||
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
|
||||
foreach ($result as $key => $value) {
|
||||
if ( is_array($value) ) {
|
||||
$result[$key] = super_unique($value);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
const FLAG_Entfall = 0b0000000000000001;
|
||||
const FLAG_Betreuung = 0b0000000000000010;
|
||||
const FLAG_Sondereinsatz = 0b0000000000000100;
|
||||
const FLAG_Wegverlegung = 0b0000000000001000;
|
||||
const FLAG_Freisetzung = 0b0000000000010000;
|
||||
const FLAG_PlusVertreter = 0b0000000000100000;
|
||||
const FLAG_Teilverlegung = 0b0000000001000000;
|
||||
const FLAG_Hinverlegung = 0b0000000010000000;
|
||||
|
||||
function remove_dup($matriz) {
|
||||
$aux_ini=array();
|
||||
$entrega=array();
|
||||
for($n=0;$n<count($matriz);$n++) {
|
||||
$aux_ini[]=serialize($matriz[$n]);
|
||||
function lesson_in_lessons($obj, $array) {
|
||||
for($n=0;$n<count($array);$n++) {
|
||||
if ($obj->lessonid== $array[$n]->lessonid &&
|
||||
$obj->teacher == $array[$n]->teacher &&
|
||||
$obj->subject == $array[$n]->subject &&
|
||||
$obj->class == $array[$n]->class &&
|
||||
$obj->room == $array[$n]->room) return true;
|
||||
}
|
||||
$mat=array_unique($aux_ini);
|
||||
for($n=0;$n<count($matriz);$n++) {
|
||||
$entrega[]=unserialize($mat[$n]);
|
||||
}
|
||||
return $entrega;
|
||||
}
|
||||
|
||||
function lesson_in_lessons($array, $arrays) {
|
||||
for($n=0;$n<count($arrays);$n++) {
|
||||
if ($array['teacher'] == $arrays[$n]['teacher'] &&
|
||||
$array['subject'] == $arrays[$n]['subject'] &&
|
||||
$array['room'] == $arrays[$n]['room'] &&
|
||||
$array['class'] == $arrays[$n]['class'] &&
|
||||
// $array['flag'] == $arrays[$n]['flag'] &&
|
||||
$array['status'] == $arrays[$n]['status']) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function collapse_lessons($array) {
|
||||
$result = array();
|
||||
foreach ($array as $lesson) {
|
||||
$integrated = false;
|
||||
foreach ($result as $rlesson) {
|
||||
if ($rlesson->integrate($lesson)) $integrated = true;
|
||||
}
|
||||
if (!$integrated) $result[] = $lesson;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class timetable
|
||||
*
|
||||
|
@ -59,6 +57,8 @@ class timetable {
|
|||
|
||||
/** @var array the data of timetable */
|
||||
public $data;
|
||||
//public $lessons;
|
||||
//public $lessons_canceled;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
|
@ -75,7 +75,20 @@ class timetable {
|
|||
|
||||
public function clear_data() {
|
||||
$this->data = array();
|
||||
for ($i=1; $i<=6; $i++) $this->data[$i] = array();
|
||||
$this->lessons = array();
|
||||
$this->lessons_canceled = array();
|
||||
$this->lessons_event = array();
|
||||
for ($i=1; $i<=6; $i++) {
|
||||
$this->data[$i] = array();
|
||||
$this->lessons[$i] = array();
|
||||
$this->lessons_canceled[$i] = array();
|
||||
$this->lessons_event[$i] = array();
|
||||
for ($j=1; $j<=13; $j++) {
|
||||
$this->lessons[$i][$j] = array();
|
||||
$this->lessons_canceled[$i][$j] = array();
|
||||
$this->lessons_event[$i][$j] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,20 +99,12 @@ class timetable {
|
|||
public function read_db($week) {
|
||||
global $USER, $DB, $CFG;
|
||||
|
||||
$this->clear_data();
|
||||
$this->clear_data();
|
||||
$this->numdayweek = 5 + get_config('timetable', 'saturday');
|
||||
$this->week = $week;
|
||||
$this->monday = new \DateTime();
|
||||
$this->monday->setISODate($this->monday->format("Y"), $week);
|
||||
/*
|
||||
$this->monday = new \DateTime('29-07-2020'); // Only for debugging!!!
|
||||
if ($week>0) {
|
||||
$this->monday->add(new \DateInterval("P".($week)."W"));
|
||||
} elseif ($week<0) {
|
||||
$this->monday->sub(new \DateInterval("P".(-$week)."W"));
|
||||
}
|
||||
*/
|
||||
$dayofweek = $this->monday->format('w');
|
||||
$dayofweek = $this->monday->format('w');
|
||||
if ($dayofweek > $this->numdayweek) {
|
||||
$this->monday->add(new \DateInterval("P".(8-$dayofweek)."D"));
|
||||
} elseif ($dayofweek < 1) {
|
||||
|
@ -112,30 +117,63 @@ class timetable {
|
|||
$this->lastday = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
||||
$this->lastday->add(new \DateInterval("P".($this->numdayweek-1)."D"));
|
||||
|
||||
//$this->content->text .= $monday->format('d.m') . " - " . $lastday->format('d.m');
|
||||
$sql = "$this->type = '$this->name' AND NOT lessonid=0 AND (mid(week, $this->week, 1) = '1')";
|
||||
$result = $DB->get_records_select('timetable_lesson',$sql);
|
||||
foreach ($result as $lesson) {
|
||||
if (!lesson_in_lessons($lesson, $this->lessons[$lesson->day][$lesson->period]))
|
||||
$this->lessons[$lesson->day][$lesson->period][] = new lesson($lesson);
|
||||
// Todo: if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
|
||||
}
|
||||
$sql = "$this->type = '$this->name' AND lessonid=0 AND (mid(week, $this->week, 1) = '1')";
|
||||
$result = $DB->get_records_select('timetable_lesson',$sql);
|
||||
foreach ($result as $lesson) {
|
||||
if (!lesson_in_lessons($lesson, $this->lessons_event[$lesson->day][$lesson->period]))
|
||||
$this->lessons_event[$lesson->day][$lesson->period][] = new lesson($lesson);
|
||||
// Todo: if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
|
||||
}
|
||||
$sql = "$this->type = '$this->name' and (mid(week, $this->week, 1) = 'x')";
|
||||
$result = $DB->get_records_select('timetable_lesson',$sql);
|
||||
foreach ($result as $lesson) {
|
||||
if (!lesson_in_lessons($lesson, $this->lessons_canceled[$lesson->day][$lesson->period]))
|
||||
$this->lessons_canceled[$lesson->day][$lesson->period][] = new lesson($lesson);
|
||||
// Todo: if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
|
||||
}
|
||||
|
||||
$sql = "$this->type = '$this->name' and not (mid(week, $this->week, 1) = '-')";
|
||||
//$sql = "$this->type = '$this->name' and (mid(week, $this->week, 1) = '1')";
|
||||
if ($result = $DB->get_records_select('timetable_lesson',$sql)) {
|
||||
foreach ($result as $lesson) {
|
||||
//if (!exists($this->data[$lesson->day][$lesson->period])) $this->data[$lesson->day][$lesson->period] = array();
|
||||
$this->data[$lesson->day][$lesson->period]['lesson'][] = $lesson;
|
||||
if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
|
||||
}
|
||||
}
|
||||
$day = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
||||
$day = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
||||
for ($i=0; $i<$this->numdayweek; $i++) {
|
||||
$sql = "date = '".$day->format('Ymd')."' AND ({$this->type}a RLIKE '(^|~){$this->name}($|~)' OR {$this->type}b RLIKE '(^|~){$this->name}($|~)')";
|
||||
$result = $DB->get_records_select('timetable_substitution',$sql);
|
||||
foreach ($result as $substitution) {
|
||||
foreach ($this->lessons[$i+1][$substitution->period] as $lesson) {
|
||||
$lesson->process_substitution($substitution);
|
||||
}
|
||||
foreach ($this->lessons_canceled[$i+1][$substitution->period] as $lesson) {
|
||||
$lesson->process_substitution($substitution);
|
||||
}
|
||||
foreach ($this->lessons_event[$i+1][$substitution->period] as $lesson) {
|
||||
$lesson->process_substitution($substitution);
|
||||
}
|
||||
}
|
||||
// Todo: if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
|
||||
|
||||
for ($i=0; $i<$this->numdayweek; $i++) {
|
||||
$sql = "date = '".$day->format('Ymd')."' AND ({$this->type}a RLIKE '(^|~){$this->name}($|~)' OR {$this->type}b RLIKE '(^|~){$this->name}($|~)')";
|
||||
if ($result = $DB->get_records_select('timetable_substitution',$sql)) {
|
||||
foreach ($result as $substitution) {
|
||||
$this->data[$i+1][$substitution->period]['substitution'][] = $substitution;
|
||||
if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
|
||||
//echo var_dump($substitution);
|
||||
}
|
||||
}
|
||||
$day->add(new \DateInterval("P1D"));
|
||||
}
|
||||
$types = array('teacher'=>'L', 'class'=>'K', 'room'=>'R');
|
||||
$sql = "startdate <= '".$day->format('Ymd')."' AND enddate >= '".$day->format('Ymd')."' AND type = '{$types[$this->type]}' AND name = '{$this->name}'";
|
||||
$result = $DB->get_records_select('timetable_absence',$sql);
|
||||
foreach ($result as $absence) {
|
||||
for ($j=$absence->startperiod; $j<=$absence->endperiod; $j++) {
|
||||
foreach ($this->lessons_event[$i+1][$j] as $lesson) {
|
||||
$lesson->process_absence($absence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$day->add(new \DateInterval("P1D"));
|
||||
}
|
||||
|
||||
for ($i=0; $i<$this->numdayweek; $i++) {
|
||||
foreach($this->lessons[$i+1] as &$lessons) $lessons = collapse_lessons($lessons);
|
||||
foreach($this->lessons_canceled[$i+1] as &$lessons) $lessons = collapse_lessons($lessons);
|
||||
}
|
||||
|
||||
if ($this->type == 'teacher') {
|
||||
if ($result = $DB->get_record("timetable_$this->type",[$this->type => $this->name])) {
|
||||
|
@ -146,266 +184,103 @@ class timetable {
|
|||
$this->description = $result->description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of online users
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function print_navigation($week) {
|
||||
/**
|
||||
* Count the number of online users
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
$table = new \html_table();
|
||||
$table->attributes['class'] = 'minicalendar calendartable calendar-controls';
|
||||
//$table->head = array('','Mo','Di', 'Mi' , 'Do', 'Fr');
|
||||
$tablerow = new \html_table_row();
|
||||
if ($week>0) {
|
||||
$tablerow->cells[] = new \html_table_cell('<a href="#slide-'.($week-1).'" class="arrow_link previous" title="Vorherige Woche" data-week="-1"><span class="arrow">◄</span></a>');
|
||||
} else {
|
||||
$tablerow->cells[] = new \html_table_cell('');
|
||||
}
|
||||
$tablerow->cells[] = new \html_table_cell('<a href="#">'.$this->monday->format('d.m') . " - " . $this->lastday->format('d.m').'</a>');
|
||||
if ($week<2) {
|
||||
$tablerow->cells[] = new \html_table_cell('<a href="#slide-'.($week+1).'" class="arrow_link next" title="Nächste Woche" data-month="8" data-week="1"><span class="arrow">►</span></a>');
|
||||
} else {
|
||||
$tablerow->cells[] = new \html_table_cell('');
|
||||
}
|
||||
$sql = "day = 1 ORDER BY period asc";
|
||||
$this->times = $DB->get_records_select('timetable_time',$sql);
|
||||
}
|
||||
|
||||
public function prepare_output() {
|
||||
$resultdata = array();
|
||||
|
||||
$table->data[] = $tablerow;
|
||||
return \html_writer::table($table);
|
||||
|
||||
}
|
||||
|
||||
public function get_caption($week) {
|
||||
$result = "";
|
||||
if ($week>0) {
|
||||
//$result .= '<a href="#slide-'.($week-1).'" class="arrow_link previous" title="Vorherige Woche" data-week="-1"><span class="arrow">◄</span></a>';
|
||||
$result .= '<a href="javascript:M.block_timetable.scroll_week('.($week-1).');" class="arrow_link previous" title="Vorherige Woche" data-week="1"><span class="arrow">◄<</span></a>';
|
||||
} else {
|
||||
$result .= '<a href="#" class="previous" style="visibility:hidden" data-week="-1"></A>';
|
||||
//$result .= '<a href="#" class="arrow_link previous" data-week="-1"><span class="arrow" style="display:none"></span></a>';
|
||||
}
|
||||
$result .= '<span class="hide"> | </span>';
|
||||
$result .= '<span class="current">';
|
||||
$result .= '<a href="#">'.$this->monday->format('d.m') . " - " . $this->lastday->format('d.m').'</a>';
|
||||
$result .= "</span>";
|
||||
$result .= '<span class="hide"> | </span>';
|
||||
if ($week<2) {
|
||||
//$result .= '<a href="#slide-'.($week+1).'" class="arrow_link next" title="Nächste Woche" data-month="8" data-week="1"><span class="arrow">►</span></a>';
|
||||
$result .= '<a href="javascript:M.block_timetable.scroll_week('.($week+1).');" class="arrow_link next" title="Nächste Woche" data-month="8" data-week="1"><span class="arrow">►</span></a>';
|
||||
} else {
|
||||
$result .= '';
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function print_table($view,$week) {
|
||||
global $DB;
|
||||
//var_dump($this->data[1]);
|
||||
$numperiod = get_config('timetable', 'numperiod');
|
||||
$numdayweek = 5 + get_config('timetable', 'saturday');
|
||||
if ($this->periodmax>$numperiod) $numperiod = $this->periodmax;
|
||||
$table = new \html_table();
|
||||
//$table->attributes['class'] = "minicalendar calendartable generaltable timetable_view_$view";
|
||||
$table->attributes['class'] = "minicalendar calendartable generaltable timetable_view_$view";
|
||||
$table->caption = "<div class='calendar-controls'>".$this->get_caption($week)."</div>";
|
||||
//$table->style = 'display: none;';
|
||||
$table->head = array('','Mo','Di', 'Mi' , 'Do', 'Fr');
|
||||
if ($numdayweek == 6) $table->head[] = 'Sa';
|
||||
for ($i = 1; $i<=$numperiod; $i++) {
|
||||
$tablerow = new \html_table_row();
|
||||
$cell = new \html_table_cell($i);
|
||||
$cell->style = 'font-weight: bold;';
|
||||
// $cell->attributes['class'] = 'header';
|
||||
$tablerow->cells[] = $cell;
|
||||
for ($k = 1; $k <= $numdayweek; $k++) {
|
||||
$flag = 0;
|
||||
if (array_key_exists($i,$this->data[$k]) && array_key_exists('lesson',$this->data[$k][$i])) {
|
||||
$content = "";
|
||||
foreach ($this->data[$k][$i]['lesson'] as $lesson) {
|
||||
if ($content) $content .= "<br>";
|
||||
if ($lesson->flag) $content .= "<span style='color:red;'>";
|
||||
//if (substr($lesson->week,$this->week,1) == '1') $content .= $lesson->{$view};
|
||||
if ($lesson->week[$this->week-1] == '1') {
|
||||
if ($lesson->{$view}) {
|
||||
$content .= $lesson->{$view};
|
||||
} else {
|
||||
$content .= "+++";
|
||||
}
|
||||
}
|
||||
if ($lesson->week[$this->week-1] == 'x') $content .= "---";
|
||||
if ($lesson->flag) $content .= "</span>";
|
||||
$flag += $lesson->flag;
|
||||
}
|
||||
} else {
|
||||
$content = "-";
|
||||
}
|
||||
$subtxt = "";
|
||||
if (array_key_exists($i,$this->data[$k]) && array_key_exists('substitution', $this->data[$k][$i])) {
|
||||
foreach ($this->data[$k][$i]['substitution'] as $substitution) {
|
||||
$subtxt .= $substitution->text;
|
||||
}
|
||||
if ($subtxt) {
|
||||
$content = "<a href='#' data-toggle='tooltip' title='$subtxt'>$content</a>";
|
||||
//$content .= "<span class='tooltiptext'>$subtxt</span>";
|
||||
}
|
||||
}
|
||||
$cell = new \html_table_cell($content);
|
||||
// if ($flag) $cell->style = 'color: red;';
|
||||
//if (array_key_exists($i, $this->data[$k] ) && array_key_exists('substitution', $this->data[$k][$i])) $cell->attributes['class'] = 'tooltip';
|
||||
$tablerow->cells[] = $cell;
|
||||
}
|
||||
$table->data[] = $tablerow;
|
||||
}
|
||||
return \html_writer::table($table);
|
||||
}
|
||||
|
||||
public function prepare_output() {
|
||||
$resultdata = array();
|
||||
$numperiod = get_config('timetable', 'numperiod');
|
||||
if ($this->periodmax > $numperiod) $numperiod = $this->periodmax;
|
||||
$numdayweek = 5 + get_config('timetable', 'saturday');
|
||||
if ($numdayweek == 6) $resultdata['saturday'] = 1; else $resultdata['saturday'] = 0;
|
||||
$resultdata['type'] = $this->type;
|
||||
$resultdata['name'] = $this->name;
|
||||
$resultdata['description'] = $this->description;
|
||||
$resultdata['date'] = $this->monday->format('d.m') . " - " . $this->lastday->format('d.m');
|
||||
$resultdata['week'] = $this->week;
|
||||
$resultdata['prevweek'] = $this->week-1;
|
||||
$resultdata['nextweek'] = $this->week+1;
|
||||
$resultdata['id'] = \substr(\md5(\rand()), 0, 7);
|
||||
$numperiod = 13;
|
||||
|
||||
$numdayweek = 5 + get_config('timetable', 'saturday');
|
||||
if ($numdayweek == 6) $resultdata['saturday'] = 1; else $resultdata['saturday'] = 0;
|
||||
|
||||
$resultdata['type'] = $this->type;
|
||||
$resultdata['name'] = $this->name;
|
||||
$resultdata['description'] = $this->description;
|
||||
$resultdata['date'] = $this->monday->format('d.m') . " - " . $this->lastday->format('d.m');
|
||||
$resultdata['week'] = $this->week;
|
||||
$resultdata['prevweek'] = $this->week-1;
|
||||
$resultdata['nextweek'] = $this->week+1;
|
||||
$resultdata['id'] = \substr(\md5(\rand()), 0, 7);
|
||||
$periods = array();
|
||||
|
||||
for ($period=0; $period<$numperiod; $period++) {
|
||||
$days = array();
|
||||
for ($day=0; $day<$numdayweek; $day++) {
|
||||
$days[$day] = array();
|
||||
$days[$day]['substitution'] = "";
|
||||
$days[$day]['lessons'] = array();
|
||||
if (array_key_exists($period+1,$this->data[$day+1])
|
||||
&& array_key_exists('lesson',$this->data[$day+1][$period+1])) {
|
||||
foreach ($this->data[$day+1][$period+1]['lesson'] as $lesson) {
|
||||
$mylesson = array();
|
||||
$mylesson['class'] = $lesson->class;
|
||||
$mylesson['teacher'] = $lesson->teacher;
|
||||
$mylesson['room'] = $lesson->room;
|
||||
$mylesson['subject'] = $lesson->subject;
|
||||
$mylesson['status'] = "";
|
||||
$mylesson['flag'] = "";
|
||||
if ($lesson->flag) $mylesson['flag'] = $lesson->flag;
|
||||
if ($lesson->week[$this->week-1] == 'x') {
|
||||
$mylesson['status'] = 1;
|
||||
$mylesson['flag'] = 1;
|
||||
/*
|
||||
if (array_key_exists('substitution', $this->data[$day+1][$period+1])) {
|
||||
foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) {
|
||||
if ($lesson->class == $substitution->classa &&
|
||||
$lesson->teacher == $substitution->teachera &&
|
||||
$lesson->subject == $substitution->subjecta &&
|
||||
$lesson->room == $substitution->rooma) {
|
||||
$mylesson['class'] = $substitution->classb;
|
||||
$mylesson['teacher'] = $substitution->teacherb;
|
||||
$mylesson['room'] = $substitution->roomb;
|
||||
$mylesson['subject'] = $substitution->subjectb;
|
||||
$mylesson['status'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->type == 'class') $mylesson['class'] = "";
|
||||
if ($this->type == 'teacher') $mylesson['teacher'] = "";
|
||||
if ($this->type == 'room') $mylesson['room'] = "";
|
||||
*/
|
||||
if ($lesson->week[$this->week-1] != '0' && !lesson_in_lessons($mylesson, $days[$day]['lessons'])) {
|
||||
//$days[$day]['lessons'][] = $mylesson;
|
||||
if (count($days[$day]['lessons']) && $days[$day]['lessons'][0]['status']) {
|
||||
$days[$day]['lessons'][0] = $mylesson;
|
||||
} else {
|
||||
$days[$day]['lessons'][] = $mylesson;
|
||||
}
|
||||
}
|
||||
//if ($lesson->week[$this->week-1] == '1') $days[$day]['lessons'][] = $mylesson;
|
||||
/*
|
||||
- für diese Woche wurden keine Daten ausgegeben
|
||||
0 in dieser Woche findet der Unterricht nicht statt
|
||||
1 in dieser Woche findet der Unterricht statt
|
||||
x in dieser Woche entfällt der Unterricht
|
||||
|
||||
if ($lesson->week[$this->week-1] == 'x')
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (array_key_exists($period+1,$this->data[$day+1])
|
||||
&& array_key_exists('substitution', $this->data[$day+1][$period+1])) {
|
||||
foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) {
|
||||
//echo "In substitution loop".$substitution->text;
|
||||
if ($days[$day]['substitution']) $days[$day]['substitution'] .= ' / ';
|
||||
$days[$day]['substitution'] .= $substitution->text;
|
||||
|
||||
$mylesson = array();
|
||||
$mylesson['class'] = $substitution->classb;
|
||||
$mylesson['teacher'] = $substitution->teacherb;
|
||||
$mylesson['room'] = $substitution->roomb;
|
||||
$mylesson['subject'] = $substitution->subjectb;
|
||||
|
||||
if ($substitution->subjectb &&
|
||||
(($this->type == 'teacher' && $this->name == $substitution->teacherb) ||
|
||||
// ($this->type == 'class' && $this->name == $substitution->classb) ||
|
||||
($this->type == 'class' && strpos($substitution->classb, $this->name)) ||
|
||||
($this->type == 'room' && $this->name == $substitution->roomb))
|
||||
) {
|
||||
|
||||
$mylesson['status'] = "";
|
||||
$mylesson['flag'] = 1;
|
||||
|
||||
if (!lesson_in_lessons($mylesson, $days[$day]['lessons'])) {
|
||||
if (count($days[$day]['lessons']) && $days[$day]['lessons'][0]['status']) {
|
||||
$days[$day]['lessons'][0] = $mylesson;
|
||||
} else {
|
||||
$days[$day]['lessons'][] = $mylesson;
|
||||
}
|
||||
}
|
||||
//if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson;
|
||||
} elseif (($this->type == 'teacher' && $this->name == $substitution->teachera) ||
|
||||
// ($this->type == 'class' && $this->name == $substitution->classa) ||
|
||||
($this->type == 'class' && strpos($substitution->classa, $this->name)) ||
|
||||
($this->type == 'room' && $this->name == $substitution->rooma)) {
|
||||
$mylesson['class'] = $substitution->classa;
|
||||
$mylesson['teacher'] = $substitution->teachera;
|
||||
$mylesson['room'] = $substitution->rooma;
|
||||
$mylesson['subject'] = $substitution->subjecta;
|
||||
$mylesson['status'] = 1;
|
||||
$mylesson['flag'] = 1;
|
||||
//$days[$day]['lessons'][] = $mylesson;
|
||||
if (!lesson_in_lessons($mylesson, $days[$day]['lessons'])) $days[$day]['lessons'][] = $mylesson;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//$days[$day]['lessons'] = array_unique($days[$day]['lessons']);
|
||||
//$days[$day]['lessons'] = super_unique($days[$day]['lessons']);
|
||||
//$days[$day]['lessons'] = remove_dup($days[$day]['lessons']);
|
||||
|
||||
}
|
||||
$periods[$period] = array();
|
||||
$periods[$period]['days'] = $days;
|
||||
$periods[$period]['number'] = $period+1;
|
||||
}
|
||||
$resultdata['periods'] = $periods;
|
||||
//echo var_dump($data);
|
||||
return $resultdata;
|
||||
}
|
||||
|
||||
$days[$day]['substitutionold'] = "";
|
||||
$days[$day]['lessons'] = array();
|
||||
foreach ($this->lessons_event[$day+1][$period+1] as $lesson) {
|
||||
$mylesson = array();
|
||||
$mylesson['class'] = $lesson->class;
|
||||
$mylesson['teacher'] = $lesson->teacher;
|
||||
$mylesson['room'] = $lesson->room;
|
||||
$mylesson['subject'] = $lesson->subject;
|
||||
$mylesson['classa'] = $lesson->classa;
|
||||
$mylesson['teachera'] = $lesson->teachera;
|
||||
$mylesson['rooma'] = $lesson->rooma;
|
||||
$mylesson['subjecta'] = $lesson->subjecta;
|
||||
$mylesson['substitution'] = $lesson->substitution;
|
||||
$mylesson['cancel'] = "";
|
||||
$mylesson['event'] = $lesson->reason ? $lesson->reason : "Event";
|
||||
$mylesson['status'] = "1";
|
||||
$mylesson['flag'] = "1";
|
||||
$mylesson['text'] = $lesson->text;
|
||||
$days[$day]['substitutionold'] .= $lesson->text;
|
||||
$days[$day]['lessons'][] = $mylesson;
|
||||
}
|
||||
foreach ($this->lessons[$day+1][$period+1] as $lesson) {
|
||||
$mylesson = array();
|
||||
$mylesson['class'] = $lesson->class;
|
||||
$mylesson['teacher'] = $lesson->teacher;
|
||||
$mylesson['room'] = $lesson->room;
|
||||
$mylesson['subject'] = $lesson->subject;
|
||||
$mylesson['classa'] = $lesson->classa;
|
||||
$mylesson['teachera'] = $lesson->teachera;
|
||||
$mylesson['rooma'] = $lesson->rooma;
|
||||
$mylesson['subjecta'] = $lesson->subjecta;
|
||||
$mylesson['substitution'] = $lesson->substitution;
|
||||
$mylesson['cancel'] = "";
|
||||
$mylesson['event'] = "";
|
||||
$mylesson['status'] = "";
|
||||
$mylesson['flag'] = "";
|
||||
$mylesson['text'] = $lesson->text;
|
||||
$days[$day]['substitutionold'] .= $lesson->text;
|
||||
$days[$day]['lessons'][] = $mylesson;
|
||||
}
|
||||
foreach ($this->lessons_canceled[$day+1][$period+1] as $lesson) {
|
||||
$mylesson = array();
|
||||
$mylesson['class'] = $lesson->class;
|
||||
$mylesson['teacher'] = $lesson->teacher;
|
||||
$mylesson['room'] = $lesson->room;
|
||||
$mylesson['subject'] = $lesson->subject;
|
||||
$mylesson['classa'] = $lesson->classa;
|
||||
$mylesson['teachera'] = $lesson->teachera;
|
||||
$mylesson['rooma'] = $lesson->rooma;
|
||||
$mylesson['subjecta'] = $lesson->subjecta;
|
||||
$mylesson['substitution'] = $lesson->substitution;
|
||||
$mylesson['cancel'] = "1";
|
||||
$mylesson['event'] = "";
|
||||
$mylesson['status'] = "1";
|
||||
$mylesson['flag'] = "1"; // status und flag werden vertauscht (im Template bzw. extern-lib.php
|
||||
$mylesson['text'] = $lesson->text;
|
||||
$days[$day]['substitutionold'] .= $lesson->text;
|
||||
$days[$day]['lessons'][] = $mylesson;
|
||||
}
|
||||
}
|
||||
$periods[$period] = array();
|
||||
$periods[$period]['days'] = $days;
|
||||
$periods[$period]['number'] = $period+1;
|
||||
$periods[$period]['starttime'] = substr_replace($this->times[$period+1]->starttime, ":",-2,0);
|
||||
$periods[$period]['endtime'] = substr_replace($this->times[$period+1]->endtime, ":",-2,0);
|
||||
}
|
||||
$resultdata['periods'] = $periods;
|
||||
return $resultdata;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,34 @@
|
|||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="timetable_absence" COMMENT="Absences">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="type" TYPE="char" LENGTH="1" NOTNULL="true" SEQUENCE="false" COMMENT="Element type"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Shortname of absence element"/>
|
||||
<FIELD NAME="startdate" TYPE="int" LENGTH="8" NOTNULL="true" SEQUENCE="false" COMMENT="Date of start of absence"/>
|
||||
<FIELD NAME="enddate" TYPE="int" LENGTH="8" NOTNULL="true" SEQUENCE="false" COMMENT="Date of start of absence"/>
|
||||
<FIELD NAME="startperiod" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="Number of first absence period"/>
|
||||
<FIELD NAME="endperiod" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="Number of last absence period"/>
|
||||
<FIELD NAME="reason" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Reason of absence"/>
|
||||
<FIELD NAME="text" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Description of absence"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="timetable_absence_reason" COMMENT="Teachers">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="reason" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Absence shortname"/>
|
||||
<FIELD NAME="description" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Absence description"/>
|
||||
<FIELD NAME="flag" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="flag"/>
|
||||
<FIELD NAME="statistic" 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_teacher" COMMENT="Teachers">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
|
@ -97,5 +125,18 @@
|
|||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="timetable_time" COMMENT="Classes">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="day" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="day"/>
|
||||
<FIELD NAME="period" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="period"/>
|
||||
<FIELD NAME="maxperiod" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="maximum number of periods"/>
|
||||
<FIELD NAME="starttime" TYPE="char" LENGTH="4" NOTNULL="true" SEQUENCE="false" COMMENT="starttime"/>
|
||||
<FIELD NAME="endtime" TYPE="char" LENGTH="4" NOTNULL="true" SEQUENCE="false" COMMENT="endtime"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
|
|
|
@ -178,6 +178,75 @@ function xmldb_timetable_upgrade($oldversion) {
|
|||
upgrade_mod_savepoint(true, 2020082903, 'timetable');
|
||||
}
|
||||
|
||||
if ($oldversion < 2020110901) {
|
||||
|
||||
// Define table timetable to be created.
|
||||
$table = new xmldb_table('timetable_absence');
|
||||
|
||||
// Adding fields to table timetable.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('type', XMLDB_TYPE_CHAR, '1', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('startdate', XMLDB_TYPE_INTEGER, '8', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('enddate', XMLDB_TYPE_INTEGER, '8', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('startperiod', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('endperiod', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('reason', XMLDB_TYPE_CHAR, '10', null, null, null, null);
|
||||
$table->add_field('text', 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);
|
||||
}
|
||||
|
||||
// Define table timetable to be created.
|
||||
$table = new xmldb_table('timetable_absence_reason');
|
||||
|
||||
// Adding fields to table timetable.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('reason', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('description', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
$table->add_field('flag', XMLDB_TYPE_CHAR, '8', null, null, null, null);
|
||||
$table->add_field('statistic', XMLDB_TYPE_CHAR, '8', 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, 2020110901, 'timetable');
|
||||
}
|
||||
if ($oldversion < 2020111101) {
|
||||
|
||||
// Define table timetable to be created.
|
||||
$table = new xmldb_table('timetable_time');
|
||||
|
||||
// Adding fields to table timetable.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('day', XMLDB_TYPE_INTEGER, '2' , null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('period', XMLDB_TYPE_INTEGER, '2' , null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('maxperiod', XMLDB_TYPE_INTEGER, '2' , null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('starttime', XMLDB_TYPE_CHAR, '4', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('endtime', XMLDB_TYPE_CHAR, '4', null, XMLDB_NOTNULL, 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, 2020111101, 'timetable');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -198,10 +198,12 @@ class mod_timetable_external extends external_api {
|
|||
new external_single_structure(
|
||||
array(
|
||||
'number' => new external_value(PARAM_INT, 'number of period'),
|
||||
'starttime' => new external_value(PARAM_TEXT, 'starttime of period'),
|
||||
'endtime' => new external_value(PARAM_TEXT, 'endtime of period'),
|
||||
'days' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'substitution' => new external_value(PARAM_TEXT, 'substitution'),
|
||||
'substitutionold' => new external_value(PARAM_TEXT, 'substitution'),
|
||||
'lessons' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
|
@ -209,8 +211,16 @@ class mod_timetable_external extends external_api {
|
|||
'teacher' => new external_value(PARAM_TEXT, 'name of teacher'),
|
||||
'room' => new external_value(PARAM_TEXT, 'name of room'),
|
||||
'subject' => new external_value(PARAM_TEXT, 'name of subject'),
|
||||
'classa' => new external_value(PARAM_TEXT, 'name of class'),
|
||||
'teachera'=> new external_value(PARAM_TEXT, 'name of teacher'),
|
||||
'rooma' => new external_value(PARAM_TEXT, 'name of room'),
|
||||
'subjecta' => new external_value(PARAM_TEXT, 'name of subject'),
|
||||
'substitution'=> new external_value(PARAM_TEXT, 'lesson is substitution'),
|
||||
'cancel' => new external_value(PARAM_TEXT, 'lesson is canceled'),
|
||||
'event' => new external_value(PARAM_TEXT, 'lesson is event'),
|
||||
'status' => new external_value(PARAM_TEXT, 'status of lesson'),
|
||||
'flag' => new external_value(PARAM_TEXT, 'flag of lesson')
|
||||
'flag' => new external_value(PARAM_TEXT, 'flag of lesson'),
|
||||
'text' => new external_value(PARAM_TEXT, 'description text')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -37,6 +37,12 @@ $string['import_data'] = 'import_data';
|
|||
$string['labelfnamelesson'] = 'lesson import file';
|
||||
$string['descfnamelesson'] = 'Absolute path and filename of untis export file lesson.txt';
|
||||
$string['labelfnamesubst'] = 'substitution import file';
|
||||
$string['descfnameabs'] = 'Absolute path and filename of untis export file GPU013.TXT';
|
||||
$string['labelfnameabs'] = 'absence import file';
|
||||
$string['descfnameabsreas'] = 'Absolute path and filename of untis export file GPU012.TXT';
|
||||
$string['labelfnameabsreas'] = 'absence reason import file';
|
||||
$string['descfnametimes'] = 'Absolute path and filename of untis export file time.txt';
|
||||
$string['labelfnametimes'] = 'time import file';
|
||||
$string['descfnamesubst'] = 'Absolute path and filename of untis export file GPU014.TXT';
|
||||
$string['labelfnameteacher'] = 'teacher import file';
|
||||
$string['descfnameteacher'] = 'Absolute path and filename of untis export file teacher.txt';
|
||||
|
|
41
settings.php
41
settings.php
|
@ -33,34 +33,49 @@ if ($ADMIN->fulltree) {
|
|||
$settings->add(new admin_setting_configcheckbox('timetable/saturday',
|
||||
get_string('labelsaturday', 'mod_timetable'),
|
||||
get_string('descsaturday', 'mod_timetable'),
|
||||
'0'));
|
||||
'0'));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_lesson',
|
||||
get_string('labelfnamelesson', 'mod_timetable'),
|
||||
get_string('descfnamelesson', 'mod_timetable'),
|
||||
''));
|
||||
get_string('descfnamelesson', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_substitution',
|
||||
get_string('labelfnamesubst', 'mod_timetable'),
|
||||
get_string('descfnamesubst', 'mod_timetable'),
|
||||
''));
|
||||
get_string('descfnamesubst', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_absence',
|
||||
get_string('labelfnameabs', 'mod_timetable'),
|
||||
get_string('descfnameabs', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_absence_reason',
|
||||
get_string('labelfnameabsreas', 'mod_timetable'),
|
||||
get_string('descfnameabsreas', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_teacher',
|
||||
get_string('labelfnameteacher', 'mod_timetable'),
|
||||
get_string('descfnameteacher', 'mod_timetable'),
|
||||
''));
|
||||
get_string('descfnameteacher', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_class',
|
||||
get_string('labelfnameclass', 'mod_timetable'),
|
||||
get_string('descfnameclass', 'mod_timetable'),
|
||||
get_string('descfnameclass', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_room',
|
||||
get_string('labelfnameroom', 'mod_timetable'),
|
||||
get_string('descfnamesroom', 'mod_timetable'),
|
||||
''));
|
||||
get_string('descfnamesroom', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/fname_times',
|
||||
get_string('labelfnametimes', 'mod_timetable'),
|
||||
get_string('descfnametimes', 'mod_timetable'),
|
||||
''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('timetable/numperiod',
|
||||
get_string('labelnumperiod', 'mod_timetable'),
|
||||
get_string('descnumperiod', 'mod_timetable'),
|
||||
12, PARAM_INT));
|
||||
get_string('descnumperiod', 'mod_timetable'),
|
||||
12, PARAM_INT));
|
||||
|
|
|
@ -19,23 +19,47 @@
|
|||
</thead>
|
||||
{{#periods}}
|
||||
<tr sstyle="border:1px black; padding-top:0rem; padding-bottom:0rem">
|
||||
<td>{{number}}</td>
|
||||
<td>
|
||||
<a href="javascript:;" style="color: black;" data-container="body" data-toggle="popover" data-placement="top" data-html="true" data-content="Beginn: {{starttime}} Uhr<br/>Ende: {{endtime}} Uhr" title="{{starttime}}-{{endtime}}">
|
||||
{{number}}
|
||||
</a></td>
|
||||
{{#days}}
|
||||
<td style="padding-top:0rem; padding-bottom:0rem; vertical-alig:middle; border-left:1px black;" {{#substitution}}bgcolor="pink" data-toggle='tooltip' title='{{substitution}}'{{/substitution}}>
|
||||
<td style="padding-top:0rem; padding-bottom:0rem; vertical-align:middle; border-left:1px black;" {{#substitutionolddd}}bgcolor="pink" data-toggle='tooltip' title='{{substitutionold}}'{{/substitutionolddd}}>
|
||||
{{#lessons}}
|
||||
{{#status}}
|
||||
<div class="lesson" style="padding:2pt; {{#flag}}background-color:red;{{/flag}}">
|
||||
<div class="omission">---</div>
|
||||
<div class="lesson" style="padding:2pt; {{#substitution}}border-color:red; boder-width:2px; border-style:solid; background-color:pink;{{/substitution}} {{#cancel}}font-weight:bold; background-color:red; text-decoration:line-through;{{/cancel}}{{#text}} background-color:pink;{{/text}}">
|
||||
<a href="javascript:;" style="color:{{#cancel}}white{{/cancel}}{{^cancel}}black{{/cancel}};" data-container="body" data-toggle="popover" data-placement="top" data-html="true" data-content="Fach: {{subject}},<br/>Lehrer: {{teacher}},<br/>Klasse: {{class}},</br>Raum: {{room}}</br>
|
||||
{{#cancel}} entfällt.{{/cancel}}{{#substitution}} statt: {{subjecta}}, {{teachera}}, {{classa}}, {{rooma}}{{/substitution}}{{#text}}<br><b>Hinweis: {{text}}</b>{{/text}}" title="{{#cancel}}Stunde entfällt{{/cancel}}{{#substitution}}Stundenänderung{{/substitution}}{{#event}} Event / Sonderplan{{/event}}">
|
||||
{{#event}}{{text}}{{/event}}
|
||||
<div class="subject">
|
||||
{{#subjecta}}<span style="background-color:red; color:white; font-weight:bold;">{{/subjecta}} {{subject}} {{#substitution}}{{#subjecta}}</span>{{/subjecta}}
|
||||
<span style="font-size:6pt">
|
||||
{{#classa}}<span style="background-color:red; color:white; font-weight:bold;">{{/classa}} {{class}} {{#classa}}</span>{{/classa}},
|
||||
{{#teachera}}<span style="background-color:red; color:white; font-weight:bold;">{{/teachera}} {{teacher}} {{#teachera}}</span>{{/teachera}},
|
||||
{{#rooma}}<span style="background-color:red; color:white; font-weight:bold;">{{/rooma}} {{room}} {{#rooma}}</span>{{/rooma}}
|
||||
</span>{{/substitution}}</div>
|
||||
<div class="class">
|
||||
{{#classa}}<span style="background-color:red; color:white; font-weight:bold;">{{/classa}} {{class}} {{#substitution}}{{#classa}}</span>{{/classa}}
|
||||
<span style="font-size:6pt">
|
||||
{{#subjecta}}<span style="background-color:red; color:white; font-weight:bold;">{{/subjecta}} {{subject}} {{#subjecta}}</span>{{/subjecta}},
|
||||
{{#teachera}}<span style="background-color:red; color:white; font-weight:bold;">{{/teachera}} {{teacher}} {{#teachera}}</span>{{/teachera}},
|
||||
{{#rooma}}<span style="background-color:red; color:white; font-weight:bold;">{{/rooma}} {{room}} {{#rooma}}</span>{{/rooma}}
|
||||
</span>{{/substitution}}</div>
|
||||
<div class="teacher">
|
||||
{{#teachera}}<span style="background-color:red; color:white; font-weight:bold;">{{/teachera}} {{teacher}} {{#substitution}}{{#teachera}}</span>{{/teachera}}
|
||||
<span style="font-size:6pt">
|
||||
{{#subjecta}}<span style="background-color:red; color:white; font-weight:bold;">{{/subjecta}} {{subject}} {{#subjecta}}</span>{{/subjecta}},
|
||||
{{#classa}}<span style="background-color:red; color:white; font-weight:bold;">{{/classa}} {{class}} {{#classa}}</span>{{/classa}}
|
||||
{{#rooma}}<span style="background-color:red; color:white; font-weight:bold;">{{/rooma}} {{room}} {{#rooma}}</span>{{/rooma}}
|
||||
</span>{{/substitution}}</div>
|
||||
<div class="room">
|
||||
{{#rooma}}<span style="background-color:red; color:white; font-weight:bold;">{{/rooma}} {{room}} {{#substitution}}{{#rooma}}</span>{{/rooma}}
|
||||
<span style="font-size:6pt">
|
||||
{{#subjecta}}<span style="background-color:red; color:white; font-weight:bold;">{{/subjecta}} {{subject}} {{#subjecta}}</span>{{/subjecta}},
|
||||
{{#classa}}<span style="background-color:red; color:white; font-weight:bold;">{{/classa}} {{class}} {{#classa}}</span>{{/classa}}
|
||||
{{#teachera}}<span style="background-color:red; color:white; font-weight:bold;">{{/teachera}} {{teacher}} {{#teachera}}</span>{{/teachera}},
|
||||
</span>{{/substitution}}</div>
|
||||
</a>
|
||||
</div>
|
||||
{{/status}}
|
||||
{{^status}}
|
||||
<div class="lesson" style="padding:2pt; {{#flag}}background-color:red;{{/flag}}">
|
||||
<div class="subject">{{subject}}</div>
|
||||
<div class="class">{{class}}</div>
|
||||
<div class="teacher">{{teacher}}</div>
|
||||
<div class="room">{{room}}</div>
|
||||
</div>
|
||||
{{/status}}
|
||||
{{/lessons}}
|
||||
</td>
|
||||
{{/days}}
|
||||
|
|
|
@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die();
|
|||
|
||||
$plugin->component = 'mod_timetable';
|
||||
$plugin->release = '0.1.0';
|
||||
$plugin->version = 2020091801;
|
||||
$plugin->version = 2020111102;
|
||||
$plugin->requires = 2020061500;
|
||||
$plugin->maturity = MATURITY_ALPHA;
|
||||
|
|
Loading…
Add table
Reference in a new issue