Aufgaben (Task) Schnittstelle eingabaut
This commit is contained in:
@@ -48,6 +48,12 @@ class TopicData
|
||||
*/
|
||||
public string $article;
|
||||
|
||||
/**
|
||||
* @var array Alle zugehörigen Formelaufgaben als Task
|
||||
* @see Task
|
||||
*/
|
||||
private array $tasks;
|
||||
|
||||
/**
|
||||
* Erstellt ein neues Thema. Es wird noch nichts gespeichert!
|
||||
* @param string $id Innerhalb des zugehörigen Faches eindeutige ID, darf nur A-Z, a-z, 0-9 sowie - und _ enthalten
|
||||
@@ -91,6 +97,8 @@ class TopicData
|
||||
|
||||
$result->article = $article;
|
||||
|
||||
$result->tasks = array();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -193,6 +201,13 @@ class TopicData
|
||||
}
|
||||
$result->article = str_replace('$TOPICPATH', Config::getTopicDirectory($subjectId, $topicId) . "images", $article);
|
||||
|
||||
$taskJson = Util::readFileContent(Config::getTopicDirectory($subjectId, $topicId) . "tasks.json");
|
||||
if(isset($taskJson)) {
|
||||
$result->tasks = json_decode($taskJson, true);
|
||||
} else {
|
||||
$result->tasks = array();
|
||||
}
|
||||
|
||||
$result->cleanupRelatedTopics();
|
||||
$result->cleanupFiles();
|
||||
|
||||
@@ -229,8 +244,17 @@ class TopicData
|
||||
mkdir($topicDirectory, 0777, true);
|
||||
}
|
||||
|
||||
|
||||
$taskJson = json_encode($this->tasks, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
if (!$taskJson) {
|
||||
return false;
|
||||
}
|
||||
var_dump($taskJson);
|
||||
|
||||
if (!(Util::writeFileContent($topicDirectory . "properties.json", $json)
|
||||
&& Util::writeFileContent($topicDirectory . "article.html", $json))
|
||||
&& Util::writeFileContent($topicDirectory . "article.html", $json)
|
||||
//&& Util::writeFileContent($topicDirectory . "tasks.html", $taskJson)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -383,6 +407,18 @@ class TopicData
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addTask(Task $task): bool
|
||||
{
|
||||
$this->tasks[] = $task;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function removeTask(Task $task): bool
|
||||
{
|
||||
$this->tasks = array_diff($this->tasks, [$task]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
@@ -463,5 +499,13 @@ class TopicData
|
||||
$this->article = $article;
|
||||
}
|
||||
|
||||
public function getTasks(): array
|
||||
{
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
public function setTasks(array $tasks): void
|
||||
{
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user