From ea8b48b97b750e8f91b4651be5a9141401aea210 Mon Sep 17 00:00:00 2001 From: Matthias Grief Date: Mon, 23 Dec 2024 18:38:26 +0100 Subject: [PATCH] Formeln von MathJax auf KaTeX umgestellt --- .../mathe/topics/bruchrechnung/article.html | 2 +- .../schriftliches-dividieren/article.html | 2 +- .../schriftliches-multiplizieren/article.html | 4 +- webseite/topic.php | 23 ++- webseite/topicEditor.php | 149 +++++++++++++----- 5 files changed, 136 insertions(+), 44 deletions(-) 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'])) { + + + + -
+
+ class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required value=""> +
+ +
+ +
- @@ -73,32 +153,20 @@ if (isset($_GET['subjectId']) && isset($_GET['topicId'])) { + class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" required>
+ id="iconSelect" value="">
getRelatedTopics()); - } - ?>"> + name="relatedTopics" id="relatedTopicSelect" value="">
@@ -120,24 +188,16 @@ if (isset($_GET['subjectId']) && isset($_GET['topicId'])) {
- getFinishedArticle(); - $article = str_replace("$$", "
$$
", $article); - echo $article; - } - ?> +
-