A simple system for creating multiple-choice questions for an audience to answer on their phones. Responses are tallied and displayed in real-time. https://openquestion.netsyms.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

124 lines
5.7 KiB

<nav class="navbar navbar-light bg-light">
<span class="navbar-brand" href="./">
<?php
// Use custom icon if it exists
$iconsrc = "img/icon.svg";
if (file_exists(__DIR__ . "/../custom/icon.svg")) {
$iconsrc = "custom/icon.svg";
}
?>
<img src="<?php echo SITE_PATH . $iconsrc; ?>" width="30" height="30" alt="" class="mr-2 mb-1">
<?php echo SITE_TITLE; ?>
</span>
</nav>
<div class="container">
<?php if ($arg2 == "") { ?>
<?php if (!$database->has('questions', ['qcode' => $arg1])) { ?>
<div class="row justify-content-center mt-4">
<div class="col-12 col-md-6 col-lg-4">
<div class="card border-primary">
<form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
<h5 class="card-title">Enter question code:</h5>
<?php if (!isset($_SESSION['name'])) { ?>
<input type="text" class="form-control my-2" name="name" placeholder="Name" required />
<?php } ?>
<input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
<button class="btn btn-primary btn-block" type="submit">
Go
</button>
</form>
</div>
</div>
</div>
<?php
die();
}
?>
<?php
$qid = $database->get('questions', 'qid', ['qcode' => $arg1]);
?>
<h1 class="my-2 mb-4"><?php echo $database->get('questions', 'qtext', ['qid' => $qid]); ?></h1>
<div class="list-group">
<?php
$total = $database->count('responses', ['qid' => $qid]);
$answers = $database->select('answers', ['aid', 'atext'], ['qid' => $qid]);
foreach ($answers as $a) {
?>
<a class="list-group-item" href="<?php echo SITE_PATH . "vote.php?qid=$qid&aid=" . $a['aid']; ?>">
<h3 class="d-flex"><?php echo $a['atext']; ?></h3>
</a>
<?php
}
?>
</div>
<?php } else if ($arg2 == "thanks") { ?>
<div class="row justify-content-center mt-4">
<div class="col-12 col-md-6 col-lg-4">
<div class="card border-success">
<div class="card-body text-success text-center">
<span class="fas fa-check fa-10x">
</span>
<h3>Your vote was recorded!</h3>
</div>
</div>
</div>
<div class="col-12 col-md-6 col-lg-4 mt-2 mt-md-0">
<div class="card border-primary">
<form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
<h5 class="card-title">Enter question code:</h5>
<?php if (!isset($_SESSION['name'])) { ?>
<input type="text" class="form-control my-2" name="name" placeholder="Name" required />
<?php } ?>
<input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
<button class="btn btn-primary btn-block" type="submit">
Go
</button>
</form>
</div>
</div>
</div>
<?php } else if ($arg2 == "dejavu") { ?>
<div class="alert alert-danger mt-4">
<strong>Déjà vu</strong><br />It looks like you've already voted on this question.
</div>
<div class="row justify-content-center mt-4">
<div class="col-12 col-md-6 col-lg-4">
<div class="card border-primary">
<form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
<h5 class="card-title">Enter question code:</h5>
<?php if (!isset($_SESSION['name'])) { ?>
<input type="text" class="form-control my-2" name="name" placeholder="Name" required />
<?php } ?>
<input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
<button class="btn btn-primary btn-block" type="submit">
Go
</button>
</form>
</div>
</div>
</div>
<?php } else { ?>
<div class="alert alert-danger mt-4">
Something bad happened, please try your vote again.
</div>
<div class="row justify-content-center mt-4">
<div class="col-12 col-md-6 col-lg-4">
<div class="card border-primary">
<form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
<h5 class="card-title">Enter question code:</h5>
<?php if (!isset($_SESSION['name'])) { ?>
<input type="text" class="form-control my-2" name="name" placeholder="Name" required />
<?php } ?>
<input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
<button class="btn btn-primary btn-block" type="submit">
Go
</button>
</form>
</div>
</div>
</div>
<?php } ?>
</div>