<?php include '../config.php'; include '../functions.php'; updateQuestion($_POST['question']);
createQuestionForm(); } break; case "list-question": if ($v == "search") { echoQuestionList(getQuestionListBySearch($r['search'])); } else { echoQuestionList(getQuestionList()); } break; case "edit-question": $q = getQuestionByID($r['edit-question']); createQuestionForm(true, $r['edit-question'], $q['question'], $q['display'], $q['answers'], $q['search']); break; case "update-question": if (!updateQuestion($v, $r['text'], $r['display'], $r['answers'], $r['search'])) { echo 'fehler beim bearbeiten der frage'; } else { echo "änderungen wurden gespeichert"; } echoQuestionList(getQuestionList()); break; case "delete-question": if ($r['accept'] && $r['submit'] == "ja") { deleteQuestion($v); echo "frage wurde gelöscht"; echoQuestionList(getQuestionList()); } else { if ($v && $r['submit'] == "nein") { echoQuestionList(getQuestionList()); } else {
function checkAnswer($qid, $answer, $exam) { $json = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://afsaccess2.njit.edu/~ls339/cs490/back/beta/model.php"); curl_setopt($ch, CURLOPT_URL, "http://afsaccess2.njit.edu/~es66/gettestquestions.php"); curl_setopt($ch, CURLOPT_POST, 1); //curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=getQuestions"); curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=getQuestions"); // fix me curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); $decoded_json = json_decode($output); //echo count($decoded_json); for ($i = 0; $i < count($decoded_json); $i++) { if ($decoded_json[$i]->{"qid"} == $qid) { $db_answer = $decoded_json[$i]->{"answer"}; } } if ($db_answer == $answer) { $result = "ok"; updateQuestion($qid, 1, $exam); } else { $result = "bad"; updateQuestion($qid, 0, $exam); } //echo "input qid ".$qid."<br>"; //echo "input answer ".$answer."<br>"; //echo "db answer ".$db_answer."<br>"; $json["qid"] = $qid; $json["yourAnswer"] = $answer; $json["realAnswer"] = $db_answer; $json["result"] = $result; echo json_encode($json); }
<?php function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_POST['type'] == 'question') { $question['name'] = test_input($_POST['name']); $question['email'] = test_input($_POST['email']); $question['topic'] = test_input($_POST['topic']); $question['content'] = test_input($_POST['content']); $question['q_id'] = $_POST['q_id']; updateQuestion($question); } else { $answer['q_id'] = $_GET['q_id']; $answer['name'] = test_input($_POST['name']); $answer['email'] = test_input($_POST['email']); $answer['content'] = test_input($_POST['content']); addAnswer($answer); } } ?> <?php $q_id = $_GET['q_id']; $question = getQuestion($q_id); $tabAnswer = getAnswers($q_id); $nAnswer = mysqli_num_rows($tabAnswer);
<?php include 'funciones.php'; updateQuestion();
if (isset($dataset['delete'])) { deleteQuestion($key); } $rank = $dataset['rank']; $parentid = $dataset['parentid']; $title = trim($dataset['title']); $description = $dataset['description']; $percent = $dataset['percent']; if (!parentExists($pollid, $parentid)) { $notify->add($lang->get('detailedpoll'), sprintf($lang->get('notify_parent_missing'), $parentid, $title)); } else { if ($title != '') { if ($key == 'new') { saveQuestion($pollid, $title, $description, $rank, $parentid, $percent); } else { updateQuestion($key, $title, $description, $rank, $parentid, $percent); } } } } } if ($pollid > 0) { $poll = getPollById($pollid); if ($poll) { $smarty->assign('poll', $poll); $smarty->assign('questions', getQuestions($pollid)); } } $smarty->assign('singlequestion_path', $template_dir . '/questions_single.tpl'); $smarty->assign('path', $template_dir . '/create.tpl'); break;
<!--@author : Ignatius Alriana H.M / 13513051--> <html> <head> <title>Submit Question - Simple StackExchange</title> <link rel="stylesheet" type="text/css" href="SiteStyle.css"> </head> <body> <?php include 'dbact.php'; if (!(isset($_POST['id_q']) && isset($_POST['Name']) && isset($_POST['Email']) && isset($_POST['Topic']) && isset($_POST['Content']))) { echo '<h2>Error</h2>'; header("Location: ask.php"); exit; } if ($_POST['id_q'] == '') { $id = addQuestion($_POST['Name'], $_POST['Email'], $_POST['Topic'], $_POST['Content']); $q = getLastQid(); $id_q = $q['id_q']; } else { $id = updateQuestion($_POST['id_q'], $_POST['Name'], $_POST['Email'], $_POST['Topic'], $_POST['Content']); $id_q = $_POST['id_q']; } $id_q = trim($id_q); echo $id_q; header("Location: displayQuestion.php?id_q=+" . basename($id_q) . ""); /* Redirect browser */ ?> </body> </html>