function getQuestion($id) { $qsts = getQuestions(); foreach ($qsts as $q) { if ($q["id"] == $id) { return $q; } } return null; }
function getQuestions($pollid, $parentid = 0, $depth = 0) { global $db; $parents = $db->selectList('detailedpoll_questions', '*', "`parentid`=" . $parentid . " AND `detailedpollid` = " . (int) $pollid, "`rank` ASC"); if ($parents) { $newparents = array(); foreach ($parents as $parent) { $childs = getQuestions($pollid, $parent['questionid'], $depth + 1); $parent['depth'] = $depth; $parent['childs'] = $childs ? count($childs) : 0; $newparents[] = $parent; if ($childs) { $newparents = array_merge($newparents, $childs); } } return $newparents; } else { return false; } }
function doAction($action) { $forwardpage = ""; $forward = true; $loggedin = isUserLoggedIn(); if (!$loggedin && strcmp($action, "login") != 0 && strcmp($action, "register") != 0 && strcmp($action, "getTags") != 0) { addError("fatal", "user.unathorized"); outputJSON("error"); } else { if (strcmp($action, "login") == 0) { login(); } else { if (strcmp($action, "logout") == 0) { logout(); } else { if (strcmp($action, "isLoggedIn") == 0) { isLoggedIn(); } else { if (strcmp($action, "register") == 0) { register(); } else { if (strcmp($action, "addquestion") == 0) { addQuestion(); } else { if (strcmp($action, "getTags") == 0) { getTags(); } else { if (strcmp($action, "getquestions") == 0) { getQuestions(); } } } } } } } } }
include "includes.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <title>Conseil general - Titre du site</title> <?php include "head.php"; ?> <link rel="stylesheet" type="text/css" href="styles/mosaic.css?v=1"></link> <script src="js/mosaic.js?v=1" type="text/javascript"></script> </head> <body><div class="all" id="all-global"><?php //ORDRE DES ELEMENTS EST IMPORTANT if (strlen($cat) < 1) { $qsts = getQuestions(); if (count($qsts) < 1) { die("Pas de questions"); } $question = getCurrentQuestion(); $qstId = $question["id"]; include "mosaicContent.php"; } else { if (strpos($cat, "presentation") > -1) { list($cat, $subcat) = explode("-", $cat); include "presentation.php"; } else { include $cat . ".php"; } } ?>
<?php require_once "feeder.php"; $requests = json_decode(file_get_contents("php://input")); $gQ = getQuestions(); $output = array(); $i = 0; foreach ($gQ as $q) { $output[$i] = array("id" => $q['id'], "question" => $q['question'], "choices" => $q['choices']); $i++; } echo '{"result":' . json_encode($output) . '}';
$results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } while ($r = mysql_fetch_assoc($results)) { $rows[] = array('text' => $r["text"], 'votes' => $r["numvotes"], 'answered' => $r["answered"], 'type' => 'Q'); } } elseif ($type == 'F') { // Query Feedback and fetch results $query = sprintf("SELECT * FROM Feedback WHERE sid = %d", $sid); $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } while ($r = mysql_fetch_assoc($results)) { $rows[] = array('text' => $r["text"], 'votes' => $r["numvotes"], 'isread' => $r["isread"], 'type' => 'F'); } } mysql_close($db_conn); return $rows; } } if (isset($_POST['sid']) && isset($_POST['type'])) { $sid = $_POST['sid']; $type = $_POST['type']; $results = getQuestions($sid, $type); // Return the questions and feedback back to the calling Javascript // as a JSON object header('Content-type: application/json'); echo json_encode($results); }
<?php $apiKey = $_GET['apiKey']; $formID = $_GET['formID']; $format = $_GET['format']; $columnHeaders = $_GET['columnHeaders']; if ($formID < 1) { die("Form ID Missing!"); } include 'form_details.php'; $formTitle = getFormTitle($apiKey, $formID); $questions = getQuestions($apiKey, $formID, $columnHeaders); $submissions = getSubmissions($apiKey, $formID); switch ($format) { case 'PostgreSQL': include 'jotform_postgresqldump.php'; $sql = jotform_postgresqldump($apiKey, $format, $formTitle, $questions, $submissions); break; case 'Oracle': include 'jotform_oracledump.php'; $sql = jotform_oracledump($apiKey, $format, $formTitle, $questions, $submissions); break; case 'SQL Server': include 'jotform_sqlserverdump.php'; $sql = jotform_sqlserverdump($apiKey, $format, $formTitle, $questions, $submissions); break; case 'DB2': include 'jotform_db2dump.php'; $sql = jotform_db2dump($apiKey, $format, $formTitle, $questions, $submissions); break; case 'Sybase':
require_once "./includes/mysql.php"; include "./includes/header.php"; ?> <?php if (isset($_POST['type'])) { if ($_POST['type'] == 'ask') { postQuestion($_POST); } } $q = ''; if (isset($_GET['q']) && !is_null($_GET['q'])) { $q = $_GET['q']; $questions = getQuestions($_GET['q']); } else { $questions = getQuestions(); } ?> <div id="main-page" onload="function() {document.getElementById('autofocus').focus();}"> <div id="main-search" class="center"> <form action="index.php" method="GET"> <input autofocus="autofocus" type="text" name="q" id="search-bar" placeholder="Search question topic or content here..." value="<?php echo $q; ?> "> <input type="submit" value="Search"> </form> <p>Cannot find what you are looking for? <a href="ask.php">Ask here</a></p> </div>
} else { echo "<tr>"; } if ($feed[$row]["voted"] == 1) { echo "<td class=checked><input class=check type=checkbox id=check_" . $feed[$row]["type"] . $feed[$row]["id"] . " checked=true /></td>"; } else { echo "<td class=checked><input class=check type=checkbox id=check_" . $feed[$row]["type"] . $feed[$row]["id"] . " /></td>"; } echo "<td class=feed>" . $feed[$row]["text"] . "</td>"; if ($feed[$row]["type"] == 'Q' && $feed[$row]["answered"] == 1 || $feed[$row]["type"] == 'F' && $feed[$row]["isread"] == 1) { echo "<td class=answered>Yes</td>"; } else { echo "<td class=answered>No</td>"; } //echo "<td class=answered>".$feed[$row]["answered"]."</td>"; echo "</tr>"; } } echo "</table>"; } if (isset($_POST['sid']) && isset($_POST['filter']) && isset($_POST['sort']) && isset($_POST['uid'])) { $sid = $_POST['sid']; $filter = $_POST['filter']; $sort = $_POST['sort']; $uid = $_POST['uid']; $feed = getQuestions($sid, $filter, $sort, $uid); echoTable($feed); } ?>
session_start(); $_SESSION['player_type'] = getGenderFromType(filter_var($_POST['player_type'])); $_SESSION['play'] = true; $_SESSION['name'] = getWho($_POST['player_type']); $_SESSION['result'] = 0; echo json_encode(true); } else { session_start(); if (!isset($_SESSION['play'])) { header("location: " . URL . HOME); exit; } } if (isset($_SESSION['play'])) { $ques_type = $_SESSION['player_type']; $questions = getQuestions($ques_type); $options = getAnswerOpt($questions); $name = $_SESSION['name']; } function getGenderFromType($type) { $female = "Female"; $male = "Male"; $self = "Self"; $me = "Me"; $mother = "Wife"; $sister = "Sister"; $father = "Husband"; $brother = "Brother"; $friendMale = "Friend-male"; $friendFemale = "Friend-female";
} function echoTable($rows) { // Prints out the feed data in a nice html format echo "<table id=feedTable>"; for ($row = 0; $row < 200; $row++) { if (!empty($rows[$row])) { if ($rows[$row]["type"] == "Q") { echo "<tr class=alt>"; } else { echo "<tr>"; } echo "<td class=votes>" . $rows[$row]["votes"] . "</td>"; echo "<td class=feed>" . $rows[$row]["text"] . "</td>"; if ($rows[$row]["answered"] == 1 || $rows[$row]["isread"] == 1) { echo "<td class=checked><input class=check type=checkbox id=check_" . $rows[$row]["type"] . $rows[$row]["id"] . " checked=true /></td>"; } else { echo "<td class=checked><input class=check type=checkbox id=check_" . $rows[$row]["type"] . $rows[$row]["id"] . "/></td>"; } echo "</tr>"; } } echo "</table>"; } if (isset($_POST['sid']) && isset($_POST['filter']) && isset($_POST['sort'])) { $sid = $_POST['sid']; $filter = $_POST['filter']; $sort = $_POST['sort']; $rows = getQuestions($sid, $filter, $sort); echoTable($rows); }
function loadContestData($db) { global $tinyOrm, $config; $teamID = $_SESSION["teamID"]; $stmt = $db->prepare("UPDATE `team` SET `startTime` = NOW() WHERE `ID` = :teamID AND `startTime` IS NULL"); $stmt->execute(array("teamID" => $teamID)); if ($config->db->use == 'dynamoDB') { $stmt = $db->prepare("SELECT `startTime` FROM `team` WHERE `ID` = :teamID"); $stmt->execute(array("teamID" => $teamID)); $row = $stmt->fetchObject(); try { $tinyOrm->update('team', array('startTime' => $row->startTime), array('ID' => $teamID, 'startTime' => null)); } catch (\Aws\DynamoDb\Exception $e) { error_log($e->getMessage . " - " . $e->getCode()); error_log('DynamoDB error updating team for teamID: ' . $teamID); } } $questionsData = getQuestions($db, $_SESSION["contestID"]); //$stmt = $db->prepare("SELECT `questionID`, `answer` FROM `team_question` WHERE `teamID` = ?"); //$stmt->execute(array($teamID)); try { $results = $tinyOrm->select('team_question', array('questionID', 'answer', 'ffScore'), array('teamID' => $teamID)); } catch (\Aws\DynamoDb\Exception $e) { error_log($e->getMessage . " - " . $e->getCode()); error_log('DynamoDB error retrieving team_questions for teamID: ' . $teamID); } $answers = array(); $scores = array(); //while ($row = $stmt->fetchObject()) { foreach ($results as $row) { if (isset($row['answer'])) { $answers[$row['questionID']] = $row['answer']; } if (isset($row['ffScore'])) { $scores[$row['questionID']] = $row['ffScore']; } } $stmt = $db->prepare("SELECT TIME_TO_SEC(TIMEDIFF(NOW(), `team`.`startTime`)) as `timeUsed`, `endTime` FROM `team` WHERE `ID` = ?"); $stmt->execute(array($teamID)); $row = $stmt->fetchObject(); $_SESSION["startTime"] = time() - intval($row->timeUsed); if ($row->endTime != null) { $_SESSION["closed"] = true; } echo json_encode((object) array("success" => true, "questionsData" => $questionsData, 'scores' => $scores, "answers" => $answers, "timeUsed" => $row->timeUsed, "endTime" => $row->endTime, "teamPassword" => $_SESSION["teamPassword"])); }
public function testGetReadFeedback() { $db_conn = $this->initAndClearTables(); $this->insertSubmission($db_conn, 'F', 'test1', 2, 1, 12345); sleep(1); $this->insertSubmission($db_conn, 'Q', 'test2', 1, 1, 12345); sleep(1); $this->insertSubmission($db_conn, 'F', 'test3', 0, 1, 12345); sleep(1); $this->insertSubmission($db_conn, 'Q', 'test4', 3, 1, 23456); sleep(1); $this->insertSubmission($db_conn, 'F', 'test5', 1, 1, 12345); sleep(1); $this->insertSubmission($db_conn, 'F', 'test6', 4, 0, 23456); include_once '../../Incognito/instr/scripts/lookup_questions.php'; $feed = getQuestions(12345, "Read", "None"); $this->assertEquals(3, count($feed)); $this->assertEquals('test1', $feed[0]['text']); $this->assertEquals('test3', $feed[1]['text']); $this->assertEquals('test5', $feed[2]['text']); $feed = getQuestions(12345, "Read", "Newest"); $this->assertEquals(3, count($feed)); $this->assertEquals('test5', $feed[0]['text']); $this->assertEquals('test3', $feed[1]['text']); $this->assertEquals('test1', $feed[2]['text']); $feed = getQuestions(12345, "Read", "Priority"); $this->assertEquals(3, count($feed)); $this->assertEquals('test1', $feed[0]['text']); $this->assertEquals('test5', $feed[1]['text']); $this->assertEquals('test3', $feed[2]['text']); }
} else { $notify->add($lang->get('detailedpoll'), $lang->get('notify_send_unsuccessfull')); } } else { $notify->add($lang->get('detailedpoll'), $lang->get('notify_send_unsuccessfull_fields_missing')); $smarty->assign('values', $_POST['values']); } } if (hasVoted($pollid, $login->currentUserId())) { $smarty->assign('values', getMyAnswers($pollid, $login->currentUserId())); } $smarty->assign('sendAvailable', $poll['state'] == 1); $smarty->assign('resultAvailable', $poll['state'] >= 2); $smarty->assign('poll', $poll); if ($poll['state'] >= 2) { $questions = calculatePoll($pollid); $smarty->assign('result', getCalculatedPoll($questions)); } else { $questions = getQuestions($pollid); } $smarty->assign('questions', $questions); $colors = array(0 => '#aaa', 1 => '#bbb', 2 => '#ccc', 3 => '#ddd'); $smarty->assign('color', $colors); $smarty->assign('path', $template_dir . '/poll.tpl'); } else { $allpolls = getPolls(); $smarty->assign('polls', $allpolls); $smarty->assign('path', $template_dir . '/polls.tpl'); } break; }
$questions = 0; $questions = getQuestions($t_id); if (count($questions) == 0) { echo '<div class="h8 centered">' . Global_07 . "</div>"; } else { $topics->setTopicID($t_id); $topics->setTopic($t_id); $Topic = $topics->getTopicName(); echo "<br /><h2> " . Statistic_01 . " " . stripslashes($Topic) . "<br /></h2>"; getTopTenCorrect($questions); } break; case 'flopTen': // die 10 schlechtest beantworteten Fragen $questions = 0; $questions = getQuestions($t_id); if (count($questions) == 0) { echo '<div class="h8 centered">' . Global_07 . "</div>"; } else { $topics->setTopicID($t_id); $topics->setTopic($t_id); $Topic = $topics->getTopicName(); echo "<br /><h2> " . Statistic_02 . " " . stripslashes($Topic) . "<br /></h2>"; getFlopTenCorrects($questions); } break; case 'sortByTopic': // Fragen nach Thema sortieren $topics->getTopic(); $topicarray = $topics->getTopicArray(); $number = $qu->getNumberOfQuestions($topicarray);
function getQuestionData($statusId) { return getQuestions(getQuestionStatusById($statusId)); }
// EXPORT QUESTION GROUP BUTTON if (bHasSurveyPermission($surveyid, 'surveycontent', 'export')) { $groupsummary .= "<a href='{$scriptname}?action=exportstructureGroup&sid={$surveyid}&gid={$gid}' title=\"" . $clang->gTview("Export this question group") . "\" >" . "<img src='{$imageurl}/dumpgroup.png' title='' alt='" . $clang->gT("Export this question group") . "' name='ExportGroup' /></a>\n"; } // CHANGE QUESTION ORDER BUTTON if (bHasSurveyPermission($surveyid, 'surveycontent', 'update')) { $groupsummary .= "<img src='{$imageurl}/seperator.gif' alt='' />\n"; if ($activated != "Y" && getQuestionSum($surveyid, $gid) > 1) { // $groupsummary .= "<img src='$imageurl/blank.gif' alt='' width='40' />\n"; // $groupsummary .= "<img src='$imageurl/seperator.gif' alt='' />\n"; $groupsummary .= "<a href='{$scriptname}?action=orderquestions&sid={$surveyid}&gid={$gid}' title=\"" . $clang->gTview("Change Question Order") . "\" >" . "<img src='{$imageurl}/reorder.png' alt='" . $clang->gT("Change Question Order") . "' name='updatequestionorder' /></a>\n"; } else { $groupsummary .= "<img src='{$imageurl}/blank.gif' alt='' width='40' />\n"; } } $groupsummary .= "</div>\n" . "<div class='menubar-right'>\n" . "<span class=\"boxcaption\">" . $clang->gT("Questions") . ":</span><select class=\"listboxquestions\" name='qid' " . "onchange=\"window.open(this.options[this.selectedIndex].value, '_top')\">" . getQuestions($surveyid, $gid, $qid) . "</select>\n"; // QUICK NAVIGATION TO PREVIOUS AND NEXT QUESTION // TODO: Fix functionality to previos and next question buttons (Andrie) $QidPrev = getQidPrevious($surveyid, $gid, $qid); $groupsummary .= "<span class='arrow-wrapper'>"; if ($QidPrev != "") { $groupsummary .= "" . "<a href='{$scriptname}?sid={$surveyid}&gid={$gid}&qid={$QidPrev}'>" . "<img src='{$imageurl}/previous_20.png' title='' alt='" . $clang->gT("Previous question") . "' " . "name='questiongroupprevious'/></a>"; } else { $groupsummary .= "" . "<img src='{$imageurl}/previous_disabled_20.png' title='' alt='" . $clang->gT("No previous question") . "' " . "name='noquestionprevious' />"; } $QidNext = getQidNext($surveyid, $gid, $qid); if ($QidNext != "") { $groupsummary .= "" . "<a href='{$scriptname}?sid={$surveyid}&gid={$gid}&qid={$QidNext}'>" . "<img src='{$imageurl}/next_20.png' title='' alt='" . $clang->gT("Next question") . "' " . "name='questionnext' /> </a>"; } else { $groupsummary .= "" . "<img src='{$imageurl}/next_disabled_20.png' title='' alt='" . $clang->gT("No next question") . "' " . "name='noquestionnext' />"; }
} else { if ($mode == "aws+local") { deleteRecurse($contestLocalDir . $contestFolder); mkdir($contestLocalDir . $contestFolder, 0777, true); $publicClient->deleteMatchingObjects($publicBucket, 'contests/' . $contestFolder); } else { deleteRecurse($contestLocalDir . $contestFolder); if (!mkdir($contestLocalDir . $contestFolder, 0777, true)) { exit; } } } } if (!isset($_REQUEST['tasks'])) { // Retrieve the question's list $questions = getQuestions($db, $contestID); $questionsUrl = array(); foreach ($questions as $curQuestion) { $questionsUrl[] = $curQuestion->folder . '/' . $curQuestion->key . '/'; } emptyContestDir($contestFolder); echo json_encode(array('questionsUrl' => $questionsUrl)); exit; } if (isset($_REQUEST['tasks']) && $_REQUEST['tasks']) { $tasks = json_decode($_REQUEST['tasks'], true); emptyContestDir($contestFolder); generateContest($tasks, $contestID, $contestFolder, isset($_REQUEST['fullFeedback']) ? $_REQUEST['fullFeedback'] : false, isset($_REQUEST['status']) ? $_REQUEST['status'] : 'RunningContest'); } function contestAddContent($contestFolder, $content, &$listParts, &$buffer, &$numPart, $isLast) {
echo $iIconSize; ?> "/></a> <?php } ?> </div> <div class='menubar-right'> <label for="questionid"><?php $clang->eT("Questions:"); ?> </label> <select class="listboxquestions" name='questionid' id='questionid' onchange="window.open(this.options[this.selectedIndex].value, '_top')"> <?php echo getQuestions($surveyid, $gid, $qid); ?> </select> <span class='arrow-wrapper'> <?php if ($QidPrev != "") { ?> <a href='<?php echo $this->createUrl("admin/survey/sa/view/surveyid/" . $surveyid . "/gid/" . $gid . "/qid/" . $QidPrev); ?> '>
public function testAutoComplete() { include '../../db_credentials.php'; $db_conn = mysql_connect("cubist.cs.washington.edu", $username, $password); if (!$db_conn) { die("Could not connect"); } mysql_select_db($db_name, $db_conn); // Wipe the tables $query = "DELETE FROM Question"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } $query = "DELETE FROM Feedback"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } // Insert some test values $query = "INSERT INTO Question (text, numvotes, answered, sid) VALUES ('test1', 0, 0, 23456)"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } $query = "INSERT INTO Question (text, numvotes, answered, sid) VALUES ('test2', 1, 0, 23456)"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } $query = "INSERT INTO Question (text, numvotes, answered, sid) VALUES ('test3', 1, 0, 12345)"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } $query = "INSERT INTO Feedback (text, numvotes, isread, sid) VALUES ('test4', 0, 0, 23456)"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } $query = "INSERT INTO Feedback (text, numvotes, isread, sid) VALUES ('test5', 0, 0, 12345)"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } $query = "INSERT INTO Feedback (text, numvotes, isread, sid) VALUES ('test6', 0, 0, 23456)"; $results = mysql_query($query, $db_conn); if (!$results) { die("Error: " . mysql_error($db_conn)); } include '../../Incognito/students/scripts/studenthome_lookup_questions.php'; $array = getQuestions(23456, 'Q'); $this->assertEquals('test1', $array[0]['text']); $this->assertEquals('test2', $array[1]['text']); $this->assertEquals(2, count($array)); $array = getQuestions(12345, 'Q'); $this->assertEquals('test3', $array[0]['text']); $this->assertEquals(1, count($array)); $array = getQuestions(23456, 'F'); $this->assertEquals('test4', $array[0]['text']); $this->assertEquals('test6', $array[1]['text']); $this->assertEquals(2, count($array)); $array = getQuestions(12345, 'F'); $this->assertEquals('test5', $array[0]['text']); $this->assertEquals(1, count($array)); }
<?php require_once "feeder.php"; $requests = json_decode(file_get_contents("php://input")); $q = getQuestions(); $results = array(); $ii = 0; for ($i = 0; $i < count($requests); $i++) { for ($j = 0; $j < count($q); $j++) { if ($requests[$i]->id == $q[$j]['id']) { if ($requests[$i]->answer == $q[$j]['answer']) { $results[$ii] = array("id" => $requests[$i]->id, "result" => true); } else { $results[$ii] = array("id" => $requests[$i]->id, "result" => false, "correct_answer" => $q[$j]['answer']); } $ii++; } } } echo '{"result":' . json_encode($results) . '}';
/** * Function to render textarea for comments * @param Integer $spaceID ID of the space * @return String Generated HTML for the comments textarea */ function getInputForComments($spaceID) { $questions = getQuestions(); $html = "<h5>" . $questions['comments'] . "</h5>"; $html .= "<textarea rows='5' name='" . $spaceID . "_comments'></textarea>"; return $html; }
( "jqueryFaqSendQuestion.php", {'userQuestion' : document.getElementById('userQuestion').value }, function (data) { showModalAlert(data); window.location.reload(); } ); } </script> <div class = "container content"> <div class="titleName">FAQ</div> <?php $questions = getQuestions("answered"); foreach ($questions as $question) { ?> <h4>Вопрос:</h4> <div class = "questionDiv"> <?php echo $question['question']; ?> </div> <h4>Ответ:</h4> <div class = "answerDiv"> <?php echo $question['answer']; ?> </div> <hr>
function getContent($modus) { global $db_game, $params; $content = ""; switch ($modus) { case 'questionnaire_create': $template = tmpl_open("modules/Module_Questionnaire/templates/create.ihtml"); // Form Submitted if (isset($params->creator)) { $laufzeit = max(0, intval($params->laufzeit)); $credits = max(0, intval($params->credits)); $choices = array(); for ($i = 1; $i <= sizeof($params->choiceID); ++$i) { if ($params->choiceID[$i] == "") { break; } $choices[$i] = strval($params->choiceID[$i]); } if (!sizeof($choices)) { tmpl_set($template, "MESSAGE/message", "Keine Antworten!"); } else { $query = "INSERT INTO Questionnaire_questions " . "(questionText, expiresOn, credits) " . "VALUES ('{$params->questionText}', " . "(NOW() + INTERVAL {$laufzeit} DAY) + 0, {$credits})"; if (!$db_game->query($query)) { die("Datenbankfehler beim Eintragen der Frage!"); } $questionID = $db_game->insertID(); foreach ($choices as $key => $value) { $query = "INSERT INTO Questionnaire_choices " . "(questionID, choiceID, choiceText) " . "VALUES ({$questionID}, {$key}, '{$value}')"; if (!$db_game->query($query)) { die("Datenbankfehler beim Eintragen der Antwort [{$key}]!"); } } tmpl_set($template, "MESSAGE/message", "Frage eingetragen!"); } } else { $numChoices = intval(3 + $params->moreChoices); tmpl_set($template, "FORM/moreChoices", $numChoices); for ($i = 1; $i <= $numChoices; ++$i) { tmpl_iterate($template, 'FORM/CHOICE'); tmpl_set($template, 'FORM/CHOICE/choiceID', $i); } } $content = tmpl_parse($template); break; case 'questionnaire_report': $template = tmpl_open("modules/Module_Questionnaire/templates/report.ihtml"); if (sizeof($questions = getQuestions($db_game))) { tmpl_set($template, 'QUESTIONS/QUESTION', $questions); } if (isset($params->questionID)) { if (sizeof($report = getReport($db_game, $questions[$params->questionID]))) { tmpl_set($template, 'RESULT', $report); } } $content = tmpl_parse($template); break; case 'questionnaire_snails': $template = tmpl_open("modules/Module_Questionnaire/templates/snails.ihtml"); // Form Submitted if (isset($params->creator)) { // TODO snailNumber checken $credits = (int) $params->snailNumber; // TODO Namen checken.. zB auf % $player = $params->snailPlayer; $query = "UPDATE Player " . "SET questionCredits = questionCredits + {$credits} " . "WHERE name = '{$player}' LIMIT 1"; if (!$db_game->query($query)) { die("Datenbankfehler beim Eintragen der Schnecken!: {$query}"); } if ($db_game->affected_rows() == 1) { tmpl_set($template, 'MESSAGE/message', "'{$player}' got {$credits} more snails."); } else { tmpl_set($template, 'MESSAGE/message', "No such player: '{$player}' ?"); } } $content = tmpl_parse($template); break; case 'questionnaire_cross': $template = tmpl_open("modules/Module_Questionnaire/templates/cross.ihtml"); // Form Submitted if (isset($params->crossing)) { $sql = "SELECT a1.choiceID, a2.choiceID, COUNT(*) " . "FROM Questionnaire_answers a1 " . "LEFT JOIN Questionnaire_answers a2 " . "ON a1.playerID = a2.playerID AND " . "a2.questionID = 10 " . "WHERE a1.questionID = 20 GROUP BY a1.choiceID, a2.choiceID"; } if (sizeof($questions = getQuestions($db_game))) { tmpl_set($template, 'QUESTIONONE', $questions); tmpl_set($template, 'QUESTIONTWO', $questions); } $content = tmpl_parse($template); break; } return $content; }