Skip to content

Commit

Permalink
Rearranged course information
Browse files Browse the repository at this point in the history
Closes #24
  • Loading branch information
bohnacker committed Apr 9, 2020
1 parent 22b005b commit 852ed8a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 62 deletions.
34 changes: 0 additions & 34 deletions site/blueprints/pages/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,6 @@ columns:
required: true
query: kirby.users.filterBy("role", "editor")

supervisors:
label: Supervisors
type: tags
min: 1
required: true

major:
label: Major
type: select
required: true
default: IG
options:
IG: IG
IoT: IoT
KG: KG
PG: PG
SG: SG


semester:
label: Semester
type: select
required: true
default: "1"
options:
"1": "1"
"2": "2"
"3": "3"
"4": "4"
"5": "5"
"6": "6"
"7": "7"
"8": "8"

description:
label: Description
type: textarea
Expand Down
48 changes: 23 additions & 25 deletions site/blueprints/pages/overview.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
title: Overview

fields:
courseTitle:
label: Course Title
courseSubject:
label: Course Subject
type: text
required: true
width: 2/3
help: This will be the big title on the overview page.

allowEdit:
label: Allow Edit
type: toggle
text: Allow Students to edit their documentations?
default: true
width: 1/3
label: Allow Edit
type: toggle
text: Allow Students to edit their documentations?
default: true
width: 1/3

major:
label: Major
type: select
course:
label: Course Name
type: text
required: true
default: IG
options:
Interaktionsgestaltung: IG
Internet der Dinge: IoT
Kommunikationsgestaltung: KG
Produktgestaltung: PG
Strategische Gestaltung : SG
width: 1/2
help: The course or module name how it's listed in the curriculum.

course:
label: Course (as in curriculum)
type: text
classes:
label: Class(es)
type: tags
accept: options
required: true
options: [IG1, IG2, IG3, IG4, IG5, IG6, IG7, KG1, KG2, KG3, KG4, KG5, KG6, KG7, PG1, PG2, PG3, PG4, PG5, PG6, PG7, IoT1, IoT2, IoT3, IoT4, IoT5, IoT6, IoT7, SG1, SG2, SG3]
width: 1/2
help: The class(es) involved in the course as short names (e.g. KG4, IG3).

supervisors:
label: Supervisors
type: tags
required: true
label: Supervisors
type: tags
required: true

text:
label: Briefing
type: textarea
label: Briefing
type: textarea
10 changes: 10 additions & 0 deletions site/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
],


//------------ Panel Semesters Tag ------------
"departmentLongName" => [
"KG" => "Kommunikationsgestaltung",
"IG" => "Interaktionsgestaltung",
"PG" => "Produktgestaltung",
"IoT" => "Internet der Dinge",
"SG" => "Strategische Gestaltung",
],


//------------ Custom File DragTexts ------------
// List of elements for which the dragText should be customized
// key -> file extension or kirby defined file type NOTE: file extension gets checked before file type
Expand Down
8 changes: 7 additions & 1 deletion site/snippets/introduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
<?= page("overview")->course()->html() ?>
</p>
<p class="mb-0">
<?= $page->parent()->major()->html() . $page->parent()->semester()->html() ?>
<?php
$classes = [];
foreach(page("overview")->classes()->split() as $class) {
array_push($classes, $class);
}
echo implode(", ", $classes);
?>
</p>
</div>
<br>
Expand Down
40 changes: 38 additions & 2 deletions site/templates/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,44 @@
<a name="s-jump"></a>
<div id="row" class="row my-4 flex-column-reverse flex-md-row">
<div class="col-11 col-sm-11 col-md-6 offset-md-1 col-lg-7 offset-lg-1 col-xl-6 offset-xl-1">
<h2 class="d-none d-sm-block "><?= $page->major() ?><?= $page->course() ?></h2>
<h1 class="d-none d-sm-block "><?= $page->courseTitle() ?></h1>
<h2 class="d-none d-sm-block ">
<?php
// Make long names from classes tags. E.g. [KG3, IG2, KG4] will be transformed to
// "Kommunikationsgestaltung 3+4, Interaktionsgestaltung 2"
$classes = [];
foreach($page->classes()->split() as $class) {
// Split e.g. "IG2" into department "IG" and classNumber "2"
$department = substr($class, 0, -1);
$classNumber = substr($class, -1);
// Store everything in a dictionary, e.g. {KG:[3,4], IG:[2]}
if (array_key_exists($department, $classes)) {
$classes[$department][] = $classNumber;
} else {
$classes[$department] = [];
$classes[$department][] = $classNumber;
}
}

// Go through that dictionary and build a string of it
$result = "";
foreach ($classes as $department => $classNumbers) {
// Look up long names of the departments given in config.php
$departmentLongName = option("departmentLongName.{$department}");
$result = "{$result}{$departmentLongName} ";
// asort($classNumbers);
foreach ($classNumbers as $classNumber) {
$result = "{$result}{$classNumber}+";
}
$result = substr($result, 0, -1);
$result = "{$result}, ";
}

$result = substr($result, 0, -2);
echo $result;
?>
<?= $page->course() ?>
</h2>
<h1 class="d-none d-sm-block "><?= $page->courseSubject() ?></h1>
</div>

<div id="meta" class="col-11 col-md-3 col-lg-2 offset-md-1 pull-right">
Expand Down

0 comments on commit 852ed8a

Please sign in to comment.