Compare commits
No commits in common. "c5d31f7812c5160da6564fb7c117aa63036a7d0c" and "5503fc88edebac4e53259da65b6be1ae8c519af0" have entirely different histories.
c5d31f7812
...
5503fc88ed
16 changed files with 636 additions and 1068 deletions
64
README.md
64
README.md
|
@ -1,66 +1,8 @@
|
||||||
# mod_timetable #
|
# timetable #
|
||||||
|
|
||||||
mod_timetable is a moodle plugin that provides timetables based on Untis export data.
|
TODO Describe the plugin shortly here.
|
||||||
|
|
||||||
The provides timetable views are:
|
|
||||||
- teacher
|
|
||||||
- student
|
|
||||||
- room
|
|
||||||
|
|
||||||
You can search for the timetables:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Multiple results can be displayed at same time
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Substitutions and events are displayed too.
|
|
||||||
|
|
||||||
On clicking on lessons you will get detailed information about it.
|
|
||||||
|
|
||||||
Required Untis-exportfiles:
|
|
||||||
- class.txt
|
|
||||||
- lesson.txt
|
|
||||||
- teacher.txt
|
|
||||||
- time.txt
|
|
||||||
- room.txt
|
|
||||||
- GPU012.TXT
|
|
||||||
- GPU013.TXT
|
|
||||||
- GPU014.TXT
|
|
||||||
|
|
||||||
If file content is changing, the moodle-database will be automatically updated.
|
|
||||||
|
|
||||||
You can also specify whether there are no classes on saturday.
|
|
||||||
The minimum number of teaching hours displayed is also configurable.
|
|
||||||
|
|
||||||
## Update data via WebService ##
|
|
||||||
|
|
||||||
- create user
|
|
||||||
- Website-Administration - Users - Rechte ändern - Rollen verwalten
|
|
||||||
- Add new role
|
|
||||||
- Basisrolle: keine
|
|
||||||
- Kurzbezeichnung: webservice-timetable
|
|
||||||
- Kontexttype: User
|
|
||||||
- add: update timetable data
|
|
||||||
webservice rest:use
|
|
||||||
webservice reatetoken
|
|
||||||
- Website-Administration - Users - timetable-user from step 1 - Einstellungen - rollen - Rollen relativ zu diesem Nutzerkonto zuweisen
|
|
||||||
- Website-Administration - Plugins - Webservice - Externe Webservices - Hinzufügen
|
|
||||||
- Name: timetableupdate
|
|
||||||
- Shortname: timetableupdate
|
|
||||||
x Aktiviert
|
|
||||||
x nur berechtigte Personen
|
|
||||||
- Erweitert:
|
|
||||||
Notwendige Rechte: keine
|
|
||||||
Funktion hinzufügen: mod/timetable:update: update timetable data
|
|
||||||
|
|
||||||
- Berechtigte Personen: add user from step 1
|
|
||||||
- Website-Administration - Plugins - Webservices - Token verwalten
|
|
||||||
- username: user from step 1
|
|
||||||
- service: timetableupdate
|
|
||||||
|
|
||||||
|
|
||||||
|
TODO Provide more detailed description here.
|
||||||
|
|
||||||
## License ##
|
## License ##
|
||||||
|
|
||||||
|
|
|
@ -1,340 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace mod_timetable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An example of a scheduled task.
|
|
||||||
*/
|
|
||||||
class import_data {
|
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the task's name as shown in admin screens.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function get_name() {
|
|
||||||
return get_string('import_data', 'mod_timetable');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_lesson($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_lesson');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result ="";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_lesson", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
//echo $buffer;
|
|
||||||
$result .= "+";
|
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
|
||||||
$data = explode("\t", $buffer);
|
|
||||||
if (count($data) != 10) throw new \Exception('Wrong size of elements ');
|
|
||||||
$dataobject = (object)array('teacher' => $data[0],
|
|
||||||
'day' => $data[1],
|
|
||||||
'period' => $data[2],
|
|
||||||
'subject' => $data[3],
|
|
||||||
'room' => $data[4],
|
|
||||||
'lessonid'=> $data[5],
|
|
||||||
'flag' => $data[6],
|
|
||||||
'class' => $data[7],
|
|
||||||
'week' => $data[8],
|
|
||||||
'unknown' => $data[9]);
|
|
||||||
|
|
||||||
$DB->insert_record("timetable_lesson", $dataobject);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_lesson', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return ($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function update_substitution($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_substitution');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result ="";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_substitution", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
$data = str_getcsv($buffer, ',');
|
|
||||||
$dataobject = (object)array(
|
|
||||||
'id' => $data[0],
|
|
||||||
'date' => $data[1],
|
|
||||||
'period' => $data[2],
|
|
||||||
'absence' => $data[3],
|
|
||||||
'lesson' => $data[4],
|
|
||||||
'teachera' => $data[5],
|
|
||||||
'teacherb' => $data[6],
|
|
||||||
'subjecta' => utf8_encode($data[7]),
|
|
||||||
'statistica' => $data[8],
|
|
||||||
'subjectb' => utf8_encode($data[9]),
|
|
||||||
'statisticb' => $data[10],
|
|
||||||
'rooma' => $data[11],
|
|
||||||
'roomb' => $data[12],
|
|
||||||
'statisticflag' => $data[13],
|
|
||||||
'classa' => utf8_encode($data[14]),
|
|
||||||
'reason' => utf8_encode($data[15]),
|
|
||||||
'text' => utf8_encode($data[16]),
|
|
||||||
'type' => $data[17],
|
|
||||||
'classb' => utf8_encode($data[18]),
|
|
||||||
'substitutiontype' => $data[19],
|
|
||||||
'changetime' => $data[20],
|
|
||||||
'unknown' => $data[21]);
|
|
||||||
//echo var_dump($dataobject);
|
|
||||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
|
||||||
if ($value=='') unset($dataobject->{$key});
|
|
||||||
}
|
|
||||||
$DB->insert_record_raw("timetable_substitution", $dataobject,false, false, true);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_substitution', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_teacher($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_teacher');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result = "";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_teacher", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
|
||||||
$data = explode("\t", $buffer);
|
|
||||||
if (!(array_key_exists(3,$data))) {
|
|
||||||
$data[3] = '';
|
|
||||||
} else {
|
|
||||||
$result .= "firstname exists: $data[3]\n";
|
|
||||||
}
|
|
||||||
//if (count($data) < 3) throw new Exception('Wrong size of elements');
|
|
||||||
$dataobject = (object)array('teacher' => $data[0],
|
|
||||||
'surname' => $data[1],
|
|
||||||
'firstname' => $data[3]);
|
|
||||||
|
|
||||||
$DB->insert_record("timetable_teacher", $dataobject);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_teacher', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_room($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_room');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result = "";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_room", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
|
||||||
$data = explode("\t", $buffer);
|
|
||||||
if (count($data) < 2) throw new \Exception('Wrong size of elements');
|
|
||||||
$dataobject = (object)array('room' => $data[0],
|
|
||||||
'description' => $data[1]);
|
|
||||||
|
|
||||||
$DB->insert_record("timetable_room", $dataobject);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_room', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_class($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_class');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result = "";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_class", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
|
||||||
$data = explode("\t", $buffer);
|
|
||||||
if (!(array_key_exists(1,$data))) $data[1] = $data[0];
|
|
||||||
if (count($data) < 2) throw new \Exception('Wrong size of elements');
|
|
||||||
$dataobject = (object)array('class' => $data[0],
|
|
||||||
'description' => $data[1]);
|
|
||||||
|
|
||||||
$DB->insert_record("timetable_class", $dataobject);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_class', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_absence($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_abs');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result = "";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_absence", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
$data = str_getcsv($buffer, ',');
|
|
||||||
$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]));
|
|
||||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
|
||||||
if ($value=='') unset($dataobject->{$key});
|
|
||||||
}
|
|
||||||
$DB->insert_record("timetable_absence", $dataobject);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_abs', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_absence_reason($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_absreas');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result = "";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_absence_reason", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $buffer) {
|
|
||||||
$data = str_getcsv($buffer, ',');
|
|
||||||
$dataobject = (object)array('reason' => utf8_encode($data[0]),
|
|
||||||
'description' => utf8_encode($data[1]),
|
|
||||||
'flag' => $data[2],
|
|
||||||
'statistic' => $data[3]);
|
|
||||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
|
||||||
if ($value=='') unset($dataobject->{$key});
|
|
||||||
}
|
|
||||||
$DB->insert_record("timetable_absence_reason", $dataobject);
|
|
||||||
}
|
|
||||||
$transaction->allow_commit();
|
|
||||||
set_config('filehash_absreas', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function update_time($content) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$filehash = get_config('timetable', 'filehash_times');
|
|
||||||
$hash = md5($content);
|
|
||||||
if ($hash == $filehash) return('Data not changed');
|
|
||||||
$result = "";
|
|
||||||
try {
|
|
||||||
$transaction = $DB->start_delegated_transaction();
|
|
||||||
$result .= "before delete\n";
|
|
||||||
$DB->delete_records_select("timetable_time", "id>0");
|
|
||||||
$result .= "after delete\n";
|
|
||||||
foreach (preg_split('/$\R?^/m',$content) as $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();
|
|
||||||
set_config('filehash_times', $hash, 'timetable');
|
|
||||||
} catch(Exception $e) {
|
|
||||||
$transaction->rollback($e);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the task.
|
|
||||||
*/
|
|
||||||
public function update($files) {
|
|
||||||
global $DB,$CFG;
|
|
||||||
$results = array();
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$content = base64_decode($file['content']);
|
|
||||||
$result = array();
|
|
||||||
$result['name'] = $file['name'];
|
|
||||||
switch ($file['name']) {
|
|
||||||
case 'lesson':
|
|
||||||
$result['result'] = $this->update_lesson($content);
|
|
||||||
break;
|
|
||||||
case 'substitution':
|
|
||||||
$result['result'] = $this->update_substitution($content);
|
|
||||||
break;
|
|
||||||
case 'teacher':
|
|
||||||
$result['result'] = $this->update_teacher($content);
|
|
||||||
break;
|
|
||||||
case 'class':
|
|
||||||
$result['result'] = $this->update_class($content);
|
|
||||||
break;
|
|
||||||
case 'room':
|
|
||||||
$result['result'] = $this->update_room($content);
|
|
||||||
break;
|
|
||||||
case 'time':
|
|
||||||
$result['result'] = $this->update_time($content);
|
|
||||||
break;
|
|
||||||
case 'absence':
|
|
||||||
$result['result'] = $this->update_absence($content);
|
|
||||||
break;
|
|
||||||
case 'absence_reason':
|
|
||||||
$result['result'] = $this->update_absence_reason($content);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$result['result'] = "no handler";
|
|
||||||
}
|
|
||||||
$results[] = $result;
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -37,7 +37,6 @@ class lesson {
|
||||||
$this->room = $lesson->room;
|
$this->room = $lesson->room;
|
||||||
$this->period = $lesson->period;
|
$this->period = $lesson->period;
|
||||||
$this->day = $lesson->day;
|
$this->day = $lesson->day;
|
||||||
$this->type = $lesson->type;
|
|
||||||
$this->text = "";
|
$this->text = "";
|
||||||
$this->substitution = "";
|
$this->substitution = "";
|
||||||
$this->teachera = "";
|
$this->teachera = "";
|
||||||
|
@ -52,8 +51,8 @@ class lesson {
|
||||||
$this->subjectchanged = false;
|
$this->subjectchanged = false;
|
||||||
$this->classchanged = false;
|
$this->classchanged = false;
|
||||||
$this->roomchanged = false;
|
$this->roomchanged = false;
|
||||||
$this->reason = "";
|
$this->reason = "";
|
||||||
$this->subtype = 0;
|
$this->type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,12 +70,12 @@ class lesson {
|
||||||
$this->subjecta = $substitution->subjecta;
|
$this->subjecta = $substitution->subjecta;
|
||||||
$this->classa = $substitution->classa;
|
$this->classa = $substitution->classa;
|
||||||
$this->rooma = $substitution->rooma;
|
$this->rooma = $substitution->rooma;
|
||||||
$this->teacherchanged = ($this->teacher != $this->teachera && $this->teachera) ? true : false;
|
$this->teacherchanged = ($this->teacher != $this->teachera) ? true : false;
|
||||||
$this->subjectchanged = ($this->subject != $this->subjecta && $this->subjecta) ? true : false;
|
$this->subjectchanged = ($this->subject != $this->subjecta) ? true : false;
|
||||||
$this->classchanged = (!preg_match("/(^|~)".preg_quote($this->class,"/")."($|~)/" , $this->classa ) && $this->classa) ? true : false;
|
$this->classchanged = (!preg_match("/(^|~)".preg_quote($this->class,"/")."($|~)/" , $this->classa )) ? true : false;
|
||||||
$this->roomchanged = (!preg_match("/(^|~)".preg_quote($this->room,"/")."($|~)/" , $this->rooma ) && $this->rooma) ? true : false;
|
$this->roomchanged = (!preg_match("/(^|~)".preg_quote($this->room,"/")."($|~)/" , $this->rooma )) ? true : false;
|
||||||
if ($substitution->text) $this->text .= $substitution->text;
|
if ($substitution->text) $this->text .= $substitution->text;
|
||||||
$this->subtype = $substitution->type;
|
$this->type = $substitution->type;
|
||||||
$this->substitution = "1";
|
$this->substitution = "1";
|
||||||
return 1;
|
return 1;
|
||||||
} elseif (//$this->lessonid == $substitution->lesson &&
|
} elseif (//$this->lessonid == $substitution->lesson &&
|
||||||
|
@ -95,7 +94,7 @@ class lesson {
|
||||||
$this->roomchanged = (!preg_match("/(^|~)".preg_quote($this->room,"/")."($|~)/" , $this->roomb )) ? true : false;
|
$this->roomchanged = (!preg_match("/(^|~)".preg_quote($this->room,"/")."($|~)/" , $this->roomb )) ? true : false;
|
||||||
if ($substitution->text) $this->text .= $substitution->text;
|
if ($substitution->text) $this->text .= $substitution->text;
|
||||||
// TODO Entfall, falls teacherb!=teacher bzw. class not in classb bzw. roomb!=room TODO
|
// TODO Entfall, falls teacherb!=teacher bzw. class not in classb bzw. roomb!=room TODO
|
||||||
$this->subtype = $substitution->type;
|
$this->type = $substitution->type;
|
||||||
$this->substitution = "1";
|
$this->substitution = "1";
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,9 +128,6 @@ class lesson {
|
||||||
//$this->teacher == $lesson->teacher &&
|
//$this->teacher == $lesson->teacher &&
|
||||||
$this->subject == $lesson->subject &&
|
$this->subject == $lesson->subject &&
|
||||||
$this->room == $lesson->room &&
|
$this->room == $lesson->room &&
|
||||||
$this->type == $lesson->type &&
|
|
||||||
$this->subtype == $lesson->subtype &&
|
|
||||||
//$this->teacherchanged == $lesson->teacherchanged &&
|
|
||||||
$this->text == $lesson->text) {
|
$this->text == $lesson->text) {
|
||||||
if ($this->class != $lesson->class) {
|
if ($this->class != $lesson->class) {
|
||||||
$class1parts = explode("/", $this->class);
|
$class1parts = explode("/", $this->class);
|
||||||
|
|
|
@ -1,374 +1,374 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace mod_timetable\task;
|
namespace mod_timetable\task;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An example of a scheduled task.
|
* An example of a scheduled task.
|
||||||
*/
|
*/
|
||||||
class import_data extends \core\task\scheduled_task {
|
class import_data extends \core\task\scheduled_task {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the task's name as shown in admin screens.
|
* Return the task's name as shown in admin screens.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function get_name() {
|
public function get_name() {
|
||||||
return get_string('import_data', 'mod_timetable');
|
return get_string('import_data', 'mod_timetable');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_lesson() {
|
private function read_lesson() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$lastmtime = get_config('timetable', 'lastmtime');
|
$lastmtime = get_config('timetable', 'lastmtime');
|
||||||
$filenamel = get_config('timetable', 'fname_lesson');
|
$filenamel = get_config('timetable', 'fname_lesson');
|
||||||
|
|
||||||
echo "Lastmtime = $lastmtime\n";
|
echo "Lastmtime = $lastmtime\n";
|
||||||
if ($filenamel && (file_exists ($filenamel))) {
|
if ($filenamel && (file_exists ($filenamel))) {
|
||||||
$mtime = filemtime ( $filenamel );
|
$mtime = filemtime ( $filenamel );
|
||||||
echo "mtime = $mtime\n";
|
echo "mtime = $mtime\n";
|
||||||
if ($mtime<=$lastmtime) return;
|
if ($mtime<=$lastmtime) return;
|
||||||
echo "after return\n";
|
echo "after return\n";
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_lesson", "id>0");
|
$DB->delete_records_select("timetable_lesson", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filenamel, "r");
|
$handle = @fopen($filenamel, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||||
// echo $buffer;
|
// echo $buffer;
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
$buffer = utf8_encode(rtrim($buffer));
|
||||||
$data = explode("\t", $buffer);
|
$data = explode("\t", $buffer);
|
||||||
if (count($data) != 10) throw new Exception('Wrong size of elements');
|
if (count($data) != 10) throw new Exception('Wrong size of elements');
|
||||||
$dataobject = (object)array('teacher' => $data[0],
|
$dataobject = (object)array('teacher' => $data[0],
|
||||||
'day' => $data[1],
|
'day' => $data[1],
|
||||||
'period' => $data[2],
|
'period' => $data[2],
|
||||||
'subject' => $data[3],
|
'subject' => $data[3],
|
||||||
'room' => $data[4],
|
'room' => $data[4],
|
||||||
'lessonid'=> $data[5],
|
'lessonid'=> $data[5],
|
||||||
'flag' => $data[6],
|
'flag' => $data[6],
|
||||||
'class' => $data[7],
|
'class' => $data[7],
|
||||||
'week' => $data[8],
|
'week' => $data[8],
|
||||||
'unknown' => $data[9]);
|
'unknown' => $data[9]);
|
||||||
|
|
||||||
$DB->insert_record("timetable_lesson", $dataobject);
|
$DB->insert_record("timetable_lesson", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
$lastmtime = $mtime;
|
$lastmtime = $mtime;
|
||||||
set_config('lastmtime', $lastmtime, 'timetable');
|
set_config('lastmtime', $lastmtime, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_substitution() {
|
private function read_substitution() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_substitution');
|
$filehash = get_config('timetable', 'filehash_substitution');
|
||||||
$filename = get_config('timetable', 'fname_substitution');
|
$filename = get_config('timetable', 'fname_substitution');
|
||||||
|
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
/*
|
/*
|
||||||
$max_id = 0;
|
$max_id = 0;
|
||||||
$max_changetime = 0;
|
$max_changetime = 0;
|
||||||
if ($result = $DB->get_record_sql("select max(id), max(changetime) from {$CFG->prefix}timetable_substitution")) {
|
if ($result = $DB->get_record_sql("select max(id), max(changetime) from {$CFG->prefix}timetable_substitution")) {
|
||||||
$max_id = $result->{'max(id)'};
|
$max_id = $result->{'max(id)'};
|
||||||
$max_changetime = $result->{'max(changetime)'};
|
$max_changetime = $result->{'max(changetime)'};
|
||||||
}
|
}
|
||||||
echo "Max id = $max_id\n";
|
echo "Max id = $max_id\n";
|
||||||
echo "Max changetime = $max_changetime\n";
|
echo "Max changetime = $max_changetime\n";
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_substitution", "id>0");
|
$DB->delete_records_select("timetable_substitution", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
||||||
$dataobject = (object)array('id' => $data[0],
|
$dataobject = (object)array('id' => $data[0],
|
||||||
'date' => $data[1],
|
'date' => $data[1],
|
||||||
'period' => $data[2],
|
'period' => $data[2],
|
||||||
'absence' => $data[3],
|
'absence' => $data[3],
|
||||||
'lesson' => $data[4],
|
'lesson' => $data[4],
|
||||||
'teachera' => $data[5],
|
'teachera' => $data[5],
|
||||||
'teacherb' => $data[6],
|
'teacherb' => $data[6],
|
||||||
'subjecta' => utf8_encode($data[7]),
|
'subjecta' => utf8_encode($data[7]),
|
||||||
'statistica' => $data[8],
|
'statistica' => $data[8],
|
||||||
'subjectb' => utf8_encode($data[9]),
|
'subjectb' => utf8_encode($data[9]),
|
||||||
'statisticb' => $data[10],
|
'statisticb' => $data[10],
|
||||||
'rooma' => $data[11],
|
'rooma' => $data[11],
|
||||||
'roomb' => $data[12],
|
'roomb' => $data[12],
|
||||||
'statisticflag' => $data[13],
|
'statisticflag' => $data[13],
|
||||||
'classa' => utf8_encode($data[14]),
|
'classa' => utf8_encode($data[14]),
|
||||||
'reason' => utf8_encode($data[15]),
|
'reason' => utf8_encode($data[15]),
|
||||||
'text' => utf8_encode($data[16]),
|
'text' => utf8_encode($data[16]),
|
||||||
'type' => $data[17],
|
'type' => $data[17],
|
||||||
'classb' => utf8_encode($data[18]),
|
'classb' => utf8_encode($data[18]),
|
||||||
'substitutiontype' => $data[19],
|
'substitutiontype' => $data[19],
|
||||||
'changetime' => $data[20],
|
'changetime' => $data[20],
|
||||||
'unknown' => $data[21]);
|
'unknown' => $data[21]);
|
||||||
//echo var_dump($dataobject);
|
//echo var_dump($dataobject);
|
||||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
foreach (get_object_vars($dataobject) as $key => $value) {
|
||||||
if ($value=='') unset($dataobject->{$key});
|
if ($value=='') unset($dataobject->{$key});
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if ($dataobject->id > $max_id) {
|
if ($dataobject->id > $max_id) {
|
||||||
$DB->insert_record_raw("timetable_substitution", $dataobject,false, false, true);
|
$DB->insert_record_raw("timetable_substitution", $dataobject,false, false, true);
|
||||||
echo "Object (id={$data[0]}) inserted\n";
|
echo "Object (id={$data[0]}) inserted\n";
|
||||||
} elseif ($dataobject->changetime >= $max_changetime) {
|
} elseif ($dataobject->changetime >= $max_changetime) {
|
||||||
$DB->update_record("timetable_substitution", $dataobject);
|
$DB->update_record("timetable_substitution", $dataobject);
|
||||||
echo "Object (id={$data[0]}) updated\n";
|
echo "Object (id={$data[0]}) updated\n";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
$DB->insert_record_raw("timetable_substitution", $dataobject,false, false, true);
|
$DB->insert_record_raw("timetable_substitution", $dataobject,false, false, true);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_substitution', $hash, 'timetable');
|
set_config('filehash_substitution', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_teacher() {
|
private function read_teacher() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_teacher');
|
$filehash = get_config('timetable', 'filehash_teacher');
|
||||||
$filename = get_config('timetable', 'fname_teacher');
|
$filename = get_config('timetable', 'fname_teacher');
|
||||||
echo "Filename: $filename\n";
|
echo "Filename: $filename\n";
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_teacher", "id>0");
|
$DB->delete_records_select("timetable_teacher", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filename, "r");
|
$handle = @fopen($filename, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||||
echo $buffer;
|
echo $buffer;
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
$buffer = utf8_encode(rtrim($buffer));
|
||||||
$data = explode("\t", $buffer);
|
$data = explode("\t", $buffer);
|
||||||
if (!(array_key_exists(3,$data))) {
|
if (!(array_key_exists(3,$data))) {
|
||||||
$data[3] = '';
|
$data[3] = '';
|
||||||
} else {
|
} else {
|
||||||
echo "firstname exists: $data[3]\n";
|
echo "firstname exists: $data[3]\n";
|
||||||
}
|
}
|
||||||
//if (count($data) < 3) throw new Exception('Wrong size of elements');
|
//if (count($data) < 3) throw new Exception('Wrong size of elements');
|
||||||
$dataobject = (object)array('teacher' => $data[0],
|
$dataobject = (object)array('teacher' => $data[0],
|
||||||
'surname' => $data[1],
|
'surname' => $data[1],
|
||||||
'firstname' => $data[3]);
|
'firstname' => $data[3]);
|
||||||
|
|
||||||
$DB->insert_record("timetable_teacher", $dataobject);
|
$DB->insert_record("timetable_teacher", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_teacher', $hash, 'timetable');
|
set_config('filehash_teacher', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_room() {
|
private function read_room() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_room');
|
$filehash = get_config('timetable', 'filehash_room');
|
||||||
$filename = get_config('timetable', 'fname_room');
|
$filename = get_config('timetable', 'fname_room');
|
||||||
|
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_room", "id>0");
|
$DB->delete_records_select("timetable_room", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filename, "r");
|
$handle = @fopen($filename, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||||
// echo $buffer;
|
// echo $buffer;
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
$buffer = utf8_encode(rtrim($buffer));
|
||||||
$data = explode("\t", $buffer);
|
$data = explode("\t", $buffer);
|
||||||
if (count($data) < 2) throw new Exception('Wrong size of elements');
|
if (count($data) < 2) throw new Exception('Wrong size of elements');
|
||||||
$dataobject = (object)array('room' => $data[0],
|
$dataobject = (object)array('room' => $data[0],
|
||||||
'description' => $data[1]);
|
'description' => $data[1]);
|
||||||
|
|
||||||
$DB->insert_record("timetable_room", $dataobject);
|
$DB->insert_record("timetable_room", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_room', $hash, 'timetable');
|
set_config('filehash_room', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_class() {
|
private function read_class() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_class');
|
$filehash = get_config('timetable', 'filehash_class');
|
||||||
$filename = get_config('timetable', 'fname_class');
|
$filename = get_config('timetable', 'fname_class');
|
||||||
|
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_class", "id>0");
|
$DB->delete_records_select("timetable_class", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filename, "r");
|
$handle = @fopen($filename, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||||
// echo $buffer;
|
// echo $buffer;
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
$buffer = utf8_encode(rtrim($buffer));
|
||||||
$data = explode("\t", $buffer);
|
$data = explode("\t", $buffer);
|
||||||
if (!(array_key_exists(1,$data))) $data[1] = $data[0];
|
if (!(array_key_exists(1,$data))) $data[1] = $data[0];
|
||||||
|
|
||||||
if (count($data) < 2) throw new Exception('Wrong size of elements');
|
if (count($data) < 2) throw new Exception('Wrong size of elements');
|
||||||
$dataobject = (object)array('class' => $data[0],
|
$dataobject = (object)array('class' => $data[0],
|
||||||
'description' => $data[1]);
|
'description' => $data[1]);
|
||||||
|
|
||||||
$DB->insert_record("timetable_class", $dataobject);
|
$DB->insert_record("timetable_class", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_class', $hash, 'timetable');
|
set_config('filehash_class', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_absence() {
|
private function read_absence() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_abs');
|
$filehash = get_config('timetable', 'filehash_abs');
|
||||||
$filename = get_config('timetable', 'fname_absence');
|
$filename = get_config('timetable', 'fname_absence');
|
||||||
|
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_absence", "id>0");
|
$DB->delete_records_select("timetable_absence", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filename, "r");
|
$handle = @fopen($filename, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
||||||
$dataobject = (object)array('id' => $data[0],
|
$dataobject = (object)array('id' => $data[0],
|
||||||
'type' => $data[1],
|
'type' => $data[1],
|
||||||
'name' => utf8_encode($data[2]),
|
'name' => utf8_encode($data[2]),
|
||||||
'startdate' => $data[3],
|
'startdate' => $data[3],
|
||||||
'enddate' => $data[4],
|
'enddate' => $data[4],
|
||||||
'startperiod' => $data[5],
|
'startperiod' => $data[5],
|
||||||
'endperiod' => $data[6],
|
'endperiod' => $data[6],
|
||||||
'reason' => utf8_encode($data[7]),
|
'reason' => utf8_encode($data[7]),
|
||||||
'text' => utf8_encode($data[8]));
|
'text' => utf8_encode($data[8]));
|
||||||
//echo var_dump($dataobject);
|
//echo var_dump($dataobject);
|
||||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
foreach (get_object_vars($dataobject) as $key => $value) {
|
||||||
if ($value=='') unset($dataobject->{$key});
|
if ($value=='') unset($dataobject->{$key});
|
||||||
}
|
}
|
||||||
$DB->insert_record("timetable_absence", $dataobject);
|
$DB->insert_record("timetable_absence", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_abs', $hash, 'timetable');
|
set_config('filehash_abs', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_absence_reason() {
|
private function read_absence_reason() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_absreas');
|
$filehash = get_config('timetable', 'filehash_absreas');
|
||||||
$filename = get_config('timetable', 'fname_absence_reason');
|
$filename = get_config('timetable', 'fname_absence_reason');
|
||||||
|
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_absence_reason", "id>0");
|
$DB->delete_records_select("timetable_absence_reason", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filename, "r");
|
$handle = @fopen($filename, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
|
||||||
$dataobject = (object)array('reason' => utf8_encode($data[0]),
|
$dataobject = (object)array('reason' => utf8_encode($data[0]),
|
||||||
'description' => utf8_encode($data[1]),
|
'description' => utf8_encode($data[1]),
|
||||||
'flag' => $data[2],
|
'flag' => $data[2],
|
||||||
'statistic' => $data[3]);
|
'statistic' => $data[3]);
|
||||||
//echo var_dump($dataobject);
|
//echo var_dump($dataobject);
|
||||||
foreach (get_object_vars($dataobject) as $key => $value) {
|
foreach (get_object_vars($dataobject) as $key => $value) {
|
||||||
if ($value=='') unset($dataobject->{$key});
|
if ($value=='') unset($dataobject->{$key});
|
||||||
}
|
}
|
||||||
$DB->insert_record("timetable_absence_reason", $dataobject);
|
$DB->insert_record("timetable_absence_reason", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_absreas', $hash, 'timetable');
|
set_config('filehash_absreas', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function read_times() {
|
private function read_times() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
$filehash = get_config('timetable', 'filehash_times');
|
$filehash = get_config('timetable', 'filehash_times');
|
||||||
$filename = get_config('timetable', 'fname_times');
|
$filename = get_config('timetable', 'fname_times');
|
||||||
|
|
||||||
if (!$filename || !file_exists($filename)) return;
|
if (!$filename || !file_exists($filename)) return;
|
||||||
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
if (($handle = fopen($filename, 'r')) == FALSE) return;
|
||||||
$hash = hash_file('md5', $filename);
|
$hash = hash_file('md5', $filename);
|
||||||
if ($hash == $filehash) return;
|
if ($hash == $filehash) return;
|
||||||
try {
|
try {
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
echo "before delete\n";
|
echo "before delete\n";
|
||||||
$DB->delete_records_select("timetable_time", "id>0");
|
$DB->delete_records_select("timetable_time", "id>0");
|
||||||
echo "after delete\n";
|
echo "after delete\n";
|
||||||
$handle = @fopen($filename, "r");
|
$handle = @fopen($filename, "r");
|
||||||
echo "after handle\n";
|
echo "after handle\n";
|
||||||
while (($buffer = fgets($handle, 4096)) !== false) {
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
||||||
// echo $buffer;
|
// echo $buffer;
|
||||||
$buffer = utf8_encode(rtrim($buffer));
|
$buffer = utf8_encode(rtrim($buffer));
|
||||||
$data = explode("\t", $buffer);
|
$data = explode("\t", $buffer);
|
||||||
|
|
||||||
$dataobject = (object)array('day' => $data[0],
|
$dataobject = (object)array('day' => $data[0],
|
||||||
'period' => $data[1],
|
'period' => $data[1],
|
||||||
'maxperiod' => $data[2],
|
'maxperiod' => $data[2],
|
||||||
'starttime' => $data[3],
|
'starttime' => $data[3],
|
||||||
'endtime' => $data[4]);
|
'endtime' => $data[4]);
|
||||||
|
|
||||||
$DB->insert_record("timetable_time", $dataobject);
|
$DB->insert_record("timetable_time", $dataobject);
|
||||||
}
|
}
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
set_config('filehash_times', $hash, 'timetable');
|
set_config('filehash_times', $hash, 'timetable');
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$transaction->rollback($e);
|
$transaction->rollback($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the task.
|
* Execute the task.
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
global $DB,$CFG;
|
global $DB,$CFG;
|
||||||
|
|
||||||
$this->read_lesson();
|
$this->read_lesson();
|
||||||
$this->read_substitution();
|
$this->read_substitution();
|
||||||
$this->read_teacher();
|
$this->read_teacher();
|
||||||
$this->read_room();
|
$this->read_room();
|
||||||
$this->read_class();
|
$this->read_class();
|
||||||
$this->read_absence();
|
$this->read_absence();
|
||||||
$this->read_absence_reason();
|
$this->read_absence_reason();
|
||||||
$this->read_times();
|
$this->read_times();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@ function lesson_in_lessons($obj, $array) {
|
||||||
$obj->teacher == $array[$n]->teacher &&
|
$obj->teacher == $array[$n]->teacher &&
|
||||||
$obj->subject == $array[$n]->subject &&
|
$obj->subject == $array[$n]->subject &&
|
||||||
$obj->class == $array[$n]->class &&
|
$obj->class == $array[$n]->class &&
|
||||||
$obj->room == $array[$n]->room &&
|
$obj->room == $array[$n]->room) return true;
|
||||||
$obj->type == $array[$n]->type) return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -114,30 +113,27 @@ class timetable {
|
||||||
$this->monday->sub(new \DateInterval("P".($dayofweek-1)."D"));
|
$this->monday->sub(new \DateInterval("P".($dayofweek-1)."D"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->week = intval($this->monday->format("W"));
|
$this->week = $this->monday->format("W");
|
||||||
$this->lastday = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
$this->lastday = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
||||||
$this->lastday->add(new \DateInterval("P".($this->numdayweek-1)."D"));
|
$this->lastday->add(new \DateInterval("P".($this->numdayweek-1)."D"));
|
||||||
|
|
||||||
$sql = "$this->type = '$this->name' AND NOT lessonid=0 AND (mid(week, $this->week, 1) = '1')";
|
$sql = "$this->type = '$this->name' AND NOT lessonid=0 AND (mid(week, $this->week, 1) = '1')";
|
||||||
$result = $DB->get_records_select('timetable_lesson',$sql);
|
$result = $DB->get_records_select('timetable_lesson',$sql);
|
||||||
foreach ($result as $lesson) {
|
foreach ($result as $lesson) {
|
||||||
$lesson->type = "normal";
|
|
||||||
if (!lesson_in_lessons($lesson, $this->lessons[$lesson->day][$lesson->period]))
|
if (!lesson_in_lessons($lesson, $this->lessons[$lesson->day][$lesson->period]))
|
||||||
$this->lessons[$lesson->day][$lesson->period][] = new lesson($lesson);
|
$this->lessons[$lesson->day][$lesson->period][] = new lesson($lesson);
|
||||||
}
|
}
|
||||||
$sql = "$this->type = '$this->name' AND lessonid=0 AND (mid(week, $this->week, 1) = '1')";
|
$sql = "$this->type = '$this->name' AND lessonid=0 AND (mid(week, $this->week, 1) = '1')";
|
||||||
$result = $DB->get_records_select('timetable_lesson',$sql);
|
$result = $DB->get_records_select('timetable_lesson',$sql);
|
||||||
foreach ($result as $lesson) {
|
foreach ($result as $lesson) {
|
||||||
$lesson->type = "event";
|
if (!lesson_in_lessons($lesson, $this->lessons_event[$lesson->day][$lesson->period]))
|
||||||
if (!lesson_in_lessons($lesson, $this->lessons[$lesson->day][$lesson->period]))
|
$this->lessons_event[$lesson->day][$lesson->period][] = new lesson($lesson);
|
||||||
$this->lessons[$lesson->day][$lesson->period][] = new lesson($lesson);
|
|
||||||
}
|
}
|
||||||
$sql = "$this->type = '$this->name' and (mid(week, $this->week, 1) = 'x')";
|
$sql = "$this->type = '$this->name' and (mid(week, $this->week, 1) = 'x')";
|
||||||
$result = $DB->get_records_select('timetable_lesson',$sql);
|
$result = $DB->get_records_select('timetable_lesson',$sql);
|
||||||
foreach ($result as $lesson) {
|
foreach ($result as $lesson) {
|
||||||
$lesson->type = "canceled";
|
if (!lesson_in_lessons($lesson, $this->lessons_canceled[$lesson->day][$lesson->period]))
|
||||||
if (!lesson_in_lessons($lesson, $this->lessons[$lesson->day][$lesson->period]))
|
$this->lessons_canceled[$lesson->day][$lesson->period][] = new lesson($lesson);
|
||||||
$this->lessons[$lesson->day][$lesson->period][] = new lesson($lesson);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$day = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
$day = new \DateTime($this->monday->format('Y-m-d\TH:i:sP'));
|
||||||
|
@ -148,6 +144,12 @@ class timetable {
|
||||||
foreach ($this->lessons[$i+1][$substitution->period] as $lesson) {
|
foreach ($this->lessons[$i+1][$substitution->period] as $lesson) {
|
||||||
$lesson->process_substitution($substitution);
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$types = array('teacher'=>'L', 'class'=>'K', 'room'=>'R');
|
$types = array('teacher'=>'L', 'class'=>'K', 'room'=>'R');
|
||||||
|
@ -155,8 +157,8 @@ class timetable {
|
||||||
$result = $DB->get_records_select('timetable_absence',$sql);
|
$result = $DB->get_records_select('timetable_absence',$sql);
|
||||||
foreach ($result as $absence) {
|
foreach ($result as $absence) {
|
||||||
for ($j=$absence->startperiod; $j<=$absence->endperiod; $j++) {
|
for ($j=$absence->startperiod; $j<=$absence->endperiod; $j++) {
|
||||||
foreach ($this->lessons[$i+1][$j] as $lesson) {
|
foreach ($this->lessons_event[$i+1][$j] as $lesson) {
|
||||||
if ($lesson->type == 'event') $lesson->process_absence($absence);
|
$lesson->process_absence($absence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +168,7 @@ class timetable {
|
||||||
|
|
||||||
for ($i=0; $i<$this->numdayweek; $i++) {
|
for ($i=0; $i<$this->numdayweek; $i++) {
|
||||||
foreach($this->lessons[$i+1] as &$lessons) $lessons = collapse_lessons($lessons);
|
foreach($this->lessons[$i+1] as &$lessons) $lessons = collapse_lessons($lessons);
|
||||||
// not to be done for events???
|
foreach($this->lessons_canceled[$i+1] as &$lessons) $lessons = collapse_lessons($lessons);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->type == 'teacher') {
|
if ($this->type == 'teacher') {
|
||||||
|
@ -189,6 +191,10 @@ class timetable {
|
||||||
for ($i=0; $i<$this->numdayweek; $i++) {
|
for ($i=0; $i<$this->numdayweek; $i++) {
|
||||||
foreach($this->lessons[$i+1] as $period => $lessons)
|
foreach($this->lessons[$i+1] as $period => $lessons)
|
||||||
if ($period > $maxperiod && count($lessons)) $maxperiod = $period;
|
if ($period > $maxperiod && count($lessons)) $maxperiod = $period;
|
||||||
|
foreach($this->lessons_canceled[$i+1] as $period => $lessons)
|
||||||
|
if ($period > $maxperiod && count($lessons)) $maxperiod = $period;
|
||||||
|
foreach($this->lessons_event[$i+1] as $period => $lessons)
|
||||||
|
if ($period > $maxperiod && count($lessons)) $maxperiod = $period;
|
||||||
}
|
}
|
||||||
return $maxperiod;
|
return $maxperiod;
|
||||||
}
|
}
|
||||||
|
@ -220,6 +226,40 @@ class timetable {
|
||||||
$days[$day] = array();
|
$days[$day] = array();
|
||||||
$days[$day]['substitutionold'] = "";
|
$days[$day]['substitutionold'] = "";
|
||||||
$days[$day]['lessons'] = array();
|
$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['classb'] = property_exists($lesson,'classb') ? $lesson->classb : null;
|
||||||
|
$mylesson['teacherb'] = property_exists($lesson,'teacherb') ? $lesson->teacherb : null;
|
||||||
|
$mylesson['roomb'] = property_exists($lesson,'roomb') ? $lesson->roomb : null;
|
||||||
|
$mylesson['subjectb'] = property_exists($lesson,'subjectb') ? $lesson->subjectb : null;
|
||||||
|
$mylesson['subjectchanged'] = $lesson->subjectchanged;
|
||||||
|
$mylesson['teacherchanged'] = $lesson->teacherchanged;
|
||||||
|
$mylesson['classchanged'] = $lesson->classchanged;
|
||||||
|
$mylesson['roomchanged'] = $lesson->roomchanged;
|
||||||
|
$mylesson['substitution'] = $lesson->substitution;
|
||||||
|
$mylesson['cancel'] = "";
|
||||||
|
$mylesson['cancel4me'] = "";
|
||||||
|
$mylesson['event'] = $lesson->reason ? $lesson->reason : "Event";
|
||||||
|
$mylesson['status'] = "1";
|
||||||
|
$mylesson['flag'] = "1";
|
||||||
|
$mylesson['text'] = $lesson->text;
|
||||||
|
$mylesson['subtype'] = Array();
|
||||||
|
if ($lesson->type) {
|
||||||
|
for ($i=0; $i<32; $i++) {
|
||||||
|
if ($lesson->type & (1<<$i)) $mylesson['subtype'][] = $i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$days[$day]['substitutionold'] .= $lesson->text;
|
||||||
|
$days[$day]['lessons'][] = $mylesson;
|
||||||
|
}
|
||||||
foreach ($this->lessons[$day+1][$period+1] as $lesson) {
|
foreach ($this->lessons[$day+1][$period+1] as $lesson) {
|
||||||
$mylesson = array();
|
$mylesson = array();
|
||||||
$mylesson['class'] = $lesson->class;
|
$mylesson['class'] = $lesson->class;
|
||||||
|
@ -246,25 +286,52 @@ class timetable {
|
||||||
$mylesson['flag'] = "";
|
$mylesson['flag'] = "";
|
||||||
$mylesson['text'] = $lesson->text;
|
$mylesson['text'] = $lesson->text;
|
||||||
$mylesson['subtype'] = Array();
|
$mylesson['subtype'] = Array();
|
||||||
if ($lesson->subtype) {
|
if ($lesson->type) {
|
||||||
for ($i=0; $i<32; $i++) {
|
for ($i=0; $i<32; $i++) {
|
||||||
if ($lesson->subtype & (1<<$i)) $mylesson['subtype'][] = $i+1;
|
if ($lesson->type & (1<<$i)) $mylesson['subtype'][] = $i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$days[$day]['substitutionold'] .= $lesson->text;
|
$days[$day]['substitutionold'] .= $lesson->text;
|
||||||
if ($lesson->type == 'event') {
|
$days[$day]['lessons'][] = $mylesson;
|
||||||
$mylesson['event'] = $lesson->reason ? $lesson->reason : "Event";
|
}
|
||||||
$mylesson['status'] = "1";
|
foreach ($this->lessons_canceled[$day+1][$period+1] as $lesson) {
|
||||||
$mylesson['flag'] = "1";
|
$mylesson = array();
|
||||||
} elseif ($lesson->type == 'canceled') {
|
$mylesson['class'] = $lesson->class;
|
||||||
$mylesson['cancel'] = "1";
|
$mylesson['teacher'] = $lesson->teacher;
|
||||||
$mylesson['cancel4me'] = "";
|
$mylesson['room'] = $lesson->room;
|
||||||
if (($lesson->teacherchanged && $this->type == 'teacher') ||
|
$mylesson['subject'] = $lesson->subject;
|
||||||
($lesson->classchanged && $this->type == 'class') ||
|
$mylesson['classa'] = $lesson->classa;
|
||||||
($lesson->roomchanged && $this->type == 'room')) $mylesson['cancel4me'] = "cancel4me";
|
$mylesson['teachera'] = $lesson->teachera;
|
||||||
$mylesson['status'] = "1";
|
$mylesson['rooma'] = $lesson->rooma;
|
||||||
$mylesson['flag'] = "1"; // status und flag werden vertauscht (im Template bzw. extern-lib.php
|
$mylesson['subjecta'] = $lesson->subjecta;
|
||||||
|
$mylesson['classb'] = property_exists($lesson,'classb') ? $lesson->classb : null;
|
||||||
|
$mylesson['teacherb'] = property_exists($lesson,'teacherb') ? $lesson->teacherb : null;
|
||||||
|
$mylesson['roomb'] = property_exists($lesson,'roomb') ? $lesson->roomb : null;
|
||||||
|
$mylesson['subjectb'] = property_exists($lesson,'subjectb') ? $lesson->subjectb : null;
|
||||||
|
$mylesson['substitution'] = $lesson->substitution;
|
||||||
|
$mylesson['cancel'] = "1";
|
||||||
|
$mylesson['cancel4me'] = "";
|
||||||
|
if (($lesson->teacherchanged && $this->type == 'teacher') ||
|
||||||
|
($lesson->classchanged && $this->type == 'class') ||
|
||||||
|
($lesson->roomchanged && $this->type == 'room')) $mylesson['cancel4me'] = "cancel4me";
|
||||||
|
$mylesson['subjectchanged'] = $lesson->subjectchanged;
|
||||||
|
$mylesson['teacherchanged'] = $lesson->teacherchanged;
|
||||||
|
$mylesson['classchanged'] = $lesson->classchanged;
|
||||||
|
$mylesson['roomchanged'] = $lesson->roomchanged;
|
||||||
|
#if ((property_exists($lesson,'teacherb') && $this->type == 'teacher') ||
|
||||||
|
# (property_exists($lesson,'classb') && $this->type == 'class') ||
|
||||||
|
# (property_exists($lesson,'roomb') && $this->type == 'room')) $mylesson['cancel4me'] = "cancel4me";
|
||||||
|
$mylesson['event'] = "";
|
||||||
|
$mylesson['status'] = "1";
|
||||||
|
$mylesson['flag'] = "1"; // status und flag werden vertauscht (im Template bzw. extern-lib.php
|
||||||
|
$mylesson['text'] = $lesson->text;
|
||||||
|
$mylesson['subtype'] = Array();
|
||||||
|
if ($lesson->type) {
|
||||||
|
for ($i=0; $i<32; $i++) {
|
||||||
|
if ($lesson->type & (1<<$i)) $mylesson['subtype'][] = $i+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$days[$day]['substitutionold'] .= $lesson->text;
|
||||||
$days[$day]['lessons'][] = $mylesson;
|
$days[$day]['lessons'][] = $mylesson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$capabilities = array(
|
$capabilities = array(
|
||||||
|
|
||||||
'mod/timetable:update' => array(
|
|
||||||
'riskbitmask' => RISK_XSS,
|
|
||||||
|
|
||||||
'captype' => 'write',
|
|
||||||
'contextlevel' => CONTEXT_USER,
|
|
||||||
'archetypes' => array(
|
|
||||||
'manager' => CAP_ALLOW
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
'mod/timetable:addinstance' => array(
|
'mod/timetable:addinstance' => array(
|
||||||
'riskbitmask' => RISK_XSS,
|
'riskbitmask' => RISK_XSS,
|
||||||
|
|
||||||
|
|
|
@ -40,15 +40,6 @@ $functions = array(
|
||||||
'type' => 'read',
|
'type' => 'read',
|
||||||
'ajax' => true,
|
'ajax' => true,
|
||||||
'capabilities' => array(), // capabilities required by the function.
|
'capabilities' => array(), // capabilities required by the function.
|
||||||
),
|
|
||||||
'mod_timetable_update' => array(
|
|
||||||
'classname' => 'mod_timetable_external',
|
|
||||||
'methodname' => 'update',
|
|
||||||
'classpath' => 'mod/timetable/externallib.php',
|
|
||||||
'description' => 'update timetable data',
|
|
||||||
'type' => 'write',
|
|
||||||
'ajax' => false,
|
|
||||||
'capabilities' => array(), // capabilities required by the function.
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 37 KiB |
Binary file not shown.
Before Width: | Height: | Size: 36 KiB |
Binary file not shown.
Before Width: | Height: | Size: 73 KiB |
Binary file not shown.
Before Width: | Height: | Size: 47 KiB |
465
externallib.php
465
externallib.php
|
@ -21,202 +21,139 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
require_once($CFG->libdir . "/externallib.php");
|
require_once($CFG->libdir . "/externallib.php");
|
||||||
require_once("classes/import.php");
|
|
||||||
|
|
||||||
class mod_timetable_external extends external_api {
|
class mod_timetable_external extends external_api {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns description of method parameters
|
* Returns description of method parameters
|
||||||
* @return external_function_parameters
|
* @return external_function_parameters
|
||||||
*/
|
*/
|
||||||
public static function search_parameters() {
|
public static function search_parameters() {
|
||||||
return new external_function_parameters(
|
return new external_function_parameters(
|
||||||
array('searchstring' => new external_value(PARAM_TEXT, 'The searchstring.', VALUE_DEFAULT, ''))
|
array('searchstring' => new external_value(PARAM_TEXT, 'The searchstring.', VALUE_DEFAULT, ''))
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns welcome message
|
|
||||||
* @return search result message
|
|
||||||
*/
|
|
||||||
public static function search($searchstring = 'Hello world, ') {
|
|
||||||
global $USER,$DB;
|
|
||||||
|
|
||||||
//Parameter validation
|
|
||||||
//REQUIRED
|
|
||||||
$params = self::validate_parameters(self::search_parameters(),
|
|
||||||
array('searchstring' => $searchstring));
|
|
||||||
|
|
||||||
//Context validation
|
|
||||||
//OPTIONAL but in most web service it should present
|
|
||||||
//$context = get_context_instance(CONTEXT_USER, $USER->id);
|
|
||||||
$context = context_user::instance($USER->id);
|
|
||||||
self::validate_context($context);
|
|
||||||
|
|
||||||
//Capability checking
|
|
||||||
//OPTIONAL but in most web service it should present
|
|
||||||
if (!has_capability('mod/timetable:search', $context)) {
|
|
||||||
throw new moodle_exception('cannotperformsearch');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns welcome message
|
||||||
|
* @return search result message
|
||||||
|
*/
|
||||||
|
public static function search($searchstring = 'Hello world, ') {
|
||||||
|
global $USER,$DB;
|
||||||
|
|
||||||
$results = array();
|
//Parameter validation
|
||||||
$classes = $DB->get_records_select('timetable_class', 'class like ? OR description like ? LIMIT 10', array ('%'.$params['searchstring'].'%', '%'.$params['searchstring'].'%'));
|
//REQUIRED
|
||||||
foreach($classes as $class) {
|
$params = self::validate_parameters(self::search_parameters(),
|
||||||
$result = array(
|
array('searchstring' => $searchstring));
|
||||||
'type' => 'class',
|
|
||||||
'name' => $class->class,
|
//Context validation
|
||||||
'description' => "Klassenplan: $class->description ($class->class)"
|
//OPTIONAL but in most web service it should present
|
||||||
);
|
$context = get_context_instance(CONTEXT_USER, $USER->id);
|
||||||
$results[] = $result;
|
self::validate_context($context);
|
||||||
|
|
||||||
|
//Capability checking
|
||||||
|
//OPTIONAL but in most web service it should present
|
||||||
|
if (!has_capability('mod/timetable:search', $context)) {
|
||||||
|
throw new moodle_exception('cannotperformsearch');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$results = array();
|
||||||
|
//return $params['searchstring'] . $USER->firstname ;
|
||||||
|
$classes = $DB->get_records_select('timetable_class', 'class like ? OR description like ? LIMIT 10', array ('%'.$params['searchstring'].'%', '%'.$params['searchstring'].'%'));
|
||||||
|
foreach($classes as $class) {
|
||||||
|
$result = array(
|
||||||
|
'type' => 'class',
|
||||||
|
'name' => $class->class,
|
||||||
|
'description' => "Klassenplan: $class->description ($class->class)"
|
||||||
|
);
|
||||||
|
$results[] = $result;
|
||||||
|
}
|
||||||
|
$teachers = $DB->get_records_select('timetable_teacher', 'teacher like ? OR surname like ? LIMIT 10', array ('%'.$params['searchstring'].'%', '%'.$params['searchstring'].'%'));
|
||||||
|
foreach($teachers as $teacher) {
|
||||||
|
$result = array(
|
||||||
|
'type' => 'teacher',
|
||||||
|
'name' => $teacher->teacher,
|
||||||
|
'description' => "Lehrerplan: $teacher->surname, $teacher->firstname ($teacher->teacher)"
|
||||||
|
);
|
||||||
|
$results[] = $result;
|
||||||
|
}
|
||||||
|
$rooms = $DB->get_records_select('timetable_room', 'description like ? limit 10', array ('%'.$params['searchstring'].'%'));
|
||||||
|
foreach($rooms as $room) {
|
||||||
|
$result = array(
|
||||||
|
'type' => 'room',
|
||||||
|
'name' => $room->room,
|
||||||
|
'description' => "Raumplan: ".$room->description
|
||||||
|
);
|
||||||
|
$results[] = $result;
|
||||||
|
}
|
||||||
|
//echo var_dump($results);
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
$teachers = $DB->get_records_select('timetable_teacher', 'teacher like ? OR surname like ? LIMIT 10', array ('%'.$params['searchstring'].'%', '%'.$params['searchstring'].'%'));
|
|
||||||
foreach($teachers as $teacher) {
|
|
||||||
$result = array(
|
|
||||||
'type' => 'teacher',
|
|
||||||
'name' => $teacher->teacher,
|
|
||||||
'description' => "Lehrerplan: $teacher->surname, $teacher->firstname ($teacher->teacher)"
|
|
||||||
);
|
|
||||||
$results[] = $result;
|
|
||||||
}
|
|
||||||
$rooms = $DB->get_records_select('timetable_room', 'description like ? limit 10', array ('%'.$params['searchstring'].'%'));
|
|
||||||
foreach($rooms as $room) {
|
|
||||||
$result = array(
|
|
||||||
'type' => 'room',
|
|
||||||
'name' => $room->room,
|
|
||||||
'description' => "Raumplan: ".$room->description
|
|
||||||
);
|
|
||||||
$results[] = $result;
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns description of method result value
|
* Returns description of method result value
|
||||||
* @return external_description
|
* @return external_description
|
||||||
*/
|
*/
|
||||||
public static function search_returns() {
|
public static function search_returns() {
|
||||||
//return new external_value(PARAM_TEXT, 'The search result');
|
//return new external_value(PARAM_TEXT, 'The search result');
|
||||||
return new external_multiple_structure(
|
return new external_multiple_structure(
|
||||||
new external_single_structure(
|
new external_single_structure(
|
||||||
array(
|
array(
|
||||||
'type' => new external_value(PARAM_TEXT, 'type of timetable: class, teacher, room'),
|
'type' => new external_value(PARAM_TEXT, 'type of timetable: class, teacher, room'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'value of type'),
|
'name' => new external_value(PARAM_TEXT, 'value of type'),
|
||||||
'description' => new external_value(PARAM_TEXT, 'description')
|
'description' => new external_value(PARAM_TEXT, 'description')
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns description of method parameters
|
|
||||||
* @return external_function_parameters
|
|
||||||
*/
|
|
||||||
public static function update_parameters() {
|
|
||||||
return new external_function_parameters(
|
|
||||||
array(
|
|
||||||
'files' => new external_multiple_structure(
|
|
||||||
new external_single_structure(
|
|
||||||
array(
|
|
||||||
'name' => new external_value(PARAM_TEXT, 'name of file'),
|
|
||||||
'content' => new external_value(PARAM_RAW, 'content of file')
|
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns description of method result value
|
|
||||||
* @return external_description
|
|
||||||
*/
|
|
||||||
public static function update_returns() {
|
|
||||||
return new external_multiple_structure(
|
|
||||||
new external_single_structure(
|
|
||||||
array(
|
|
||||||
'name' => new external_value(PARAM_TEXT, 'name of file'),
|
|
||||||
'result' => new external_value(PARAM_RAW, 'result message')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns description of method result value
|
|
||||||
* @return external_description
|
|
||||||
*/
|
|
||||||
public static function update($files) {
|
|
||||||
global $USER;
|
|
||||||
//Context validation
|
|
||||||
//OPTIONAL but in most web service it should present
|
|
||||||
$context = context_user::instance($USER->id);
|
|
||||||
self::validate_context($context);
|
|
||||||
|
|
||||||
//$contextmodule = context_module::instance($cm->id);
|
|
||||||
$usercontext = context_user::instance($USER->id);
|
|
||||||
|
|
||||||
//Capability checking
|
|
||||||
//OPTIONAL but in most web service it should present
|
|
||||||
if (!has_capability('mod/timetable:update', $usercontext)) {
|
|
||||||
throw new \moodle_exception('cannotupdatetimetable');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$import_data = new \mod_timetable\import_data();
|
|
||||||
return $import_data->update($files);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Returns description of method parameters
|
||||||
* Returns description of method parameters
|
* @return external_function_parameters
|
||||||
* @return external_function_parameters
|
*/
|
||||||
*/
|
public static function get_parameters() {
|
||||||
public static function get_parameters() {
|
return new external_function_parameters(
|
||||||
return new external_function_parameters(
|
array(
|
||||||
array(
|
'type' => new external_value(PARAM_TEXT, 'The type of timetable: class, teacher, room'),
|
||||||
'type' => new external_value(PARAM_TEXT, 'The type of timetable: class, teacher, room'),
|
'name' => new external_value(PARAM_TEXT, 'value of type'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'value of type'),
|
'week' => new external_value(PARAM_INT, 'The week of timetable')
|
||||||
'week' => new external_value(PARAM_INT, 'The week of timetable')
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns welcome message
|
|
||||||
* @return get result message
|
|
||||||
*/
|
|
||||||
public static function get($type,$name,$week) {
|
|
||||||
global $USER,$DB;
|
|
||||||
|
|
||||||
//Parameter validation
|
|
||||||
//REQUIRED
|
|
||||||
$params = self::validate_parameters(self::get_parameters(),
|
|
||||||
array('type' => $type, 'name'=> $name, 'week' => $week));
|
|
||||||
|
|
||||||
//Context validation
|
|
||||||
//OPTIONAL but in most web service it should present
|
|
||||||
//$context = get_context_instance(CONTEXT_USER, $USER->id);
|
|
||||||
$context = context_user::instance($USER->id);
|
|
||||||
self::validate_context($context);
|
|
||||||
|
|
||||||
//$contextmodule = context_module::instance($cm->id);
|
|
||||||
$usercontext = context_user::instance($USER->id);
|
|
||||||
|
|
||||||
//Capability checking
|
|
||||||
//OPTIONAL but in most web service it should present
|
|
||||||
if (!has_capability('mod/timetable:view'.$params['type'], $usercontext)) {
|
|
||||||
//if (!(($params['type'] == 'class') && has_capability('mod/timetable:viewownclass', $usercontext) && ($params['name'] == str_replace('_','/',$USER->department))))
|
|
||||||
if (!(($params['type'] == 'class') && ($params['name'] == str_replace('_','/',$USER->department))))
|
|
||||||
throw new \moodle_exception('cannotviewtimetable'.$params['type']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns welcome message
|
||||||
|
* @return get result message
|
||||||
|
*/
|
||||||
|
public static function get($type,$name,$week) {
|
||||||
|
global $USER,$DB;
|
||||||
|
|
||||||
|
//Parameter validation
|
||||||
|
//REQUIRED
|
||||||
|
|
||||||
|
//echo "Hallo\n";
|
||||||
|
$params = self::validate_parameters(self::get_parameters(),
|
||||||
|
array('type' => $type, 'name'=> $name, 'week' => $week));
|
||||||
|
|
||||||
|
//Context validation
|
||||||
|
//OPTIONAL but in most web service it should present
|
||||||
|
$context = get_context_instance(CONTEXT_USER, $USER->id);
|
||||||
|
self::validate_context($context);
|
||||||
|
|
||||||
|
//$contextmodule = context_module::instance($cm->id);
|
||||||
|
$usercontext = context_user::instance($USER->id);
|
||||||
|
|
||||||
|
//Capability checking
|
||||||
|
//OPTIONAL but in most web service it should present
|
||||||
|
if (!has_capability('mod/timetable:view'.$params['type'], $usercontext)) {
|
||||||
|
//if (!(($params['type'] == 'class') && has_capability('mod/timetable:viewownclass', $usercontext) && ($params['name'] == str_replace('_','/',$USER->department))))
|
||||||
|
if (!(($params['type'] == 'class') && ($params['name'] == str_replace('_','/',$USER->department))))
|
||||||
|
throw new \moodle_exception('cannotviewtimetable'.$params['type']);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ($USER->department == "Lehrer" || $USER->department == "Lehrer_fvs") {
|
if ($USER->department == "Lehrer" || $USER->department == "Lehrer_fvs") {
|
||||||
|
|
||||||
|
@ -225,99 +162,99 @@ class mod_timetable_external extends external_api {
|
||||||
} else {
|
} else {
|
||||||
throw new \moodle_exeption('Forbidden');
|
throw new \moodle_exeption('Forbidden');
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//echo "Type: ".$params['type']."\n";
|
//echo "Type: ".$params['type']."\n";
|
||||||
//echo "Name: ".$params['name']."\n";
|
//echo "Name: ".$params['name']."\n";
|
||||||
//echo "Week: ".$params['week']."\n";
|
//echo "Week: ".$params['week']."\n";
|
||||||
if(!($params['week'])) {
|
if(!($params['week'])) {
|
||||||
$today = new \DateTime();
|
$today = new \DateTime();
|
||||||
$params['week'] = $today->format("W");
|
$params['week'] = $today->format("W");
|
||||||
$dayofweek = $today->format('w');
|
$dayofweek = $today->format('w');
|
||||||
if (($dayofweek > 5 + get_config('timetable', 'saturday')) || ($dayofweek == 0)) {
|
if (($dayofweek > 5 + get_config('timetable', 'saturday')) || ($dayofweek == 0)) {
|
||||||
$params['week']++;
|
$params['week']++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ttable = new \mod_timetable\timetable($params['type'],$params['name']);
|
||||||
|
$ttable->read_db($params['week']);
|
||||||
|
//echo var_dump($ttable->prepare_output());
|
||||||
|
return $ttable->prepare_output();
|
||||||
|
//$renderable = new \mod_timetable\output\timetable($ttable);
|
||||||
|
//return $renderable->export_for_template(new \mod_timetable\output\renderer($USER,array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$ttable = new \mod_timetable\timetable($params['type'],$params['name']);
|
/**
|
||||||
$ttable->read_db($params['week']);
|
* Returns description of method result value
|
||||||
//echo var_dump($ttable->prepare_output());
|
* @return external_description
|
||||||
return $ttable->prepare_output();
|
*/
|
||||||
//$renderable = new \mod_timetable\output\timetable($ttable);
|
public static function get_returns() {
|
||||||
//return $renderable->export_for_template(new \mod_timetable\output\renderer($USER,array()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns description of method result value
|
|
||||||
* @return external_description
|
|
||||||
*/
|
|
||||||
public static function get_returns() {
|
|
||||||
|
|
||||||
|
|
||||||
return new external_single_structure(
|
return new external_single_structure(
|
||||||
array(
|
|
||||||
'periods' => new external_multiple_structure(
|
|
||||||
new external_single_structure(
|
|
||||||
array(
|
array(
|
||||||
'number' => new external_value(PARAM_INT, 'number of period'),
|
'periods' => new external_multiple_structure(
|
||||||
'starttime' => new external_value(PARAM_TEXT, 'starttime of period'),
|
new external_single_structure(
|
||||||
'endtime' => new external_value(PARAM_TEXT, 'endtime of period'),
|
|
||||||
'days' => new external_multiple_structure(
|
|
||||||
new external_single_structure(
|
|
||||||
array(
|
|
||||||
'substitutionold' => new external_value(PARAM_TEXT, 'substitution'),
|
|
||||||
'lessons' => new external_multiple_structure(
|
|
||||||
new external_single_structure(
|
|
||||||
array(
|
array(
|
||||||
'class' => new external_value(PARAM_TEXT, 'name of class'),
|
'number' => new external_value(PARAM_INT, 'number of period'),
|
||||||
'teacher' => new external_value(PARAM_TEXT, 'name of teacher'),
|
'starttime' => new external_value(PARAM_TEXT, 'starttime of period'),
|
||||||
'room' => new external_value(PARAM_TEXT, 'name of room'),
|
'endtime' => new external_value(PARAM_TEXT, 'endtime of period'),
|
||||||
'subject' => new external_value(PARAM_TEXT, 'name of subject'),
|
'days' => new external_multiple_structure(
|
||||||
'classa' => new external_value(PARAM_TEXT, 'name of class'),
|
new external_single_structure(
|
||||||
'teachera'=> new external_value(PARAM_TEXT, 'name of teacher'),
|
array(
|
||||||
'rooma' => new external_value(PARAM_TEXT, 'name of room'),
|
'substitutionold' => new external_value(PARAM_TEXT, 'substitution'),
|
||||||
'subjecta' => new external_value(PARAM_TEXT, 'name of subject'),
|
'lessons' => new external_multiple_structure(
|
||||||
'classb' => new external_value(PARAM_TEXT, 'name of class'),
|
new external_single_structure(
|
||||||
'teacherb'=> new external_value(PARAM_TEXT, 'name of teacher'),
|
array(
|
||||||
'roomb' => new external_value(PARAM_TEXT, 'name of room'),
|
'class' => new external_value(PARAM_TEXT, 'name of class'),
|
||||||
'subjectb' => new external_value(PARAM_TEXT, 'name of subject'),
|
'teacher' => new external_value(PARAM_TEXT, 'name of teacher'),
|
||||||
'classchanged' => new external_value(PARAM_BOOL, 'name of class'),
|
'room' => new external_value(PARAM_TEXT, 'name of room'),
|
||||||
'teacherchanged' => new external_value(PARAM_BOOL, 'name of teacher'),
|
'subject' => new external_value(PARAM_TEXT, 'name of subject'),
|
||||||
'roomchanged' => new external_value(PARAM_BOOL, 'name of room'),
|
'classa' => new external_value(PARAM_TEXT, 'name of class'),
|
||||||
'subjectchanged' => new external_value(PARAM_BOOL, 'name of subject'),
|
'teachera'=> new external_value(PARAM_TEXT, 'name of teacher'),
|
||||||
'substitution'=> new external_value(PARAM_TEXT, 'lesson is substitution'),
|
'rooma' => new external_value(PARAM_TEXT, 'name of room'),
|
||||||
'cancel' => new external_value(PARAM_TEXT, 'lesson is canceled'),
|
'subjecta' => new external_value(PARAM_TEXT, 'name of subject'),
|
||||||
'cancel4me' => new external_value(PARAM_TEXT, 'lesson is canceled 4 me'),
|
'classb' => new external_value(PARAM_TEXT, 'name of class'),
|
||||||
'event' => new external_value(PARAM_TEXT, 'lesson is event'),
|
'teacherb'=> new external_value(PARAM_TEXT, 'name of teacher'),
|
||||||
'status' => new external_value(PARAM_TEXT, 'status of lesson'),
|
'roomb' => new external_value(PARAM_TEXT, 'name of room'),
|
||||||
'flag' => new external_value(PARAM_TEXT, 'flag of lesson'),
|
'subjectb' => new external_value(PARAM_TEXT, 'name of subject'),
|
||||||
'text' => new external_value(PARAM_TEXT, 'description text'),
|
'classchanged' => new external_value(PARAM_BOOL, 'name of class'),
|
||||||
'subtype' => new external_multiple_structure( new external_value(PARAM_INT, 'bitnumber'))
|
'teacherchanged' => new external_value(PARAM_BOOL, 'name of teacher'),
|
||||||
//'subtype' => new external_multiple_structure( new external_value('number', PARAM_INT, 'bitnumber'))
|
'roomchanged' => new external_value(PARAM_BOOL, 'name of room'),
|
||||||
|
'subjectchanged' => new external_value(PARAM_BOOL, 'name of subject'),
|
||||||
|
'substitution'=> new external_value(PARAM_TEXT, 'lesson is substitution'),
|
||||||
|
'cancel' => new external_value(PARAM_TEXT, 'lesson is canceled'),
|
||||||
|
'cancel4me' => new external_value(PARAM_TEXT, 'lesson is canceled 4 me'),
|
||||||
|
'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'),
|
||||||
|
'text' => new external_value(PARAM_TEXT, 'description text'),
|
||||||
|
'subtype' => new external_multiple_structure( new external_value(PARAM_INT, 'bitnumber'))
|
||||||
|
//'subtype' => new external_multiple_structure( new external_value('number', PARAM_INT, 'bitnumber'))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
)
|
'type' => new external_value(PARAM_TEXT, 'The type of timetable: class, teacher, room'),
|
||||||
)
|
'viewteacher' => new external_value(PARAM_TEXT, '1 if type of timetable teacher'),
|
||||||
|
'viewclass' => new external_value(PARAM_TEXT, '1 if type of timetable class'),
|
||||||
|
'viewroom' => new external_value(PARAM_TEXT, '1 if type of timetable room'),
|
||||||
|
'name' => new external_value(PARAM_TEXT, 'value of type'),
|
||||||
|
'date' => new external_value(PARAM_TEXT, 'date'),
|
||||||
|
'description' => new external_value(PARAM_TEXT, 'description'),
|
||||||
|
'saturday' => new external_value(PARAM_INT, 'if timetable includes saturday'),
|
||||||
|
'week' => new external_value(PARAM_INT, 'The week of timetable'),
|
||||||
|
'prevweek' => new external_value(PARAM_INT, 'The next week of timetable'),
|
||||||
|
'nextweek' => new external_value(PARAM_INT, 'The prev week of timetable'),
|
||||||
|
'id' => new external_value(PARAM_TEXT, 'The id of timetable')
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
),
|
}
|
||||||
'type' => new external_value(PARAM_TEXT, 'The type of timetable: class, teacher, room'),
|
|
||||||
'viewteacher' => new external_value(PARAM_TEXT, '1 if type of timetable teacher'),
|
|
||||||
'viewclass' => new external_value(PARAM_TEXT, '1 if type of timetable class'),
|
|
||||||
'viewroom' => new external_value(PARAM_TEXT, '1 if type of timetable room'),
|
|
||||||
'name' => new external_value(PARAM_TEXT, 'value of type'),
|
|
||||||
'date' => new external_value(PARAM_TEXT, 'date'),
|
|
||||||
'description' => new external_value(PARAM_TEXT, 'description'),
|
|
||||||
'saturday' => new external_value(PARAM_INT, 'if timetable includes saturday'),
|
|
||||||
'week' => new external_value(PARAM_INT, 'The week of timetable'),
|
|
||||||
'prevweek' => new external_value(PARAM_INT, 'The next week of timetable'),
|
|
||||||
'nextweek' => new external_value(PARAM_INT, 'The prev week of timetable'),
|
|
||||||
'id' => new external_value(PARAM_TEXT, 'The id of timetable')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||||
$string['pluginname'] = 'Timetable';
|
$string['pluginname'] = 'Timetable';
|
||||||
$string['modulename'] = 'Timetable';
|
$string['modulename'] = 'Timetable';
|
||||||
$string['modulenameplural'] = 'Timetables';
|
$string['modulenameplural'] = 'Timetables';
|
||||||
$string['timetable:addinstance'] = 'add timetable';
|
|
||||||
$string['timetable:search'] = 'perform timetable search';
|
|
||||||
$string['timetable:viewclass'] = 'view class timetable';
|
|
||||||
$string['timetable:viewownclass'] = 'view own class timetable';
|
|
||||||
$string['timetable:viewroom'] = 'view room timetable';
|
|
||||||
$string['timetable:viewteacher'] = 'view teacher timetable';
|
|
||||||
$string['timetable:update'] = 'update timetable data';
|
|
||||||
$string['timetablename'] = 'Timetable';
|
$string['timetablename'] = 'Timetable';
|
||||||
$string['timetablename_help'] = 'Timetable help';
|
$string['timetablename_help'] = 'Timetable help';
|
||||||
$string['timetablefieldset'] = 'Settings';
|
$string['timetablefieldset'] = 'Settings';
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
{{#periods}}
|
{{#periods}}
|
||||||
<tr sstyle="border:1px black; padding-top:0rem; padding-bottom:0rem">
|
<tr sstyle="border:1px black; padding-top:0rem; padding-bottom:0rem">
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:;" style="color: black;" data-container="body" data-toggle="popover" data-trigger="hover focus" data-placement="top" data-html="true" data-content="{{number}}. Stunde<br/>Beginn: {{starttime}} Uhr<br/>Ende: {{endtime}} Uhr" title="{{starttime}}-{{endtime}}">
|
<a href="javascript:;" style="color: black;" data-container="body" data-toggle="popover" data-placement="top" data-html="true" data-content="{{number}}. Stunde<br/>Beginn: {{starttime}} Uhr<br/>Ende: {{endtime}} Uhr" title="{{starttime}}-{{endtime}}">
|
||||||
{{number}}
|
{{number}}
|
||||||
<div class="time" id="{{id}}">{{starttime}}-{{endtime}}</div>
|
<div class="time" id="{{id}}">{{starttime}}-{{endtime}}</div>
|
||||||
</a></td>
|
</a></td>
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
<td style="padding-top:0rem; padding-bottom:0rem; vertical-align:middle; border-left:1px black;">
|
<td style="padding-top:0rem; padding-bottom:0rem; vertical-align:middle; border-left:1px black;">
|
||||||
{{#lessons}}
|
{{#lessons}}
|
||||||
<div class="lesson {{#substitution}}substitution{{/substitution}} {{cancel4me}} {{#subtype}}subtype_{{.}} {{/subtype}}">
|
<div class="lesson {{#substitution}}substitution{{/substitution}} {{cancel4me}} {{#subtype}}subtype_{{.}} {{/subtype}}">
|
||||||
<a href="javascript:;" data-container="body" data-toggle="popover" data-trigger="hover focus" data-placement="top" data-html="true"
|
<a href="javascript:;" data-container="body" data-toggle="popover" data-placement="top" data-html="true"
|
||||||
data-content="Fach: {{subject}}
|
data-content="Fach: {{subject}}
|
||||||
{{#subjectchanged}}
|
{{#subjectchanged}}
|
||||||
{{#cancel}}{{#subjectb}} wird ersetzt durch {{subjectb}}{{/subjectb}}{{^subjectb}} entfällt{{/subjectb}}{{/cancel}}
|
{{#cancel}}{{#subjectb}} wird ersetzt durch {{subjectb}}{{/subjectb}}{{^subjectb}} entfällt{{/subjectb}}{{/cancel}}
|
||||||
|
@ -122,8 +122,6 @@ require([
|
||||||
block_timetable_type = type;
|
block_timetable_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$('[data-toggle="popover"]').popover();
|
|
||||||
|
|
||||||
//alert("Hi, this is a test");
|
//alert("Hi, this is a test");
|
||||||
$(".nextweek").click(function() {
|
$(".nextweek").click(function() {
|
||||||
load_timetable($(event.target).data('type'), $(event.target).data('name'), $(event.target).data('week'), $(event.target).data('id')); //.parentNode.parentNode.parentNode.parentNode);
|
load_timetable($(event.target).data('type'), $(event.target).data('name'), $(event.target).data('week'), $(event.target).data('id')); //.parentNode.parentNode.parentNode.parentNode);
|
||||||
|
@ -158,13 +156,7 @@ require([
|
||||||
select_type(block_timetable_type);
|
select_type(block_timetable_type);
|
||||||
} else {
|
} else {
|
||||||
select_type('subject');
|
select_type('subject');
|
||||||
};
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
$('[data-toggle="popover"]').popover();
|
|
||||||
});
|
|
||||||
|
|
||||||
//$('[data-toggle="popover"]').popover();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
{{/ js }}
|
{{/ js }}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->component = 'mod_timetable';
|
$plugin->component = 'mod_timetable';
|
||||||
$plugin->release = '0.2.0';
|
$plugin->release = '0.1.0';
|
||||||
$plugin->version = 2020120401;
|
$plugin->version = 2020112102;
|
||||||
$plugin->requires = 2020061500;
|
$plugin->requires = 2020061500;
|
||||||
$plugin->maturity = MATURITY_ALPHA;
|
$plugin->maturity = MATURITY_ALPHA;
|
||||||
|
|
Loading…
Add table
Reference in a new issue