debugging
This commit is contained in:
parent
aefe6411a4
commit
3442e33d4e
1 changed files with 78 additions and 12 deletions
|
@ -12,6 +12,42 @@ namespace mod_timetable;
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_dup($matriz) {
|
||||||
|
$aux_ini=array();
|
||||||
|
$entrega=array();
|
||||||
|
for($n=0;$n<count($matriz);$n++) {
|
||||||
|
$aux_ini[]=serialize($matriz[$n]);
|
||||||
|
}
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class timetable
|
* Class timetable
|
||||||
*
|
*
|
||||||
|
@ -263,8 +299,11 @@ class timetable {
|
||||||
$mylesson['room'] = $lesson->room;
|
$mylesson['room'] = $lesson->room;
|
||||||
$mylesson['subject'] = $lesson->subject;
|
$mylesson['subject'] = $lesson->subject;
|
||||||
$mylesson['status'] = "";
|
$mylesson['status'] = "";
|
||||||
|
$mylesson['flag'] = "";
|
||||||
|
if ($lesson->flag) $mylesson['flag'] = $lesson->flag;
|
||||||
if ($lesson->week[$this->week-1] == 'x') {
|
if ($lesson->week[$this->week-1] == 'x') {
|
||||||
$mylesson['status'] = 1;
|
$mylesson['status'] = 1;
|
||||||
|
$mylesson['flag'] = 1;
|
||||||
/*
|
/*
|
||||||
if (array_key_exists('substitution', $this->data[$day+1][$period+1])) {
|
if (array_key_exists('substitution', $this->data[$day+1][$period+1])) {
|
||||||
foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) {
|
foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) {
|
||||||
|
@ -282,15 +321,21 @@ class timetable {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
$mylesson['flag'] = "";
|
|
||||||
if ($lesson->flag) $mylesson['flag'] = $lesson->flag;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ($this->type == 'class') $mylesson['class'] = "";
|
if ($this->type == 'class') $mylesson['class'] = "";
|
||||||
if ($this->type == 'teacher') $mylesson['teacher'] = "";
|
if ($this->type == 'teacher') $mylesson['teacher'] = "";
|
||||||
if ($this->type == 'room') $mylesson['room'] = "";
|
if ($this->type == 'room') $mylesson['room'] = "";
|
||||||
*/
|
*/
|
||||||
if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson;
|
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
|
- für diese Woche wurden keine Daten ausgegeben
|
||||||
0 in dieser Woche findet der Unterricht nicht statt
|
0 in dieser Woche findet der Unterricht nicht statt
|
||||||
|
@ -305,7 +350,14 @@ class timetable {
|
||||||
&& array_key_exists('substitution', $this->data[$day+1][$period+1])) {
|
&& array_key_exists('substitution', $this->data[$day+1][$period+1])) {
|
||||||
foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) {
|
foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) {
|
||||||
//echo "In substitution loop".$substitution->text;
|
//echo "In substitution loop".$substitution->text;
|
||||||
|
if ($days[$day]['substitution']) $days[$day]['substitution'] .= ' / ';
|
||||||
$days[$day]['substitution'] .= $substitution->text;
|
$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 &&
|
if ($substitution->subjectb &&
|
||||||
(($this->type == 'teacher' && $this->name == $substitution->teacherb) ||
|
(($this->type == 'teacher' && $this->name == $substitution->teacherb) ||
|
||||||
|
@ -313,22 +365,35 @@ class timetable {
|
||||||
($this->type == 'room' && $this->name == $substitution->roomb))
|
($this->type == 'room' && $this->name == $substitution->roomb))
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$mylesson = array();
|
|
||||||
$mylesson['class'] = $substitution->classb;
|
|
||||||
$mylesson['teacher'] = $substitution->teacherb;
|
|
||||||
$mylesson['room'] = $substitution->roomb;
|
|
||||||
$mylesson['subject'] = $substitution->subjectb;
|
|
||||||
$mylesson['status'] = "";
|
$mylesson['status'] = "";
|
||||||
$mylesson['flag'] = 1;
|
$mylesson['flag'] = 1;
|
||||||
|
|
||||||
$days[$day]['lessons'][] = $mylesson;
|
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;
|
//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 == '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] = array();
|
||||||
|
@ -340,4 +405,5 @@ class timetable {
|
||||||
return $resultdata;
|
return $resultdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue