-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_audits.php
executable file
·286 lines (219 loc) · 10.6 KB
/
admin_audits.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<?php
require_once('settings.php');
require_once('moodle.inc');
?>
<html>
<head>
<style type="text/css" title="currentStyle" media="screen">
@import "official_blue.css";
</style>
<title>Administrate audits</title>
</head>
<body>
<div class="sqamenu"><span class="sqamenu"><a href="index.php">Welcome</a></span> <span class="sqamenu"><a href="checked_out.php">Participate</a></span> <span class="sqamenusel">Administrate</span></div>
<h1 class="sqa">Software Quality Assurance</h1>
<div class="sqah1"> </div>
<h2 class="sqa">Administrate audits</h2>
<!--
<h2 class="sqa"><?php echo "<a href=\"" . $CFG->wwwroot . "\">"; ?>Moodle</a> login</h2>
-->
<?php
if (isloggedin() && $USER->username != 'guest') {
$moodle_full_name = $USER->firstname . " " . $USER->lastname;
$moodle_id = $USER->id;
$moodle_email = $USER->email;
echo "<p><span class=\"sqaopf\">You are currently logged in as:";
echo "<span class=\"sqaop\">" . $moodle_full_name . "</span>";
echo "</span> <a href=\"" . $CFG->wwwroot . "/login/logout.php\">Logout</a></p>";
# echo "Your ID is: " . $USER->id . "</p>";
} else {
echo "<p>Please follow this <a href='" . $CFG->wwwroot . "/mod/resource/view.php?id=83'>link</a> and log into moodle</p>";
# echo "<p>Login below and hit <a href=\"admin_audits.php\">refresh</a></p>";
# echo "<iframe width=100% height=60% src=\"" . $CFG->wwwroot . "/login/index.php\"></iframe>";
echo "</body></html>";
return;
}
$link = mysql_connect($db_server,$db_username,$db_password);
if (! mysql_select_db($db_database)) {
die(mysql_error());
}
?>
<div class="sqap">The following is a list of web based software audits which you currently manage. Open the audit to add and
remove sessions. Export the audit as a table to access the entered data.</div>
<?php
if (! empty($password_error)) {
echo '<span class="sqaerr">' . $password_error . '</span>';
}
?>
<table class="list" width="95%">
<tr>
<th class="list">Scope</th>
<th class="list">Institution</th>
<th class="list">Dataset</th>
<th class="list">Start Date</th>
<th class="list">End Date</th>
<th class="list">Visible</th>
<th class="list">Official audit</th>
<th class="list">Open sessions</th>
<th class="list">Export as sheets</th>
<?php
//alter table collection drop column allow_report;
//alter table collection drop column allow_multiple_sessions;
//alter table collection drop column allow_user_lock;
//alter table collection drop column is_audit;
//alter table collection add column ( allow_report int default 0);
//alter table collection add column ( allow_multiple_sessions int default 0);
//alter table collection add column ( allow_user_lock int default 1 );
//alter table collection add column ( is_audit int default 1);
$query = 'SELECT collection.collection_id, collection.scope, DATE_FORMAT(collection.start_date,"%e/%c/%Y") AS start_date, DATE_FORMAT(collection.end_date,"%e/%c/%Y") AS end_date, institution.title AS institution, institution.department AS department, module.title AS module, module.module_id, collection.is_audit, collection.visible, institution_auth.visible_priv FROM collection LEFT JOIN institution ON collection.institution_id = institution.institution_id LEFT JOIN institution_auth ON institution_auth.institution_id = institution.institution_id LEFT JOIN module ON collection.module_id = module.module_id WHERE institution_auth.manage_priv=1 AND institution_auth.moodle_id = ' . $moodle_id;
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td class="list">' . $row['scope'] . '</td>';
echo '<td class="list">' . $row['institution'] . '</td>';
echo '<td class="list">' . $row['module'] . '</td>';
echo '<td class="list">' . $row['start_date'] . '</td>';
echo '<td class="list">' . $row['end_date'] . '</td>';
echo '<td class="list">';
if ( $row['visible_priv'] ) {
echo '<form action="modify_audit.php" class="toggle" method="POST"><input type="hidden" name="collection_id" value="' . $row['collection_id'] . '"/>';
if ($row['visible'] == 1) { echo '<input type="hidden" name="visible" value="0"/><button disabled=1 class="list_active">Y</button><input type="submit" class="list_inactive" value="N"></input>'; }
else { echo '<input type="hidden" name="visible" value="1"/><input type="submit" class="list_inactive" value="Y"></input><button disabled=1 type="submit" class="list_active">N</button>'; }
echo '</form></td>';
} else {
if ($row['visible'] == 1) { echo 'Showing'; } else { echo 'Hidden'; }
}
echo '</td>';
echo '<td class="list">';
echo '<form action="modify_audit.php" class="toggle" method="POST"><input type="hidden" name="collection_id" value="' . $row['collection_id'] . '"/>';
if ($row['is_audit'] == 1) { echo '<input type="hidden" name="is_audit" value="0"/><button disabled=1 class="list_active">Y</button><input type="submit" class="list_inactive" value="N"></input>'; }
else { echo '<input type="hidden" name="is_audit" value="1"/><input class="list_inactive" type="submit" value="Y"></input><button disabled=1 type="submit" class="list_active">N</button>'; }
echo '</form></td>';
echo '</td>';
echo '<td class="list"><form action="admin_sessions.php"><input type="hidden" name="collection_id" value="' . $row['collection_id'] . '"/><button type="submit" class="list">Open</button></form></td>';
echo '<td><form action="export_audit.php" method="POST"><input type="hidden" name="collection_id" value="'. $row['collection_id'] . '">';
echo 'Name: <input name="sheet_name" type="text"><button type="submit" class="list">Export</button></form></td>';
$module_id = $row['module_id'];
echo '</tr>';
}
mysql_free_result($result);
?>
</table>
<?php
$query = sprintf('SELECT institution.institution_id, title, department FROM institution_auth JOIN institution ON institution_auth.institution_id=institution.institution_id WHERE moodle_id=%d AND create_priv=1',$moodle_id);
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$institution_html = '';
while ($row = mysql_fetch_assoc($result)) {
$institution_html .= '<option value="' . $row['institution_id'] . '" >' . $row['title'] . ' - ' . $row['department'] . '</option>';
}
if ($institution_html == '') { echo '<!--'; }
?>
<FORM action="create_audit.php" METHOD="POST">
<FIELDSET class="sqaf">
<LEGEND class="sqaf">Create Audit</LEGEND>
<DIV class="sqaf">
<SPAN class="sqaf">Scope:</SPAN>
<INPUT name="scope" type="text" value="" size="30" tabindex="5"/>
</DIV>
<DIV class="sqaf">
<SPAN class="sqaf">Institution Name:</SPAN>
<SELECT name="institution_id" size="1">
<?php echo $institution_html; ?>
</SELECT>
</DIV>
<DIV class="sqaf">
<SPAN class="sqaf">Start Date:</SPAN>
<INPUT name="start_dateDD" type="text" maxlength=2 size=2 tabindex="6"/>/
<INPUT name="start_dateMM" type="text" maxlength=2 size=2 tabindex="7"/>/
<INPUT name="start_dateYYYY" type="text" maxlength=4 size=4 tabindex="8"/>
</DIV>
<DIV class="sqaf">
<SPAN class="sqaf">End Date:</SPAN>
<INPUT name="end_dateDD" type="text" maxlength=2 size=2 tabindex="9"/>/
<INPUT name="end_dateMM" type="text" maxlength=2 size=2 tabindex="10"/>/
<INPUT name="end_dateYYYY" type="text" maxlength=4 size=4 tabindex="11"/>
</DIV>
<DIV class="sqaf">
<SPAN class="sqaf">Dataset:</SPAN>
<SELECT name="module_id" tabindex="12" >
<?php
$query = 'SELECT module_id, title FROM module';
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<option value="' . $row['module_id'] . '" >' . $row['title'] . '</option>';
}
?>
</SELECT>
</DIV>
</FIELDSET>
<INPUT type="submit" value="Create Audit" tabindex="14"/>
</FORM>
<?php
if ($institution_html == '') { echo '-->'; }
if ($institution_html != '') { echo '<!--'; }
?>
<h2 class="sqa">Request audit</h2>
<div class="sqap">You do not have the authority to add new software audits.
Please send an email to <a href="mailto:[email protected]">[email protected]</a> providing your Full Name, Email Address, Phone Number, Department Name, Institution Name.
You can either specify the details of your intended audit or provide a reason why you want to start your own audits as opposed to adding data to existing audits.
</div>
<?php
if ($institution_html != '') { echo '-->'; }
?>
<h2 class="sqa">Exported spreadsheets</h2>
<div class="sqap">The spreadsheets contain copies of the audit data in a form which is suitable for downloading and uploading as a comma delimited file (.csv).</div>
<table class="list" width="50%">
<tr>
<th class="list">Name</th>
<th class="list">Rows</th>
<th class="list">Cols</th>
<th class="list">Sheet type</th>
<th class="list">Download CSV</th>
<th class="list">View</th>
<th class="list">Delete</th>
</tr>
<?php
#COUNT(column_id)
$query = sprintf('SELECT sheet_id, module_sheets.title, number_of_rows, number_of_columns, type_name FROM module_sheets LEFT JOIN module_sheet_type ON module_sheets.type_id=module_sheet_type.type_id WHERE module_sheets.moodle_id=%d',$moodle_id);
# $query = 'SELECT sheet_id, title, number_of_rows FROM module_sheets';
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td class="list">' . $row['title'] . '</td>';
echo '<td class="list">' . $row['number_of_rows'] . '</td>';
echo '<td class="list">' . $row['number_of_columns'] . '</td>';
echo '<td class="list">' . $row['type_name'] . '</td>';
echo '<td class="list"><form action="download_sheet.php" method="POST"><button type="submit">Download</button>';
echo '<input type="hidden" name="sheet_id" value="' . $row['sheet_id'] . '"></form></td>';
echo '<td class="list"><form action="view_sheet.php" method="POST"><button type="submit">View</button>';
echo '<input type="hidden" name="sheet_id" value="' . $row['sheet_id'] . '"></form></td>';
echo '<td class="list"><form action="delete_sheet.php" method="POST"><button type="submit">Delete</button>';
echo '<input type="hidden" name="sheet_id" value="' . $row['sheet_id'] . '"></form></td>';
echo '</tr>';
}
?>
</table>
</body>
</html>