forked from delongGao/teds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
executable file
·210 lines (184 loc) · 8.8 KB
/
admin.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
<?
// ============================== authentication ===============================
// if (session_status() == PHP_SESSION_NONE) {
// session_start();
//
// }
// if(!isset($_SESSION['user_email'])) { // if there is no valid session
// header("Location: index.php?notice=login_first");
// }
require_once "session_inc.php";
// ============================== authentication ===============================
require_once "dbconnect.php";
try {
$dbq = db_connect();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Dashboard - SB Admin</title>
<!-- Bootstrap core CSS -->
<link href="stylesheets/bootstrap.css" rel="stylesheet">
<!-- Add custom CSS here -->
<link href="stylesheets/sb-admin.css" rel="stylesheet">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<!-- Page Specific CSS -->
<link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
<link rel="stylesheet" href="stylesheets/main.css">
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="admin.php">TEDS Site Rater Admin</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav">
<li class="active"><a href="admin.php"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li><a href="admin_rp.php" id="sidenav_separate"><i class="fa fa-bar-chart-o"></i> New Rating</a></li>
<li class="sub_level"><a href="admin_pjt_project.php"> 1. Project</a></li>
<li class="sub_level"><a href="admin_pjt_atft.php"> 2. Artifact</a></li>
<li class="sub_level"><a href="admin_pjt_scenario.php"> 3. Scenario</a></li>
<li class="sub_level"><a href="admin_pjt_persona.php"> 4. Persona</a></li>
<li class="sub_level"><a href="admin_pjt_user.php"> 5. User</a></li>
<li class="sub_level"><a href="admin_pjt_cate.php"> 6. Categories</a></li>
</ul>
<ul class="nav navbar-nav navbar-right navbar-user">
<li>
<a href="#" id="logout">Log out</a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1>Dashboard <small>Completed Rating Progress</small></h1>
<ol class="breadcrumb">
<li class="active"><i class="fa fa-dashboard"></i> Dashboard</li>
</ol>
</div>
</div><!-- /.row -->
<?
// outer level query
$query = "select CONCAT(upro.firstName, ' ', upro.lastName) as userName,
upro.email as email,
urp.completionDate as completeDate,
pjt.projectTitle as pjtTitle,
a.artifactTitle as aTitle,
urp.userRatingProgressID as urpID
from userRatingProgress urp
join userProfile upro on urp.userID = upro.userID
join personae p on urp.personaID = p.personaeID
join scenario s on urp.scenarioID = s.scenarioID
join projectArtifact pa on urp.projectArtifactID = pa.projectArtifactID
join project pjt on pjt.projectID = pa.projectID
join artifact a on a.artifactID = pa.artifactID
where urp.isComplete = 'true'";
$first_level_result = $dbq->prepare($query);
$first_level_result->execute();
while ($row = $first_level_result->fetch(PDO::FETCH_ASSOC)) {
?>
<?
// inner level query
$inner_query = "select c.categoryTitle as cTitle,
ur.ratingID as ratingScore
from userRatingProgress urp
join userRating ur on urp.userRatingProgressID = ur.userRatingProcessID
join scenarioCategory sc on ur.scenarioCategoryID = sc.SC_ID
join category c on c.categoryID = sc.categoryID
where urp.userRatingProgressID = " . $row['urpID'];
$stmt = $dbq->prepare($inner_query);
$stmt->execute();
$second_level_result = $stmt->fetchAll();
$half = count($second_level_result) / 2;
$sec_first_half = array_slice($second_level_result, 0, $half);
$sec_second_half = array_slice($second_level_result, $half + 1);
?>
<div class="row">
<div class="panel-group urp_record_group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse_<?= $row['urpID'] ?>">
<?= $row['userName'] . " | " . $row['pjtTitle'] . " | " . $row['aTitle'] ?>
<span class="left-small"><?= " -- Completed at: " . $row['completeDate'] ?></span>
</a>
</h4>
</div>
<div id="collapse_<?= $row['urpID'] ?>" class="panel-collapse collapse">
<div class="panel-body">
<div class="half-table-wrapper">
<table class="tbl_first_half table table-bordered table-hover table-striped tablesorter">
<tr>
<th>Category</th>
<th>User rating score</th>
</tr>
<?
for ($i = 0; $i < count($sec_first_half); $i++) {
print "<tr class='data_wrapper'><td>" . $sec_first_half[$i]['cTitle'] . "</td>";
print "<td>" . $sec_first_half[$i]['ratingScore'] . "</td></tr>";
}
?>
</table>
</div>
<div class="half-table-wrapper">
<table class="tbl_second_half table table-bordered table-hover table-striped tablesorter">
<tr>
<th>Category</th>
<th>User rating score</th>
</tr>
<?
for ($i = 0; $i < count($sec_second_half); $i++) {
print "<tr class='data_wrapper'><td>" . $sec_second_half[$i]['cTitle'] . "</td>";
print "<td>" . $sec_second_half[$i]['ratingScore'] . "</td></tr>";
}
?>
</table>
</div>
</div>
</div>
</div>
</div><!-- /accordion -->
</div><!-- /.row -->
<?
}
?>
<?
require_once "logout_form.inc.php";
?>
</div><!-- /#page-wrapper -->
<div id="noticeInfo"></div>
</div><!-- /#wrapper -->
<!-- /template -->
<!-- Included JS Files -->
<!-- template plugins -->
<!-- JavaScript -->
<script src="javascripts/jquery-1.10.2.js"></script>
<script src="javascripts/bootstrap.js"></script>
<!-- Page Specific Plugins -->
<!-- // <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script> -->
<!-- // <script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script> -->
<script src="javascripts/morris/chart-data-morris.js"></script>
<script src="javascripts/tablesorter/jquery.tablesorter.js"></script>
<script src="javascripts/tablesorter/tables.js"></script>
<script src="javascripts/main.js"></script>
<script src="javascripts/notice.js"></script>
<!-- /template plugins -->
<?
require_once "notice.inc.php";
?>
</body>
</html>
<?
} catch (PDOException $e) {
print ("getMessage(): " . $e->getMessage () . "\n");
}
?>