-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
157 lines (115 loc) · 4.45 KB
/
form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/* NAME
*
* form.php
*
* CONCEPT
*
* Activist Mirror application.
*
*/
include "lib/am.php";
// Main program follows.
$debug = 2; // calls to Debug() with $level <= $debug will emit
header("Content-Type: text/html; charset=utf-8");
mb_language('uni');
mb_internal_encoding('UTF-8');
DataStoreConnect();
if(isset($_GET["language"])) { // forgotten language var
$language = $_GET["language"];
} elseif (isset($_POST["language"])) { // for posted language var
$language = $_POST["language"];
} else {
$language = "en";
}
$title = LocalString($language, MESSAGES, TITLE) .
(isset($_COOKIE['dev']) ? ' (DEV MODE)' : '');
$next = LocalString($language, MESSAGES, NEXT);
// increment or initialize page number (and hence question and answers)
if (isset($_POST["page"])) {
$page = $_POST["page"];
++$page;
} else {
$page = 1;
}
// SelectedQ[] contains the user input, if any, to the eight questions.
$SelectedQ = array();
$SelectedQ[] = $q1 = isset($_POST['q1']) ? $_POST['q1'] : NULL;
$SelectedQ[] = $q2 = isset($_POST['q2']) ? $_POST['q2'] : NULL;
$SelectedQ[] = $q3 = isset($_POST['q3']) ? $_POST['q3'] : NULL;
$SelectedQ[] = $q4 = isset($_POST['q4']) ? $_POST['q4'] : NULL;
$SelectedQ[] = $q5 = isset($_POST['q5']) ? $_POST['q5'] : NULL;
$SelectedQ[] = $q6 = isset($_POST['q6']) ? $_POST['q6'] : NULL;
$SelectedQ[] = $q7 = isset($_POST['q7']) ? $_POST['q7'] : NULL;
$SelectedQ[] = $q8 = isset($_POST['q8']) ? $_POST['q8'] : NULL;
Debug("\$SelectedQ[] = " . print_r($SelectedQ, TRUE), 3);
// The (poorly-named) $uid is actually the value of time() when the
// user first starts the application.
$uid = isset($_POST['uid']) ? $_POST["uid"] : time();
if (isset($_POST["screen_width"])) {
$screen_width = $_POST["screen_width"];
}
if (isset($_POST["screen_height"])) {
$screen_height = $_POST["screen_height"];
}
// We are presenting a form with a multiple-choice question.
?>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>Playing the Activist Mirror Game</title>
<link rel="stylesheet" href="css/surveyStyle.css">
</head>
<body>
<div id="container">
<header>
<h1><?=$title?></h1>
</header>
<p style="display: none">language = <?= $language ?>, uid = <?= $uid ?>, screen width: <?= $screen_width ?>, screen height: <?= $screen_height ?></p>
<section>
<img src="img/activist-images-band.jpg" style="width: 95%;" >
<!--Questions-->
<?php
$action = ($page < 8) ? 'form.php' : 'result.php';
echo "<p><form name=\"answer\" action=\"$action\" method=\"post\">";
// Retrieve and display the question for this page and language.
$question = GetQuestion($language, $page);
echo "<p class=\"nlead\">$question</p>\n"; // prints the question
// presenting possible (5) answers for each question [below]
// Need to increment for each of the 8 questions (use $page)
$answers = GetAnswers($language, $page);
$answervar = "q" . $page;
$i = 1;
foreach($answers as $answer) {
echo "<p class=\"quest\"><input type=\"radio\" id=\"$i\" name=\"$answervar\" value=\"$i\"><label for=\"$i\"> $answer</label>";
$i++;
} // end loop on answers
echo "<input type=\"hidden\" name=\"page\" value=\"$page\">";
echo "<input type=\"hidden\" name=\"language\" value=\"$language\">";
echo "<input type=\"hidden\" name=\"uid\" value=\"$uid\">";
echo "<input type=\"hidden\" name=\"screen_width\" value=\"$screen_width\">";
echo "<input type=\"hidden\" name=\"screen_height\" value=\"$screen_height\">";
if ($page != 1) { echo "<input type=\"hidden\" name=\"q1\" value=\"$q1\">"; }
if ($page != 2) { echo "<input type=\"hidden\" name=\"q2\" value=\"$q2\">"; }
if ($page != 3) { echo "<input type=\"hidden\" name=\"q3\" value=\"$q3\">"; }
if ($page != 4) { echo "<input type=\"hidden\" name=\"q4\" value=\"$q4\">"; }
if ($page != 5) { echo "<input type=\"hidden\" name=\"q5\" value=\"$q5\">"; }
if ($page != 6) { echo "<input type=\"hidden\" name=\"q6\" value=\"$q6\">"; }
if ($page != 7) { echo "<input type=\"hidden\" name=\"q7\" value=\"$q7\">"; }
if ($page != 8) { echo "<input type=\"hidden\" name=\"q8\" value=\"$q8\">"; }
?>
<p>
<input type="submit" name="submit" value="<?=$next?>" class="btn btn-default">
</div>
</form>
<hr>
</div>
</section>
<br>
<footer>
The Public Sphere Project
</footer>
</body>
</html>