function getQuestion($id = 0) { $question_array = UpdateQuestion(); $one_question = $question_array[$id]; if ($_SESSION['givenQuestions'] == null) { $_SESSION['givenQuestions'] = []; } if (count($_SESSION['givenQuestions']) === count($question_array)) { return false; } if (array_search($id, $_SESSION['givenQuestions']) !== false) { $id++; return getQuestion($id); } else { $_SESSION['givenQuestions'][] = $id; $correct = $one_question['answers'][0]; shuffle($one_question['answers']); $_SESSION['answer'] = array_search($correct, $one_question['answers']); return $one_question; } }
function getCurrentQuestion() { //MANAGE QUESTION $questionId = -1; if (isset($_GET["id"])) { $questionId = $_GET["id"]; } else { if ($_SESSION["questionId"]) { $questionId = $_SESSION["questionId"]; } else { $qsts = getQuestions(); $questionId = $qsts[0]["id"]; } } if ($questionId <= 0) { die("No question selected"); } $_SESSION["questionId"] = $questionId; $question = getQuestion($questionId); //echo $questionId;print_r($question); return $question; }
<?php require_once "./includes/mysql.php"; include "./includes/header.php"; ?> <?php if (isset($_POST['question_id'])) { if ($_POST['type'] == 'answer') { postAnswer($_POST); } } if (!isset($_GET['id'])) { echo "<div class=\"error\">Please give us the question id so we can show you the question.</div>"; } else { $question = getQuestion($_GET['id']); $answers = getAnswers($_GET['id']); ?> <div id="question-page"> <div class="section"> <h2 class="underlined"><?php echo $question['title']; ?> </h2> <div class="question" id="question-<?php echo $question['question_id']; ?> "> <div class="row"> <div class="col vote">
include "sidebar_3332.php"; ?> <!--Body Goes Here--> <main class="mdl-layout__content"> <div class="bContent" style="text-align:left;"> <!-- InstanceBeginEditable name="Header" --> <h2 style="text-align: center; font-size: 80px; line-height: 1.3;">Practice Quiz 2</h2> <!-- InstanceEndEditable --> <?php echo "<form action='quiz_grade.php' method='post' name='quiz'> \n <h4>Double check your answers and when you are ready, press submit to review your score.</h4>\n <br />\n <br />"; $questionSet = range(1, 30); shuffle($questionSet); for ($x = 1; $x <= 10; $x++) { $id = $questionSet[$x]; $questionInfo = getQuestion($mysqli, $id, "numbers"); $question = $questionInfo['question']; $type = $questionInfo['qType']; $rightAnswers[$x] = $questionInfo['rightAnswer']; switch ($type) { case 'mc': //Multiple Choice Question $answer = mixAnswers($questionInfo, 4); echo "<P>" . $x . ". " . $question . "<BR>\n <input type='radio' name='q" . $x . "' value='" . $answer[0] . "'> a) " . $answer[0] . "<BR>\n <input type='radio' name='q" . $x . "' value='" . $answer[1] . "'> b) " . $answer[1] . "<BR>\n <input type='radio' name='q" . $x . "' value='" . $answer[2] . "'> c) " . $answer[2] . "<BR>\n <input type='radio' name='q" . $x . "' value='" . $answer[3] . "'> d) " . $answer[3] . "<BR>\n </p>\n <BR>"; break; case 'tf': //True False question $answer = mixAnswers($questionInfo, 2); echo "<P>" . $x . ". " . $question . "<BR>\n <input type='radio' name='q" . $x . "' value='" . $answer[0] . "'> a) " . $answer[0] . "<BR>\n <input type='radio' name='q" . $x . "' value='" . $answer[1] . "'> b) " . $answer[1] . "<BR>\n </p>\n <BR>"; break; case 'fr':
<?php require_once "./database.php"; ?> <?php if (isset($_POST['q_id'])) { if ($_POST['type'] == 'answer') { postAnswer($_POST); } } if (isset($_GET['q_id'])) { $q_id = $_GET['q_id']; $question = getQuestion($q_id); $answers = getAnswers($q_id); } else { die('Error Query [' . $connect->error . ']'); } ?> <script type="text/javascript"> function vote(id,type,result){ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { if(type == 'question') document.getElementById("qvote").innerHTML = xhttp.responseText; else document.getElementById("avote"+id).innerHTML = xhttp.responseText; } }
<!DOCTYPE html> <!--@author : Ignatius Alriana H.M / 13513051--> <html> <head> <title>Simple StackExcahange | Ask</title> <link rel="stylesheet" type="text/css" href="style.css"> <script type="text/javascript" src="js/validate.js"></script> </head> <?php include 'dbact.php'; $id_q = isset($_GET['id_q']) ? $_GET['id_q'] : ''; $cur = $id_q != '' ? getQuestion($id_q) : array(); $cur['Name'] = !isset($cur['Name']) ? '' : $cur['Name']; $cur['Email'] = !isset($cur['Email']) ? '' : $cur['Email']; $cur['Topic'] = !isset($cur['Topic']) ? '' : $cur['Topic']; $cur['Content'] = !isset($cur['Content']) ? '' : $cur['Content']; ?> <body> <a href="index.php"><h1>Simple StackExchange</h1></a> <?php if ($id_q == '') { echo "<h2>What's your question?</h2>"; } else { echo "<h2>Edit your question?</h2>"; } ?> <div class="garis"></div> <form action="addQuestion.php" method="post" name="ask-form"> <input type="text" name="Name" class="form-field" placeholder="Name" value="<?php
if (addNewPath(_POST('from'), _POST('to'), _POST('key'))) { echo json_encode(array("status" => 600, "message" => "Successfully Added Path")); } else { echo json_encode(array("status" => 601, "message" => "Unable to add a new path")); } break; case "removePath": //get from and to data and remove a path from the answer table if (removePath(_POST('from'), _POST('to'))) { echo json_encode(array("status" => 600, "message" => "Successfully Added")); } else { echo json_encode(array("status" => 601, "message" => "Unable to remove Path")); } break; case "showNode": $data = getQuestion(_POST('level')); if (!empty($data)) { echo json_encode(array("status" => 600, "message" => "Successfully Fetched", "html" => $data['question'])); } else { echo json_encode(array("status" => 601, "message" => "Query Failed")); } break; case "showPath": $data = showPath(_POST('from'), _POST('to')); if (!empty($data)) { echo json_encode(array("status" => 600, "message" => "Successfully Fetched", "html" => $data)); } else { echo json_encode(array("status" => 601, "message" => "Query Failed")); } break; case "initGraph":
$questionJSONObject = json_decode($requestQuestion, TRUE); $question = $questionJSONObject['question']; $hint = $questionJSONObject['hint']; $image = mb_convert_encoding($questionJSONObject['image'], 'ISO-8859-1', 'UTF-8'); $rightAnswer = mb_convert_encoding($questionJSONObject['answers']['rightAnswer'], 'ISO-8859-1', 'UTF-8'); $wrongAnswers = array(mb_convert_encoding($questionJSONObject['answers']['wrongAnswer1'], 'ISO-8859-1', 'UTF-8'), mb_convert_encoding($questionJSONObject['answers']['wrongAnswer2'], 'ISO-8859-1', 'UTF-8'), mb_convert_encoding($questionJSONObject['answers']['wrongAnswer3'], 'ISO-8859-1', 'UTF-8')); $wikilink = mb_convert_encoding($questionJSONObject['wikilink'], 'ISO-8859-1', 'UTF-8'); $rightAnswerPosition = rand(0, 3); $answerButtons[$rightAnswerPosition] = $rightAnswer; $counter = 0; for ($i = 0; $i < 4; $i++) { if ($i != $rightAnswerPosition) { $answerButtons[$i] = $wrongAnswers[$counter]; $counter++; } } return array('question' => $question, 'hint' => $hint, 'image' => $image, 'rightAnswer' => $rightAnswerPosition, 'answerButtons' => $answerButtons, 'wikilink' => $wikilink); } session_start(); $questionData = getQuestion($SID); $_SESSION['questionCounter'] = $_SESSION['questionCounter'] + 1; $_SESSION['questionData'] = $questionData; if (isset($_POST['questionCount'])) { $_SESSION['questionCount'] = $_POST['questionCount']; $_SESSION['askedQuestions'] = array(); } while (in_array($questionData['image'], $_SESSION['askedQuestions'])) { $questionData = getQuestion($SID); $_SESSION['questionData'] = $questionData; } array_push($_SESSION['askedQuestions'], $questionData['image']);
} if ($_SESSION['answer'] == $answerId) { addPoints(1); echo RESULT_OK; } else { $_SESSION['gameResult'] = RESULT_WRONG; echo RESULT_WRONG; } } $method = $_POST['method']; if (is_null($method)) { exit; } switch ($method) { case 'getQuestion': $question = getQuestion(); if ($question !== false) { include __DIR__ . '/Views/question.php'; } else { $_SESSION['gameResult'] = RESULT_OK; echo RESULT_LIMIT_REACHED; } break; case 'getPoints': echo getPoints(); break; case 'checkAnswer': checkAnswer(); break; case 'endGame': $points = getPoints();
} if (!empty($_POST['Email']) && !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['Email']))) { $error_msg[] = "That is not a valid e-mail address.\r\n"; } // if (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i', $_POST['url'])) // $error_msg[] = "Invalid website url.\r\n"; if ($error_msg == NULL && $points <= $maxPoints) { $subject = "New Wolf Hollow Volunteer Application Form Received!"; $message = "Volunteer application form details: \n\n"; foreach ($_POST as $key => $val) { if (is_array($val)) { foreach ($val as $subval) { $message .= getQuestion(ucwords($key)) . ": " . clean($subval) . "\r\n"; } } else { $message .= getQuestion(ucwords($key)) . ": " . clean($val) . "\r\n"; } } $message .= "\r\n"; $message .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\r\n"; $message .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . "\r\n"; //$message .= 'Points: '.$points; if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) { $headers = "From: {$yourEmail}\r\n"; } else { $headers = "From: {$yourWebsite} <{$yourEmail}>\r\n"; } $headers .= "Reply-To: {$_POST['Email']}\r\n"; if (mail($yourEmail, $subject, $message, $headers)) { if (!empty($thanksPage)) { header("Location: {$thanksPage}");
<body> <?php //error_reporting(E_ALL & ~E_NOTICE & -E_WARNING ); error_reporting(~E_NOTICE & ~E_WARNING); include "getQuestion.php"; //echo(getQuestion(1,1) ); ?> <?php $subject = $_POST["subject"]; $num = $_POST["num"]; if ($subject != "" && $num != "") { echo "<b>Ban dang lam bai tap mon " . $subject . "</b><br />"; $subject_id = get_subject_ID($subject); echo getQuestion($subject_id[1], $num); } else { echo "<form action=\"testmysql.php\" method=\"post\">"; echo "Ma môn hoc :<select name=\"subject\">"; echo "<option></option>"; $all_subject = get_subject_name(); $i = 1; while ($all_subject[$i] != "") { echo "<option>" . $all_subject[$i] . "</option>"; $i++; } echo "\t\t</select>"; echo "So luong cau hoi :<select name=\"num\">"; echo "<option></option>"; echo "<option>1</option>"; echo "<option>5</option>";
?> <?php if (isset($_GET['q_id'])) { $q_id = $_GET['q_id']; } else { $q_id = ''; } if ($q_id == '') { $data = array(); $data['Name'] = ''; $data['Email'] = ''; $data['Title'] = ''; $data['Content'] = ''; } else { $data = getQuestion($q_id); } ?> <script type="text/javascript"> function validateAskForm() { var re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; if (document.forms["askform"]["Name"].value == null || document.forms["askform"]["Name"].value == "" || document.forms["askform"]["Title"].value == null || document.forms["askform"]["Title"].value == "" || document.forms["askform"]["Email"].value == null || document.forms["askform"]["Email"].value == "" || document.forms["askform"]["Content"].value == null || document.forms["askform"]["Content"].value == "") { alert("All required fields must be filled out"); return false; } else if(!re.test(document.forms["askform"]["Email"].value)){ alert("Incorrect email address"); return false;
<?php require_once "../includes/dbconnection.php"; require_once "../includes/all_functions.php"; if (isset($_GET['key'])) { $key = $_GET['key']; $data = array(); $result = getQuestion($key); while ($row = $result->fetch_assoc()) { $data[] = array("Question" => $row['Question_Name'], "QuestionOption" => $row['Answer_Option'], "QuestionType" => $row['Question_Type'], "PMark" => $row['Positive_Mark'], "NMark" => $row['Negative_Mark']); } //var_dump($data); echo json_encode($data); } if (isset($connection)) { mysqli_close($connection); } ?>
//Check if the user has access to the particular level //$level = $request $userCurrentLevel = getUserCurrentLevel(); $requestLevelArray = getNodes($answer); //might be correct answer / trying to access a different level / the same level if ($userCurrentLevel == $requestLevelArray['from']) { //then user entered a correct answer $questionArray = getQuestion($requestLevelArray['to']); $CONTENT = $questionArray['question']; //update the database with the current level updateUserLevel($userCurrentLevel, $requestLevelArray['to']); } else { if ($userCurrentLevel == $requestLevelArray['to']) { //then user is trying to access the same level //$CONTENT = "You are still here"; //from the user's current level $userLevel = getUserCurrentLevel(); //get the question for the userlevel $questionArray = getQuestion($userLevel); $CONTENT = $questionArray['question']; } else { //user entered an answer that was not allowed $CONTENT = "Trying to access a restricted Level, this incident will be reported."; $userLevel = getQuestion(getUserCurrentLevel()); $CONTENT .= "<a href=\"./{$userLevel['header']}\">Click here</a> to goto your level "; //and nullify the form so that he cannot submit it $FORM = ""; } } } require_once "./template/index.php";
<!DOCTYPE html> <html lang="en"> <?php include 'header.php'; include 'functions.php'; include 'connectdb.php'; $id = $_GET["id"]; $eventSug = getEventSuggestion($id); $event = mysql_fetch_array($eventSug); $questions = getQuestion($id); ?> <body> <div id="wrapper"> <!-- Sidebar --> <?php include 'sidebar.php'; ?> <!-- /#sidebar-wrapper --> <!-- Page Content --> <div id="page-content-wrapper"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> <div class="col-lg-8"> <div class="alert alert-info"> <h1 >Etkinlik Ayarları</h1>
if ($rightAnswer) { $_SESSION["currentDifficulty"] -= 1; $_SESSION["success"] += 1; } else { $_SESSION["currentDifficulty"] -= 2; } if (count($_SESSION["askedQuestions"]) >= 3) { $testResult = $_SESSION["success"] / count($_SESSION["askedQuestions"]) * 100; echo "Твій результат: " . $testResult . "%<br />"; if ($testResult <= '50') { echo "Тобі треба серйозно вивчити цей розділ фізики!"; } else { if ($testResult > '50' && $testResult <= '90') { echo "Ти непогано знаєш цей розділ фізики! Але слід підучити..."; } else { if ($testResult > '90' && $testResult <= '100') { echo "Ти відмінно знаєш цей розділ фізики!"; } } } $query = "INSERT INTO test_results VALUES \n (NULL,\n\t '" . mysql_real_escape_string($testID) . "',\n\t '" . mysql_real_escape_string($_SESSION['ID']) . "', \n '" . mysql_real_escape_string($testResult) . "',\n\t NOW()\n );"; $res = mysql_query($query); if (false === $res) { echo mysql_error() . ": " . mysql_error() . '<br>'; die('<b>Error database SQL query</b><br>'); } } else { getQuestion(); } break; }
include "includes.php"; echo "<hr>"; $qsts = getQuestions(); var_dump($qsts); echo "<hr>QUESTIONS<hr>"; foreach ($qsts as $q) { var_dump($q); echo "<br/><br/>"; } echo "<hr>EACH QUESTIONS<hr>"; foreach ($qsts as $q) { var_dump($q["id"]); echo "<br/>"; } echo "<hr>QUESTION 76<hr>"; var_dump(getQuestion(76)); echo "<hr>CURRENT QUESTION<hr>"; var_dump(getCurrentQuestion()); echo "<hr>ITEMS<hr>"; $items = getItems(76); var_dump($items); echo "<hr>ITEM index 2<hr>"; $item = $items[2]; var_dump($item); echo "<hr>ITEM MORE OF ITEMS<hr>"; $more = getItemMore($items); var_dump($more); echo "<hr>ITEM RATE<hr>"; $voteCount = getItemRate($item); var_dump($voteCount); echo "<hr>ITEM COMMENTS<hr>";
<?php require_once "database.php"; $question_id = isset($_GET['question_id']) ? $_GET['question_id'] : ''; $data = $question_id != '' ? getQuestion($question_id) : array(); $data['name'] = !isset($data['name']) ? '' : $data['name']; $data['email'] = !isset($data['email']) ? '' : $data['email']; $data['title'] = !isset($data['title']) ? '' : $data['title']; $data['content'] = !isset($data['content']) ? '' : $data['content']; ?> <!DOCTYPE HTML> <html> <head> <title>Simple StackExchange</title> <link rel="stylesheet" href="css/style.css"> <script type="text/javascript" src="js/main.js"></script> </head> <body> <div class="container"> <div class="header"> <h1 class="center">Simple StackExchange</h1> </div> <h2 class="underline">What's your question?</h2> <form action="home.php" method="POST" onsubmit="return validateQuestionForm(this)"> <input type="text" class="form" placeholder="Name" name="name" value="<?php echo $data['name']; ?> " >
$testId = $_SESSION['active_test_id']; $timeLeft = getTestById($testId)['time_left']; $startedAt = getTestById($testId)['started_at']; $testDuration = getTestById($testId)['duration']; //list($optionId, $testData) = getQuestionFromJson($testId); $numQ = $numQuestions; $index = 0; $counter = 1; if (isset($_GET['question']) && ($_GET['question'] > 0 && $_GET['question'] < $numQ)) { $index = (int) $_GET['question']; $counter += $index; $questionId = getJsonQuestionId($index); } else { $questionId = getJsonQuestionId($index); } list($optionId, $testData) = getQuestion($testId, $questionId); //$department = getDepartment($deptId)[0]; //$course = getCourse($courseId)[0]; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <title>Select course</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet">