Teil 2 #94
@@ -202,10 +202,22 @@ class TopicData
|
|||||||
$result->article = str_replace('$TOPICPATH', Config::getTopicDirectory($subjectId, $topicId) . "images", $article);
|
$result->article = str_replace('$TOPICPATH', Config::getTopicDirectory($subjectId, $topicId) . "images", $article);
|
||||||
|
|
||||||
$taskJson = Util::readFileContent(Config::getTopicDirectory($subjectId, $topicId) . "tasks.json");
|
$taskJson = Util::readFileContent(Config::getTopicDirectory($subjectId, $topicId) . "tasks.json");
|
||||||
|
$result->tasks = array();
|
||||||
if(isset($taskJson)) {
|
if(isset($taskJson)) {
|
||||||
$result->tasks = json_decode($taskJson, true);
|
$arr = json_decode($taskJson, true);
|
||||||
} else {
|
foreach ($arr as $rawTask) {
|
||||||
$result->tasks = array();
|
$text = $rawTask["text"];
|
||||||
|
if(!isset($text)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$vars = $rawTask["vars"];
|
||||||
|
if (!isset($vars)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result->tasks[] = new Task($text, $vars);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->cleanupRelatedTopics();
|
$result->cleanupRelatedTopics();
|
||||||
@@ -244,16 +256,22 @@ class TopicData
|
|||||||
mkdir($topicDirectory, 0777, true);
|
mkdir($topicDirectory, 0777, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$taskArray = array();
|
||||||
|
foreach ($this->tasks as $task) {
|
||||||
|
$element = array();
|
||||||
|
$element["text"] = $task->getText();
|
||||||
|
$element["vars"] = $task->getVariables();
|
||||||
|
$taskArray[] = $element;
|
||||||
|
}
|
||||||
|
|
||||||
$taskJson = json_encode($this->tasks, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
$taskJson = json_encode($taskArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
if (!$taskJson) {
|
if (!$taskJson) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var_dump($taskJson);
|
|
||||||
|
|
||||||
if (!(Util::writeFileContent($topicDirectory . "properties.json", $json)
|
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)
|
&& Util::writeFileContent($topicDirectory . "tasks.json", $taskJson)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"text": "34 + 26 = ?",
|
"text": "34 + 26 = ?",
|
||||||
"vars": {
|
"vars": {
|
||||||
"?": "60",
|
"?": "60",
|
||||||
"x": "5",
|
"x": "5",
|
||||||
"y": "2"
|
"y": "2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "a + b = c",
|
||||||
|
"vars": {
|
||||||
|
"a": "1",
|
||||||
|
"b": "2",
|
||||||
|
"c": "4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Wie schreibt man nähmlich richtig?",
|
||||||
|
"vars": {
|
||||||
|
"?": "nämlich"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "a + b = c",
|
|
||||||
"vars": {
|
|
||||||
"a": "1",
|
|
||||||
"b": "2",
|
|
||||||
"c": "4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "Wie schreibt man nähmlich richtig?",
|
|
||||||
"vars": {
|
|
||||||
"?": "nämlich"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user