forked from nruffilo/regexquest.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestjs.php
More file actions
37 lines (33 loc) · 1.07 KB
/
questjs.php
File metadata and controls
37 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require("includes.php");
$quests = $db->query("SELECT * FROM quests WHERE status = 2");
if (count($quests) > 0) {
foreach ($quests as $quest) {
$title = str_replace(array('"','\\'),array('\"','\\\\'),$quest['title']);
$description = str_replace(array('"','\\'),array('\"','\\\\'),$quest['description']);
$difficulty = $quest['difficulty'];
echo <<<EOQUEST
quests['{$quest['safe_name']}'] = {
name: "$title - $description ($difficulty)",
questions: [
EOQUEST;
$questions = $db->query("SELECT * FROM quest_questions WHERE quest_id = {$quest['quest_id']} ORDER BY question_number ASC");
$q_text = array();
foreach($questions as $q) {
$hint = str_replace(array('"','\\'),array('\"','\\\\'),$q['hint']);
$description = str_replace(array('"','\\'),array('\"','\\\\'),$q['description']);
$answer = str_replace(array('"','\\'),array('\"','\\\\'),$q['answer']);
$qtext[] = <<<EOQUESTION
{
options:1, type: '{$q['type']}', answered:0,
hint:"$hint",
description:"$description",
answer:"$answer"
}
EOQUESTION;
}
echo implode(",",$qtext);
echo "]\n}\n";
}
}
?>