diff --git a/webseite/config/subjects/mathe/topics/bruchrechnung/article.html b/webseite/config/subjects/mathe/topics/bruchrechnung/article.html
index 895b181..2ee652b 100644
--- a/webseite/config/subjects/mathe/topics/bruchrechnung/article.html
+++ b/webseite/config/subjects/mathe/topics/bruchrechnung/article.html
@@ -2,7 +2,7 @@ Brüche werden verwendet, um Anteile an einem Ganzen darzustellen. So kann es vo
Ein Bruch setzt sich aus einem Zähler, einem Bruchstrich und einem Nenner zusammen. Der Zähler wird über dem Bruchstrich geschrieben, der Nenner darunter.
$$
-\begin{array}{c@{\quad}l}
+\begin{array}{cl}
3 & \text{Zahler} \\
- & \text{Bruchstrich} \\
7 & \text{Nenner} \\
diff --git a/webseite/config/subjects/mathe/topics/schriftliches-dividieren/article.html b/webseite/config/subjects/mathe/topics/schriftliches-dividieren/article.html
index 10425ce..f3bfd4e 100644
--- a/webseite/config/subjects/mathe/topics/schriftliches-dividieren/article.html
+++ b/webseite/config/subjects/mathe/topics/schriftliches-dividieren/article.html
@@ -1,5 +1,5 @@
$$
-\begin{array}{r@{}r@{}r@{}r}
+\begin{array}{rrrr}
& 8 & 4 & 0 & : & 4 & = & 2&1&0 \\
\hline
- & 8 & & \\ % Erste Subtraktion
diff --git a/webseite/config/subjects/mathe/topics/schriftliches-multiplizieren/article.html b/webseite/config/subjects/mathe/topics/schriftliches-multiplizieren/article.html
index f304e0b..b016f90 100644
--- a/webseite/config/subjects/mathe/topics/schriftliches-multiplizieren/article.html
+++ b/webseite/config/subjects/mathe/topics/schriftliches-multiplizieren/article.html
@@ -2,7 +2,7 @@ Kommen wir nun zur schriftlichen Multiplikation: Das Ziel dieses Artikels ist es
$$
-\begin{array}{r@{}r@{}r@{}r}
+\begin{array}{rrrr}
& 1 & 2 & \times & 3 & 2 & \\ \hline % mal 32
& & & 3 & 6 \\ % 12 * 2 = 36
+ &&&& 2 & 4 \\ \hline % 12 * 3 mit Zehnerstelle = 240
@@ -23,7 +23,7 @@ Das Ergebnis ist somit 12 · 32 = 384.
Ein weiteres Beispiel
$$
-\begin{array}{r@{}r@{}r@{}r@{}r@{}r}
+\begin{array}{rrrrr}
2 & 8 & 4 & 6 & 8 & \times & 1 & 6 \\ \hline % mal 16
&& \textcolor{red}{2} & \textcolor{red}{8} & \textcolor{red}{4} & \textcolor{red}{6} & \textcolor{red}{8} \\ % 28468 * 6 (Einerstelle)
+ && \textcolor{green}{1} & \textcolor{green}{7} & \textcolor{green}{0} & \textcolor{green}{8} & \textcolor{green}{0} & \textcolor{green}{8} \\ \hline % 28468 * 10 (Zehnerstelle)
diff --git a/webseite/topic.php b/webseite/topic.php
index 5e8c2b7..240a92f 100644
--- a/webseite/topic.php
+++ b/webseite/topic.php
@@ -30,8 +30,29 @@ if (!isset($topicData)) {
-
+
+
+
+
+
+
+
diff --git a/webseite/topicEditor.php b/webseite/topicEditor.php
index bf9ee4a..bfa7149 100644
--- a/webseite/topicEditor.php
+++ b/webseite/topicEditor.php
@@ -8,12 +8,88 @@ require_once("classes/TopicData.php");
$allSubjects = SubjectData::getAll();
$editingTopic = null;
+$defaultValues = array();
+$defaultValues['displayName'] = "";
+$defaultValues['id'] = "";
+$defaultValues['subjectId'] = "";
+$defaultValues['description'] = "";
+$defaultValues['icon'] = "";
+$defaultValues['relatedTopics'] = "";
+$defaultValues['article'] = "";
+
+$errors = array();
+
if (isset($_GET['subjectId']) && isset($_GET['topicId'])) {
if (isset($allSubjects[$_GET['subjectId']]->getTopics()[$_GET['topicId']])) {
$editingTopic = $allSubjects[$_GET['subjectId']]->getTopics()[$_GET['topicId']];
+
+ $defaultValues['displayName'] = $editingTopic->getDisplayName();
+ $defaultValues['id'] = $editingTopic->getId();
+ $defaultValues['subjectId'] = $editingTopic->getSubjectId();
+ $defaultValues['description'] = $editingTopic->getDescription();
+ $defaultValues['icon'] = $editingTopic->getIcon();
+ $defaultValues['relatedTopics'] = implode(", ", $editingTopic->getRelatedTopics());
+ $defaultValues['article'] = str_replace("$$", "
$$
", $editingTopic->getFinishedArticle());
}
}
+if($_SERVER['REQUEST_METHOD'] == 'POST') {
+ foreach ($defaultValues as $key => $value) {
+ $defaultValues[$key] = $_POST[$key];
+ }
+
+ if(!isset($_POST['displayName']) || trim($_POST['displayName']) == "") {
+ $errors["displayName"] = "Bitte geben Sie einen Namen an.";
+ }
+
+ if(!isset($_POST['id']) || trim($_POST['id']) == "") {
+ $errors["id"] = "Bitte geben Sie eine ID an.";
+ }
+
+ if(!isset($_POST['subjectId']) || trim($_POST['subjectId']) == "") {
+ $errors["subjectId"] = "Bitte geben Sie ein Fach an.";
+ }
+
+ if(!isset($_POST['description']) || trim($_POST['description']) == "") {
+ $errors["description"] = "Bitte geben Sie eine Beschreibung an.";
+ }
+
+ if(!isset($_POST['icon']) || trim($_POST['icon']) == "") {
+ $errors["icon"] = "Bitte geben Sie ein Icon an.";
+ }
+
+ if(!isset($_POST['article']) || trim($_POST['article']) == "") {
+ $errors["article"] = "Bitte geben Sie einen Erklärtext an.";
+ }
+
+ if(empty($errors)) {
+ $newTopic = false;
+ if(isset($allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']])) {
+ $newTopic = $allSubjects[$_POST['subjectId']]->getTopics()[$_POST['id']];
+ $newTopic->setDisplayName($_POST['displayName']);
+ $newTopic->setSubjectId($_POST['subjectId']);
+ $newTopic->setDescription($_POST['description']);
+ $newTopic->setIcon($_POST['icon']);
+
+ $relatedTopics = array();
+ foreach (explode(",", $_POST['relatedTopics']) as $relatedTopic) {
+ $relatedTopics[] = trim($relatedTopic);
+ }
+ $newTopic->setRelatedTopics($relatedTopics);
+ $newTopic->setArticle($_POST['article']);
+ } else {
+ $newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $_POST['relatedTopics'], $_POST['article']);
+ }
+
+ if(!$newTopic) {
+ $errors["error"] = "Fehler beim Speichern des Themas.";
+ } else {
+ $newTopic->save();
+ header("Location: " . "topic.php?subject=" . $newTopic->getSubjectId() . "&topic=" . $newTopic->getId());
+ }
+ }
+
+}
?>
@@ -31,39 +107,43 @@ if (isset($_GET['subjectId']) && isset($_GET['topicId'])) {
+
+
+
+