-
Notifications
You must be signed in to change notification settings - Fork 0
/
numerator.php
307 lines (304 loc) · 11.9 KB
/
numerator.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
require_once 'inc/util.inc';
session_start();
$_SESSION['error'] = "";
if (isset($_COOKIE['user'])) {
$username = $_COOKIE['user'];
$password = $_COOKIE['pass'];
$db_link = mysql_connect($db, $db_user, $db_pass, TRUE, MYSQL_CLIENT_INTERACTIVE);
if (!$db_link)
error(mysql_error());
mysql_query("SET NAMES utf8", $db_link);
mysql_query("SET CHARACTER SET utf8", $db_link);
mysql_query("SET SESSION interactive_timeout=30", $db_link);
mysql_select_db($dbname);
$user = mysql_query("SELECT * FROM user WHERE firstname = '$username'");
if (!$user)
error(mysql_error());
while ($userinfo = mysql_fetch_array($user)) {
if ($password != $userinfo['password']) {
header("Location: login.php");
return;
} else {
$_SESSION['unlocked'] = $userinfo['unlocked'];
if (!(bool) $_SESSION['unlocked']) {
header("Location: unlock.php");
return;
}
if (isset($_POST['indicatorSelect'])) {
$_SESSION['indicatorid'] = $_POST['indicatorSelect'];
}
if (!isset($_SESSION['indicatorid'])) {
$_SESSION['indicatorid'] = 1;
}
$indicatorid = $_SESSION['indicatorid'];
$step = "numerator";
$userid = $userinfo['id'];
$commentresult = mysql_query(
"SELECT * FROM comment WHERE userid = '$userid' AND indicatorid = '$indicatorid' AND step = '$step'");
if (!$commentresult)
error(mysql_error());
$comment_num_rows = mysql_num_rows($commentresult);
while ($commentinfo = mysql_fetch_array($commentresult)) {
$comment = $commentinfo['comment'];
$commentold = $commentinfo['comment'];
}
mysql_free_result($commentresult);
if ($_POST['submitComment'] == "submit") {
$commentnew = $_POST['comment'];
$commentnewprep = PrepSQL($commentnew);
if ($commentnewprep != $commentcomment) {
if ($comment_num_rows == 0) {
$sql = "INSERT INTO comment (userid, indicatorid, step, comment, inserted) VALUES (
$userid, $indicatorid, '$step', '$commentnewprep', NOW())";
mysql_query($sql);
$comment = $commentnewprep;
} else if ($comment_num_rows > 0) {
if (strcmp($commentnew, $commentold) != 0) {
$sqlupdate = "UPDATE comment SET `comment` = '$commentnewprep', `updated` = NOW() WHERE `userid` = '$userid' AND `indicatorid` = '$indicatorid' AND `step` = '$step'";
mysql_query($sqlupdate);
$comment = $commentnewprep;
}
}
}
$commentresult = mysql_query(
"SELECT * FROM comment WHERE userid = '$userid' AND indicatorid = '$indicatorid' AND step = '$step'");
if (!$commentresult)
error(mysql_error());
while ($commentinfo = mysql_fetch_array($commentresult)) {
$comment = $commentinfo['comment'];
}
mysql_free_result($commentresult);
}
if ($_POST['form'] == "numeratorconstraints") {
$allconstraints = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid'");
if (!$allconstraints)
error(mysql_error());
while ($constraintinfo = mysql_fetch_array($allconstraints)) {
$id = $constraintinfo['id'];
$sqlupdate = "UPDATE formalised_constraint SET numeratoronly = '0', updated = NOW() WHERE id = '$id'";
mysql_query($sqlupdate);
}
mysql_free_result($allconstraints);
$selconstraints = $_POST['constraints'];
if (!empty($selconstraints)) {
$N = count($selconstraints);
for ($i = 0; $i < $N; $i++) {
$sqlupdate = "UPDATE formalised_constraint SET numeratoronly = '1' WHERE id = '$selconstraints[$i]'";
mysql_query($sqlupdate);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CLIF: Numerator</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"></link>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
<?php include_once("inc/head.inc") ?>
<div style="height: 50px"></div>
<div class="container">
<h1>Numerator: Identify constraints that only aim at the numerator</h1>
<p>For the constraints that you formalised, state which ones only aim
at the numerator. Also select the constraints of the information
model that only aim at those constraints. All constraints that you do
not select belong only to the denominator. A constraint should not be
both an exclusion criterion and only aim at the numerator.</p>
<?php include_once("inc/indicator.inc") ?>
<h2>Select constraints that only aim at the numerator</h2>
<div class="workwell">
<div style="margin-left: 10px;">
<a name="constraints"></a>
<form action="<?php echo $_SERVER['PHP_SELF'] . '#constraints' ?>"
method="post">
<h3>
<a href="informationmodel.php">Information Model</a>
</h3>
<?php
$informationmodelconstraint = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid' AND constrainttype = 'informationmodel'");
if (!$informationmodelconstraint)
error(mysql_error());
while ($informationmodelconstraintrow = mysql_fetch_array($informationmodelconstraint)) {
$id = $informationmodelconstraintrow['id'];
$table = $informationmodelconstraintrow['table'];
$attribute = $informationmodelconstraintrow['attribute'];
$relation = $informationmodelconstraintrow['relation'];
$conceptid = $informationmodelconstraintrow['conceptid'];
$numeratoronly = $informationmodelconstraintrow['numeratoronly'];
$color = "black";
if ((bool) $numeratoronly)
$color = "green";
$fsn = mysql_query("SELECT FULLYSPECIFIEDNAME FROM concepts WHERE CONCEPTID = '$conceptid' ");
if (!$fsn)
error(mysql_error());
$snorow = mysql_fetch_row($fsn);
echo "<input type='checkbox' name='constraints[]' value='$id' onchange='this.form.submit();'";
if ((bool) $numeratoronly) {
echo " checked = 'checked' ";
}
echo " /> <span style='color:$color' >";
echo "$table.$attribute $relation $conceptid $snorow[0]";
echo "</span><br />";
}
mysql_free_result($informationmodelconstraint);
?>
<h3>
<a href="temporal.php">Temporal constraints</a>
</h3>
<?php
$dateconstraint = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid' AND constrainttype = 'temporal_date'");
if (!$dateconstraint)
error(mysql_error());
while ($dateconstraintrow = mysql_fetch_array($dateconstraint)) {
$id = $dateconstraintrow['id'];
$table = $dateconstraintrow['table'];
$attribute = $dateconstraintrow['attribute'];
$relation = $dateconstraintrow['relation'];
$date = $dateconstraintrow['date'];
$numeratoronly = $dateconstraintrow['numeratoronly'];
$color = "black";
if ((bool) $numeratoronly)
$color = "green";
echo "<input type='checkbox' name='constraints[]' value='$id' onchange='this.form.submit();'";
if ((bool) $numeratoronly) {
echo " checked = 'checked' ";
}
echo " /> <span style='color:$color' >";
echo "$table.$attribute $relation $date";
echo "</span><br />";
}
mysql_free_result($dateconstraint);
$daterelationconstraint = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid' AND constrainttype = 'temporal_relation'");
if (!$daterelationconstraint)
error(mysql_error());
while ($daterelationconstraintrow = mysql_fetch_array($daterelationconstraint)) {
$id = $daterelationconstraintrow['id'];
$table = $daterelationconstraintrow['table'];
$attribute = $daterelationconstraintrow['attribute'];
$relation = $daterelationconstraintrow['relation'];
$table2 = $daterelationconstraintrow['table2'];
$attribute2 = $daterelationconstraintrow['attribute2'];
$numeratoronly = $daterelationconstraintrow['numeratoronly'];
$color = "black";
if ((bool) $numeratoronly)
$color = "green";
echo "<input type='checkbox' name='constraints[]' value='$id' onchange='this.form.submit();'";
if ((bool) $numeratoronly) {
echo " checked = 'checked' ";
}
echo " /> <span style='color:$color' >";
echo "$table.$attribute $relation $table2.$attribute2";
echo "</span><br />";
}
mysql_free_result($daterelationconstraint);
?>
<h3>
<a href="numeric.php">Numeric constraints</a>
</h3>
<?php
$numericconstraint = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid' AND constrainttype = 'numeric'");
if (!$numericconstraint)
error(mysql_error());
while ($numericconstraintrow = mysql_fetch_array($numericconstraint)) {
$id = $numericconstraintrow['id'];
$table = $numericconstraintrow['table'];
$attribute = $numericconstraintrow['attribute'];
$relation = $numericconstraintrow['relation'];
$number = $numericconstraintrow['number'];
$numeratoronly = $numericconstraintrow['numeratoronly'];
$color = "black";
if ((bool) $numeratoronly)
$color = "green";
echo "<input type='checkbox' name='constraints[]' value='$id' onchange='this.form.submit();'";
if ((bool) $numeratoronly) {
echo " checked = 'checked' ";
}
echo " /> <span style='color:$color' >";
echo "$table.$attribute $relation $number";
echo "</span><br />";
}
mysql_free_result($numericconstraint);
?>
<h3>
<a href="textual.php">Textual constraints</a>
</h3>
<?php
$textualconstraint = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid' AND constrainttype = 'textual'");
if (!$textualconstraint)
error(mysql_error());
while ($textualconstraintrow = mysql_fetch_array($textualconstraint)) {
$id = $textualconstraintrow['id'];
$table = $textualconstraintrow['table'];
$attribute = $textualconstraintrow['attribute'];
$relation = $textualconstraintrow['relation'];
$txt = $textualconstraintrow['txt'];
$numeratoronly = $textualconstraintrow['numeratoronly'];
$color = "black";
if ((bool) $numeratoronly)
$color = "green";
echo "<input type='checkbox' name='constraints[]' value='$id' onchange='this.form.submit();'";
if ((bool) $numeratoronly) {
echo " checked = 'checked' ";
}
echo " /> <span style='color:$color' >";
echo "$table.$attribute $relation $txt";
echo "</span><br />";
}
mysql_free_result($textualconstraint);
?>
<h3>
<a href="boolean.php">Boolean constraints</a>
</h3>
<?php
$booleanconstraint = mysql_query(
"SELECT * FROM formalised_constraint WHERE indicatorid = '$indicatorid' AND userid = '$userid' AND constrainttype = 'boolean'");
if (!$booleanconstraint)
error(mysql_error());
while ($booleanconstraintrow = mysql_fetch_array($booleanconstraint)) {
$id = $booleanconstraintrow['id'];
$table = $booleanconstraintrow['table'];
$attribute = $booleanconstraintrow['attribute'];
$boolean = $booleanconstraintrow['boolean'];
$numeratoronly = $booleanconstraintrow['numeratoronly'];
$color = "black";
if ((bool) $numeratoronly)
$color = "green";
echo "<input type='checkbox' name='constraints[]' value='$id' onchange='this.form.submit();'";
if ((bool) $numeratoronly) {
echo " checked = 'checked' ";
}
echo " /> <span style='color:$color' >";
echo "$table.$attribute = $boolean";
echo "</span><br />";
}
mysql_free_result($booleanconstraint);
?>
<input type="hidden" name="form" value="numeratorconstraints" />
</form>
</div>
</div>
<?php include_once("inc/comment.inc") ?>
</div>
</body>
</html>
<?php
}
}
mysql_free_result($user);
mysql_close($db_link);
} else {
header("Location: login.php");
return;
}
?>