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.

respond.php 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <nav class="navbar navbar-light bg-light">
  2. <span class="navbar-brand" href="./">
  3. <?php
  4. // Use custom icon if it exists
  5. $iconsrc = "img/icon.svg";
  6. if (file_exists(__DIR__ . "/../custom/icon.svg")) {
  7. $iconsrc = "custom/icon.svg";
  8. }
  9. ?>
  10. <img src="<?php echo SITE_PATH . $iconsrc; ?>" width="30" height="30" alt="" class="mr-2 mb-1">
  11. <?php echo SITE_TITLE; ?>
  12. </span>
  13. </nav>
  14. <div class="container">
  15. <?php if ($arg2 == "") { ?>
  16. <?php if (!$database->has('questions', ['qcode' => $arg1])) { ?>
  17. <div class="row justify-content-center mt-4">
  18. <div class="col-12 col-md-6 col-lg-4">
  19. <div class="card border-primary">
  20. <form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
  21. <h5 class="card-title">Enter question code:</h5>
  22. <?php if (!isset($_SESSION['name'])) { ?>
  23. <input type="text" class="form-control my-2" name="name" placeholder="Name" required />
  24. <?php } ?>
  25. <input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
  26. <button class="btn btn-primary btn-block" type="submit">
  27. Go
  28. </button>
  29. </form>
  30. </div>
  31. </div>
  32. </div>
  33. <?php
  34. die();
  35. }
  36. ?>
  37. <?php
  38. $qid = $database->get('questions', 'qid', ['qcode' => $arg1]);
  39. ?>
  40. <h1 class="my-2 mb-4"><?php echo $database->get('questions', 'qtext', ['qid' => $qid]); ?></h1>
  41. <div class="list-group">
  42. <?php
  43. $total = $database->count('responses', ['qid' => $qid]);
  44. $answers = $database->select('answers', ['aid', 'atext'], ['qid' => $qid]);
  45. foreach ($answers as $a) {
  46. ?>
  47. <a class="list-group-item" href="<?php echo SITE_PATH . "vote.php?qid=$qid&aid=" . $a['aid']; ?>">
  48. <h3 class="d-flex"><?php echo $a['atext']; ?></h3>
  49. </a>
  50. <?php
  51. }
  52. ?>
  53. </div>
  54. <?php } else if ($arg2 == "thanks") { ?>
  55. <div class="row justify-content-center mt-4">
  56. <div class="col-12 col-md-6 col-lg-4">
  57. <div class="card border-success">
  58. <div class="card-body text-success text-center">
  59. <span class="fas fa-check fa-10x">
  60. </span>
  61. <h3>Your vote was recorded!</h3>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="col-12 col-md-6 col-lg-4 mt-2 mt-md-0">
  66. <div class="card border-primary">
  67. <form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
  68. <h5 class="card-title">Enter question code:</h5>
  69. <?php if (!isset($_SESSION['name'])) { ?>
  70. <input type="text" class="form-control my-2" name="name" placeholder="Name" required />
  71. <?php } ?>
  72. <input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
  73. <button class="btn btn-primary btn-block" type="submit">
  74. Go
  75. </button>
  76. </form>
  77. </div>
  78. </div>
  79. </div>
  80. <?php } else if ($arg2 == "dejavu") { ?>
  81. <div class="alert alert-danger mt-4">
  82. <strong>Déjà vu</strong><br />It looks like you've already voted on this question.
  83. </div>
  84. <div class="row justify-content-center mt-4">
  85. <div class="col-12 col-md-6 col-lg-4">
  86. <div class="card border-primary">
  87. <form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
  88. <h5 class="card-title">Enter question code:</h5>
  89. <?php if (!isset($_SESSION['name'])) { ?>
  90. <input type="text" class="form-control my-2" name="name" placeholder="Name" required />
  91. <?php } ?>
  92. <input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
  93. <button class="btn btn-primary btn-block" type="submit">
  94. Go
  95. </button>
  96. </form>
  97. </div>
  98. </div>
  99. </div>
  100. <?php } else { ?>
  101. <div class="alert alert-danger mt-4">
  102. Something bad happened, please try your vote again.
  103. </div>
  104. <div class="row justify-content-center mt-4">
  105. <div class="col-12 col-md-6 col-lg-4">
  106. <div class="card border-primary">
  107. <form class="card-body" action="<?php echo SITE_PATH; ?>login.php" method="POST">
  108. <h5 class="card-title">Enter question code:</h5>
  109. <?php if (!isset($_SESSION['name'])) { ?>
  110. <input type="text" class="form-control my-2" name="name" placeholder="Name" required />
  111. <?php } ?>
  112. <input type="text" class="form-control my-2" name="code" placeholder="XXXX" required />
  113. <button class="btn btn-primary btn-block" type="submit">
  114. Go
  115. </button>
  116. </form>
  117. </div>
  118. </div>
  119. </div>
  120. <?php } ?>
  121. </div>