-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewResults.php
240 lines (210 loc) · 7.14 KB
/
viewResults.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
<?php
/* Copyright 2018 Atos SE and Worldline
* Licensed under MIT (https://github.com/atosorigin/DevOpsMaturityAssessment/blob/master/LICENSE) */
$isForm = FALSE;
$activePage = 'Results';
// Determine whether we are showing detailed results for one section
$sectionURL = '';
$uri = $_SERVER["REQUEST_URI"];
if ( strpos($uri, "results-") )
{
$sectionURL = explode("results-", $uri)[1];
$activePage = 'Detailed Reports';
}
require 'header.php';
require 'renderAdvice.php';
// Get either the overall results, or the results for the chosen sub-categories
if ( $sectionURL == '' )
{
$resultsSummary = $survey->GenerateResultsSummary();
// Sort into the order they should be displayed on the spider diagram
uasort( $resultsSummary, function($a, $b) { return $a['SpiderPos'] - $b['SpiderPos']; } );
$chartTitle = 'DevOps Maturity by Area';
}
else
{
// Need to find the name of the section we want to view
foreach ($survey->sections as $section)
{
if ( SectionnameToURLName($section['SectionName']) == $sectionURL )
{
$sectionName = $section['SectionName'];
}
}
$resultsSummary = $survey->GenerateSubCategorySummary($sectionName);
$chartTitle = 'Breakdown for ' . $sectionName;
}
// Create one variable with the labels and one with the data
$labels = '[';
$data = '[';
foreach ($resultsSummary as $sectionName=>$result)
{
$labels .= '"' . $sectionName . '",';
$data .= $result['ScorePercentage'] . ',';
}
// Replace trailing comma with closing square bracket
$labels = substr($labels, 0, -1) . ']';
$data = substr($data, 0, -1) . ']';
// Now sort by highest to lowest score
uasort( $resultsSummary, function($a, $b) { return $b['ScorePercentage'] - $a['ScorePercentage']; } );
// Now create the preamble, telling people about strengths and weaknesses
$preAmble = '';
switch ( count($resultsSummary) )
{
case 3:
$preAmble = '<p>Please find below links to resources that you may find useful for each of these areas.</p>';
break;
case 4:
$preAmble = '<p>The responses to the questionaire show that the area in which you are strongest is ' . array_keys($resultsSummary)[0] .
'.</p><p>The 3 areas where you have the most potential to improve are listed below, together with links to resources that you may find useful.</p>';
break;
case 5:
$preAmble = '<p>The responses to the questionaire show that the 2 areas in which you are strongest are ' . array_keys($resultsSummary)[0] .
' and ' . array_keys($resultsSummary)[1] . '.</p>' .
'<p>The 3 areas where you have the most potential to improve are listed below, together with links to resources that you may find useful.</p>';
break;
default:
$preAmble = '<p>The responses to the questionaire show that the 3 areas in which you are strongest are ' . array_keys($resultsSummary)[0] .
', ' . array_keys($resultsSummary)[1] . ' and ' . array_keys($resultsSummary)[2] . '.</p>' .
'<p>The 3 areas where you have the most potential to improve are listed below, together with links to resources that you may find useful.</p>';
break;
}
?>
<div class="container-fluid">
<div class="row">
<div class="col-xl-9 col-lg-11 pb-0 rounded text-center text-light mx-auto">
<div class="rounded-top p-2 ml-sm-2 ml-xs-2 mt-2 mr-sm-2 mr-xs-2 border-primary border-top border-left border-right">
<canvas id="chartOverallResults"></canvas>
<!--<image id="imageResults"></canvas>-->
</div>
</div>
</div>
<div class="row">
<div class="col-xl-9 col-lg-11 pt-0 pb-4 rounded text-left mx-auto">
<div class="bg-light rounded-bottom p-2 p-sm-4 border-primary border ml-sm-2 ml-xs-2 mb-2 mr-sm-2 mr-xs-2">
<div class="row">
<div class="col-lg-12">
<?=$preAmble?>
</div>
</div>
<?php
// Now sort by lowest to highest score
uasort( $resultsSummary, function($a, $b) { return $a['ScorePercentage'] - $b['ScorePercentage']; } );
?>
<div class="row">
<div class="col-lg-12 mt-1">
<div class="card-deck">
<div class="card border-primary">
<h5 class="card-header text-center text-white bg-primary">
<?=array_keys($resultsSummary)[0]?>
</h5>
<div class="card-body p-1">
<div>
<?php RenderAdvice(array_keys($resultsSummary)[0], true) ?>
</div>
</div>
<div class="card-footer text-center text-white bg-primary">
Your score: <?=$resultsSummary[array_keys($resultsSummary)[0]]['ScorePercentage']?>%
</div>
</div>
<div class="card border-primary">
<h5 class="card-header text-center text-white bg-primary">
<?=array_keys($resultsSummary)[1]?>
</h5>
<div class="card-body p-1">
<?php RenderAdvice(array_keys($resultsSummary)[1], true) ?>
</div>
<div class="card-footer text-center text-white bg-primary">
Your score: <?=$resultsSummary[array_keys($resultsSummary)[1]]['ScorePercentage']?>%
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 mt-sm-4">
<div class="card border-primary">
<h5 class="card-header text-center text-white bg-primary">
<?=array_keys($resultsSummary)[2]?>
</h5>
<div class="card-body p-1">
<?php RenderAdvice(array_keys($resultsSummary)[2], true) ?>
</div>
<div class="card-footer text-center text-white bg-primary">
Your score: <?=$resultsSummary[array_keys($resultsSummary)[2]]['ScorePercentage']?>%
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
Chart.defaults.global.animation.duration = 3000;
new Chart(document.getElementById("chartOverallResults"), {
type: 'radar',
data: {
labels: <?=$labels?>,
datasets: [{
lineTension: 0.4,
label: '',
pointStyle: 'circle',
pointRadius: 5,
data: <?=$data?>,
pointBackgroundColor: '#00314c',
backgroundColor: 'rgba(0, 104, 160, 0.2)',
borderColor: '#00314c'
}]
},
options: {
responsive: true,
title: {
display: true,
text: '<?=$chartTitle?>',
fontSize: 16,
fontColor: "black"
},
tooltips: {
custom: function(tooltip) {
if (!tooltip) return;
// disable displaying the color box;
tooltip.displayColors = false;
},
callbacks: {
label: function(tooltipItem, data) {
return tooltipItem.yLabel + '%';
}
}
},
legend: {
display: false
},
scaleShowLabels: true,
scale: {
ticks: {
display: false,
beginAtZero: true,
min: 0,
max: 100,
stepSize: 25,
callback: function(value, index, values) {
return value + '%';
}
},
pointLabels: {
fontSize: 14,
fontColor: "black"
},
gridLines: { color: "#0068a0" },
angleLines: { color: "#0068a0" },
}
}
}
);
//var imageURL = document.getElementById('chartOverallResults').toDataURL();
//$('#imageResults').attr('src', imageURL);
</script>
<?php
require 'footer.php';
?>