diff --git a/database.mwb b/database.mwb
index 389c0c0..67b7734 100644
Binary files a/database.mwb and b/database.mwb differ
diff --git a/database.sql b/database.sql
index c887ab7..0253335 100644
--- a/database.sql
+++ b/database.sql
@@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench
--- Mon 05 Feb 2018 02:44:01 PM MST
+-- Mon 05 Feb 2018 11:09:37 PM MST
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
@@ -55,6 +55,7 @@ CREATE TABLE IF NOT EXISTS `openquestion`.`responses` (
`aid` INT NOT NULL,
`qid` INT NOT NULL,
`timestamp` DATETIME NOT NULL,
+ `name` VARCHAR(100) NULL,
PRIMARY KEY (`rid`, `aid`, `qid`),
UNIQUE INDEX `rid_UNIQUE` (`rid` ASC),
INDEX `fk_responses_answers1_idx` (`aid` ASC, `qid` ASC),
diff --git a/getresults.php b/getresults.php
index 7ca09a7..e76df5e 100644
--- a/getresults.php
+++ b/getresults.php
@@ -2,6 +2,8 @@
require_once __DIR__ . "/required.php";
+header('Content-Type: application/json');
+
$qid = $VARS['qid'];
if (!$database->has('questions', ['qid' => $qid])) {
@@ -22,4 +24,16 @@ foreach ($answers as $a) {
];
}
+$responses = $database->select('responses', ['name', 'aid'], ['qid' => $qid]);
+$data['responses'] = [];
+foreach ($responses as $r) {
+ if ($r['name'] == null) {
+ $r['name'] = "Anonymous";
+ }
+ $data['responses'][] = [
+ "name" => $r['name'],
+ "aid" => $r['aid']
+ ];
+}
+
echo json_encode($data);
\ No newline at end of file
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..c838a64
--- /dev/null
+++ b/login.php
@@ -0,0 +1,9 @@
+get('questions', 'qid', ['qcode' => $arg1]);
?>
-
+
get('questions', 'qtext', ['qid' => $qid]); ?>
@@ -36,33 +36,74 @@ include __DIR__ . "/../bits/navbar.php";
-
- count('responses', ['qid' => $qid]);
- $answers = $database->select('answers', ['aid', 'atext'], ['qid' => $qid]);
- $colors = ["primary", "success", "danger", "info", "warning"];
- $color = -1;
- foreach ($answers as $a) {
- $color++;
- if ($color > count($colors) - 1) {
- $color = 0;
+
+
+
+
+
+ count('responses', ['qid' => $qid]);
+ $answers = $database->select('answers', ['aid', 'atext'], ['qid' => $qid]);
+ $colors = ["primary", "success", "danger", "info", "warning"];
+ $color = -1;
+ foreach ($answers as $a) {
+ $color++;
+ if ($color > count($colors) - 1) {
+ $color = 0;
+ }
+ $votes = $database->count('responses', ['aid' => $a['aid']]);
+ ?>
+
+ count('responses', ['aid' => $a['aid']]);
?>
-
+
+
+ $color = -1;
+ foreach ($answers as $a) {
+ $color++;
+ if ($color > count($colors) - 1) {
+ $color = 0;
+ }
+ ?>
+
+
+
+
+ select('responses', 'name', ['aid' => $a['aid']]);
+ foreach ($users as $u) {
+ if ($u == null) {
+ $u = "Anonymous";
+ }
+ ?>
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/respond.php b/pages/respond.php
index 8fbfa42..8644a2e 100644
--- a/pages/respond.php
+++ b/pages/respond.php
@@ -18,18 +18,16 @@
@@ -67,20 +65,18 @@
-
@@ -91,18 +87,16 @@
@@ -113,18 +107,16 @@
diff --git a/vote.php b/vote.php
index f3eb31d..b5f67bc 100644
--- a/vote.php
+++ b/vote.php
@@ -17,7 +17,7 @@ if ($_SESSION['voted'][$qid] === true) {
die();
}
-$database->insert("responses", ['qid' => $qid, 'aid' => $aid, 'timestamp' => date('Y-m-d H:i:s')]);
+$database->insert("responses", ['qid' => $qid, 'aid' => $aid, 'timestamp' => date('Y-m-d H:i:s'), 'name' => $_SESSION['name']]);
$_SESSION['voted'][$qid] = true;