diff --git a/application/controllers/jobs/ModulgrafikTest.php b/application/controllers/jobs/ModulgrafikTest.php index 7835e6ad3..8973e8f1f 100644 --- a/application/controllers/jobs/ModulgrafikTest.php +++ b/application/controllers/jobs/ModulgrafikTest.php @@ -11,10 +11,15 @@ class ModulgrafikTest extends JOB_Controller const DEFAULT_XOFFSET = 40; const DEFAULT_YOFFSET = 30; const DEFAULT_WIDTH = 160; + const DEFAULT_SEMESTER_LABEL_WIDTH = 80; + const DEFAULT_ECTS_WIDTH = 40; const DEFAULT_HEIGHT = 50; const DEFAULT_SPACING = 40; const DEFAULT_FONTSIZE = 8; + protected $curx; + protected $cury; + public function __construct() { parent::__construct(); @@ -101,6 +106,7 @@ EOSQL; } } + echo "\n\n"; if(count($errors) === 0) { $this->DrawIoLib->renderFileStart(); - - foreach($roots AS &$root) - { - $this->maxxoffset = self::DEFAULT_XOFFSET; - $this->DrawIoLib->renderDiagramStart($studienplan_id, 'Modulgrafik'); - $this->renderSemester($semster); - $this->DrawIoLib->renderDiagramEnd(); - } + $this->maxxoffset = self::DEFAULT_XOFFSET; + $this->DrawIoLib->renderDiagramStart($studienplan_id, 'Modulgrafik'); + $this->renderSemester($semester); + $this->DrawIoLib->renderDiagramEnd(); $this->DrawIoLib->renderFileEnd(); } else @@ -138,4 +140,30 @@ EOSQL; echo "Keine LVs gefunden.\n"; } } + + protected function renderSemester($semester) + { + $cury = self::DEFAULT_YOFFSET; + + foreach($semester as $sem => $mods) + { + $curx = self::DEFAULT_XOFFSET; + $id = uniqid(); + $ects = 30; //TODO calc + $this->DrawIoLib->renderSemesterLabel($id, $sem, $ects, self::DEFAULT_XOFFSET, $cury, self::DEFAULT_SEMESTER_LABEL_WIDTH, self::DEFAULT_HEIGHT); + $curx += self::DEFAULT_SEMESTER_LABEL_WIDTH + self::DEFAULT_SPACING; + $maxmodulheight = 0; + foreach($mods as $mod) + { + $modid = uniqid(); + $size = $this->DrawIoLib->renderModulList($modid, $mod, $curx, $cury, self::DEFAULT_ECTS_WIDTH, self::DEFAULT_HEIGHT); + $curx += $size->width + self::DEFAULT_SPACING; + if( $size->height > $maxmodulheight) + { + $maxmodulheight = $size->height; + } + } + $cury += $maxmodulheight + self::DEFAULT_SPACING; + } + } } diff --git a/application/libraries/DrawIoLib.php b/application/libraries/DrawIoLib.php index 91bf36d64..bafd062c2 100644 --- a/application/libraries/DrawIoLib.php +++ b/application/libraries/DrawIoLib.php @@ -108,4 +108,48 @@ EDGEPOINTS; EDGE; } + + public function renderSemesterLabel($id, $sem, $ects, $x, $y, $width, $height) + { + echo << + + + +EOTEXT; + } + + public function renderModulList($listid, $mod, $x, $y, $ects_width, $lv_height) + { + $width = ceil($mod->ects * $ects_width); + $height = (count($mod->childs) + 1) * $lv_height; + $modul_ects = (int) $mod->ects; + echo << + + + + +EOLIST; + + $childnumber = 0; + foreach ($mod->childs as $child) + { + $childnumber++; + $childid = uniqid(); + $childheight = $childnumber * $lv_height; + $child_ects = (int) $child->ects; + echo << + + +EOLISTITEM; + + } + + return (object) array( + 'width' => $width, + 'height' => $height + ); + } }