-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewreports.php
223 lines (211 loc) · 7.04 KB
/
viewreports.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
<!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">
<head>
<title>View Reports</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="css/SurveyStyles.css">
<link rel="stylesheet" type="text/css" href="css/msdstyle2.css" media="screen"/>
<link href="css/msdprint.css" rel="stylesheet" type="text/css" media="print" />
<?php
require_once("includes/config.php");
require_once("includes/getuser.php");
require_once("includes/isauthor.php");
require_once("includes/limitstring.php");
require_once("includes/ODBCDateToTextDate.php");
//These are routines from http://www.mattkruse.com/javascript/optiontransfer/index.html
if(isset($_POST['bChooseSurveys']))
{
echo " <script language=\"JavaScript\" src=\"script/OptionTransfer.js\"></script>
<script language=\"JavaScript\">
var opt = new OptionTransfer(\"qSource\",\"qDestination\");
opt.setAutoSort(true);
opt.saveNewRightOptions(\"hidQuestions\");
</script>";
}
?>
<script language="javascript" type="text/javascript">
function ValidateForm()
{
if (document.getElementById("ddSurvey").selectedIndex == 0)
{
alert ("Please choose a survey");
return false;
}
return true;
}
function ValidateSecondForm()
{
if (document.getElementById("sSchedule").selectedIndex == 0)
{
alert ("Please choose a schedule");
return false;
}
return true;
}
</script>
<script language="javascript" type="text/javascript">
//enables OK/update button if input has changed
function ControlHasChanged(btnSubmit)
{
document.getElementById(btnSubmit).disabled = false;
//setting a cookie which regsiters any changes since last submit button press
}
function goTo(URL)
{
window.location.href = URL;
}
</script>
</head>
<body>
<?php
if(IsAuthor($heraldID))
{
require_once("includes/html/adminheadernew.html");
require_once("includes/html/BreadCrumbsHeader.html");
echo "<a href=\"results.php\">Results</a> > View Reports";
require_once("includes/html/BreadCrumbsFooter.html");
}
else
{
require_once("includes/html/header.html");
echo "You do not have the necessary permissions to view this page";
exit();
}
?>
<?php
echo "<a name=\"maintext\" id=\"maintext\"></a>";
echo "<h1>View Reports</h1>";
$qSurveys = "SELECT Surveys.surveyID, Surveys.title
FROM Surveys, SurveyAuthors, Authors
WHERE Surveys.surveyID = SurveyAuthors.surveyID
AND SurveyAuthors.authorID = Authors.authorID
AND Authors.heraldID = '$heraldID'";
$qResSurveys = @mysqli_query($db_connection, $qSurveys);
echo "<div class=\"block\">
<h2>Step 1: Choose a survey</h2>
<form id=\"frmResults\" name=\"frmResults\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" onSubmit=\"return ValidateForm()\">";
if (($qResSurveys == false))
{
echo "problem querying Surveys" . mysqli_error($db_connection);
}
else
{
echo "<div class=\"questionNormal\">";
echo " <table class=\"normal_3\" summary=\"\">";
echo " <tr>
<td>
<select id=\"ddSurvey\" name=\"ddSurvey\" size=\"1\">
<option value=\"0\">
Choose a survey
</option>";
while($rowSurveys = mysqli_fetch_array($qResSurveys))
{
//remember the option previously selected
if(isset($_POST['ddSurvey']) && $_POST['ddSurvey'] == $rowSurveys['surveyID'])
{
echo " <option value=\"".$rowSurveys['surveyID']."\" selected>
".$rowSurveys['title']."
</option>";
}
else
{
echo " <option value=\"".$rowSurveys['surveyID']."\">
".$rowSurveys['title']."
</option>";
}
}
echo " </select>
</td>
</tr>";
echo " </table>";
echo "</div>";
}
echo " <input type=\"submit\" value=\"Choose survey\" id=\"bChooseSurveys\" name=\"bChooseSurveys\"> ";
echo "</form>
</div>";
if(isset($_POST['bChooseSurveys']))
{
echo "<div class=\"block\">
<h2>Step 2: Limit results</h2>
<form id=\"frmAnalyse\" name=\"frmAnalyse\" action=\"showlargetextstudents.php\" method=\"post\" onSubmit=\"return ValidateSecondForm()\">";
if (($qResSurveys == false))
{
echo "problem querying Surveys" . mysqli_error($db_connection);
}
else
{
$surveyID = $_POST['ddSurvey']; //getting surveyID from POST
echo "<div class=\"questionNormal\">";
echo " <table class=\"normal_3\" summary=\"\">
<tr>
<td class=\"question\" align=\"left\">Choose a schedule:</td>
<td>";
//get schedules for this survey
$qSurveyInstances = "SELECT surveyInstanceID, title, startDate, finishDate
FROM SurveyInstances
WHERE surveyID = $surveyID";
$qResSurveyInstances = mysqli_query($db_connection, $qSurveyInstances);
if ($qResSurveyInstances == false)
{
echo "problem querying SurveyInstances" . mysqli_error($db_connection);
}
else
{
echo"<select id=\"sSchedule\" name=\"sSchedule\" size=\"1\">";
echo " <option value=\"0\">Choose a schedule</option>";
while($rowSurveyInstances = mysqli_fetch_array($qResSurveyInstances))
{
$instanceStartDate = $rowSurveyInstances['startDate'];
if($instanceStartDate==NULL)
{
$instanceStartDate = "Unlimited";
}
else
{
$instanceStartDate = ODBCDateToTextDateShort($instanceStartDate);
}
$instanceFinishDate = $rowSurveyInstances['finishDate'];
if($instanceFinishDate==NULL)
{
$instanceFinishDate = "Unlimited";
}
else
{
$instanceFinishDate = ODBCDateToTextDateShort($instanceFinishDate);
}
echo "<option value=\"".$rowSurveyInstances['surveyInstanceID']."\">" . $rowSurveyInstances['title'] . " - " . $instanceStartDate . " to " . $instanceFinishDate . "</option>";
}
echo "</select>";
}
echo"
<input type=\"hidden\" id=\"surveyID\" name=\"surveyID\" value=\"$surveyID\">
<td>
</tr>";
echo " </table>";
echo "</div>";
}
echo " <h2>Step 3: Generate Results</h2>
<input type=\"submit\" value=\"Show reports\" id=\"bShowReports\" name=\"bShowReports\"> ";
echo "</form>
</div>";
//bit of javascript to make sure that right option for start and finish dates is chosen
echo " <script language=\"JavaScript\">";
echo " document.getElementById('rFinishDateNone').click();";
echo " document.getElementById('rStartDateNone').click();";
echo "</script>";
}
?>
<?php
//Breadcrumb
if(IsAuthor($heraldID))
{
require_once("includes/html/BreadCrumbsHeader.html");
echo "<a href=\"results.php\">Results</a> > View Reports";
require_once("includes/html/BreadCrumbsFooter.html");
}
//footer - including contact info.
require_once("includes/html/footernew.html");
require_once("includes/instructions/inst_viewreports.php");
?>
</body>
</html>