Inhaltseditoren #87
@@ -475,6 +475,11 @@ class TopicData
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeAllTasks()
|
||||||
|
{
|
||||||
|
$this->tasks = array();
|
||||||
|
}
|
||||||
|
|
||||||
public function getId(): string
|
public function getId(): string
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once("classes/User.php");
|
require_once("classes/User.php");
|
||||||
require_once("classes/SubjectData.php");
|
require_once("classes/SubjectData.php");
|
||||||
require_once("classes/TopicData.php");
|
require_once("classes/TopicData.php");
|
||||||
|
require_once("classes/Task.php");
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ $defaultValues['description'] = "";
|
|||||||
$defaultValues['icon'] = "";
|
$defaultValues['icon'] = "";
|
||||||
$defaultValues['relatedTopics'] = "";
|
$defaultValues['relatedTopics'] = "";
|
||||||
$defaultValues['existing_files'] = "";
|
$defaultValues['existing_files'] = "";
|
||||||
|
$defaultValues['formulas'] = "";
|
||||||
$defaultValues['article'] = "";
|
$defaultValues['article'] = "";
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
@@ -37,6 +39,17 @@ if (isset($_GET['subject']) && isset($_GET['topic'])) {
|
|||||||
$defaultValues['icon'] = $editingTopic->getIcon();
|
$defaultValues['icon'] = $editingTopic->getIcon();
|
||||||
$defaultValues['relatedTopics'] = implode(", ", $editingTopic->getRelatedTopics());
|
$defaultValues['relatedTopics'] = implode(", ", $editingTopic->getRelatedTopics());
|
||||||
$defaultValues['existing_files'] = implode(", ", $editingTopic->getFiles());
|
$defaultValues['existing_files'] = implode(", ", $editingTopic->getFiles());
|
||||||
|
|
||||||
|
$tasks = array();
|
||||||
|
foreach($editingTopic->getTasks() as $task) {
|
||||||
|
$variables = array();
|
||||||
|
foreach($task->getVariables() as $name => $variable) {
|
||||||
|
$variables[] = $name . "::" . $variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tasks[] = $task->getText() . ";;" . implode(";;", $variables);
|
||||||
|
}
|
||||||
|
$defaultValues['formulas'] = implode(";;;;", $tasks);
|
||||||
$defaultValues['article'] = $editingTopic->getFinishedArticle();
|
$defaultValues['article'] = $editingTopic->getFinishedArticle();
|
||||||
}
|
}
|
||||||
} else if(isset($_GET['subject'])) {
|
} else if(isset($_GET['subject'])) {
|
||||||
@@ -68,6 +81,18 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
$errors["icon"] = "Bitte geben Sie ein Icon an.";
|
$errors["icon"] = "Bitte geben Sie ein Icon an.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($_POST['relatedTopics'])) {
|
||||||
|
$errors["relatedTopics"] = "Feld relatedTopics nicht mitgesendet!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($_POST['existing_files'])) {
|
||||||
|
$errors["existing_files"] = "Feld existing_files nicht mitgesendet!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($_POST['formulas'])) {
|
||||||
|
$errors["formulas"] = "Feld formulas nicht mitgesendet!";
|
||||||
|
}
|
||||||
|
|
||||||
if(!isset($_POST['article']) || trim($_POST['article']) == "") {
|
if(!isset($_POST['article']) || trim($_POST['article']) == "") {
|
||||||
$errors["article"] = "Bitte geben Sie einen Erklärtext an.";
|
$errors["article"] = "Bitte geben Sie einen Erklärtext an.";
|
||||||
}
|
}
|
||||||
@@ -97,6 +122,38 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
$existingFiles[] = trim($existingTopic);
|
$existingFiles[] = trim($existingTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$formulas = array();
|
||||||
|
foreach (explode(";;;;", $_POST['formulas']) as $formulaString) {
|
||||||
|
$text = false;
|
||||||
|
$answers = array();
|
||||||
|
foreach (explode(";;", $formulaString) as $formulaEntry) {
|
||||||
|
if(!$text) {
|
||||||
|
$text = trim($formulaEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$answer = explode("::", $formulaEntry);
|
||||||
|
if(count($answer) != 2) {
|
||||||
|
$errors['formulas'] = "Jede Formel muss einen Text und mindestens eine Antwortmöglichkeit haben!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$answers[trim($answer[0])] = trim($answer[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$text) {
|
||||||
|
$errors['formulas'] = "Jede Formel muss einen Text haben!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($answers) == 0) {
|
||||||
|
$errors['formulas'] = "Jede Formel muss mindestens eine Antwortmöglichkeit haben!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$formulas[] = new Task($text, $answers);
|
||||||
|
}
|
||||||
|
|
||||||
$article = htmlentities($_POST['article'], ENT_HTML401, 'UTF-8');
|
$article = htmlentities($_POST['article'], ENT_HTML401, 'UTF-8');
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->encoding = 'UTF-8';
|
$dom->encoding = 'UTF-8';
|
||||||
@@ -147,6 +204,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$newTopic->setArticle($article);
|
$newTopic->setArticle($article);
|
||||||
|
$newTopic->removeAllTasks();
|
||||||
} else {
|
} else {
|
||||||
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $relatedTopics, $article);
|
$newTopic = TopicData::createNew($_POST['id'], $_POST['subjectId'], $_POST['displayName'], $_POST['icon'], $_POST['description'], $relatedTopics, $article);
|
||||||
}
|
}
|
||||||
@@ -162,6 +220,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
$newTopic->uploadImage($name, $image);
|
$newTopic->uploadImage($name, $image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($formulas as $formula) {
|
||||||
|
$newTopic->addTask($formula);
|
||||||
|
}
|
||||||
|
|
||||||
if($_POST['submit'] == "Thema löschen") {
|
if($_POST['submit'] == "Thema löschen") {
|
||||||
$newTopic->delete();
|
$newTopic->delete();
|
||||||
header("Location: " . "subject.php?subject=" . $_POST['subjectId']);
|
header("Location: " . "subject.php?subject=" . $_POST['subjectId']);
|
||||||
@@ -275,6 +337,12 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
Übungsblätter hinzufügen</label>
|
Übungsblätter hinzufügen</label>
|
||||||
<input type="file" name="new_files[]" id="new_files" multiple>
|
<input type="file" name="new_files[]" id="new_files" multiple>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="formulas"
|
||||||
|
class="block text-sm font-medium text-gray-700">Formeln - Format: aufgabentext1;;a::2,5;;b::3;;;;aufgabentext2;;a::1</label>
|
||||||
|
<input class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm" type="text" name="formulas" id="formulas" value="<?php echo $defaultValues['formulas']; ?>">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right column - Editor -->
|
<!-- Right column - Editor -->
|
||||||
|
|||||||
Reference in New Issue
Block a user