-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathview-all-results.php
127 lines (96 loc) · 4.01 KB
/
view-all-results.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
<?php
require_once('../config.php');
require_once('dao/QW_DAO.php');
use QW\DAO\QW_DAO;
use Tsugi\Core\LTIX;
// Retrieve the launch data if present
$LAUNCH = LTIX::requireData();
$p = $CFG->dbprefix;
$QW_DAO = new QW_DAO($PDOX, $p);
// Start of the output
$OUTPUT->header();
include("tool-header.html");
?>
<style type="text/css">
body {
background: #efefef;
}
</style>
<?php
$OUTPUT->bodyStart();
$mainId = $_SESSION["qw_id"];
$questions = $QW_DAO->getQuestions($mainId);
$totalQuestions = count($questions);
$StudentList = $QW_DAO->getUsersWithAnswers($mainId);
?>
<div class="container-fluid">
<ol class="breadcrumb">
<li><a href="instructor-home.php">Home</a></li>
<li class="active">All Results</li>
</ol>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<h2>All Results<span class="pull-right export-link"><a href="actions/ExportToFile.php"><span class="fa fa-cloud-download" aria-hidden="true"></span> Export Results</a></span></h2>
<?php
if (!$StudentList) {
echo ('<h4 class="text-center"><em>No students have answered yet.</em></h4>');
} else {
?>
<div class="table-responsive">
<table class="table table-bordered table-striped fadeInFast" id="allResultsTable">
<thead>
<tr>
<th>Student</th>
<th>Answers</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $StudentList as $student ) {
$userId = $student['user_id'];
$displayName = $QW_DAO->findDisplayName($userId);
$mostRecentDate = new DateTime($QW_DAO->getMostRecentAnswerDate($userId, $mainId));
$formattedDate = $mostRecentDate->format("m-d-y")." at ".$mostRecentDate->format("h:i A");
echo ('<tr>
<th rowspan="'.($totalQuestions*2).'" class="col-sm-2">
'.$displayName.'<br /><small class="text-muted date">'.$formattedDate.'</small>
</th>
');
$firstQuestion = true;
foreach ( $questions as $question ) {
$question_id = $question['question_id'];
if (!$firstQuestion) {
echo ('<tr>');
}
echo ('<td class="question-col">
'.$question["question_txt"].'
</td>');
if ($firstQuestion) {
$firstQuestion = false;
echo ('</tr>');
}
$answer = $QW_DAO->getStudentAnswerForQuestion($question_id, $userId);
$answerText = "";
if ($answer) {
$answerText = $answer["answer_txt"];
} else {
$answerText = '<span class="text-muted"><em>No answer</em></span>';
}
echo ('<tr><td class="answer-col">'.$answerText.'</td></tr>');
}
}
?>
</tbody>
</table>
</div>
<?php
}
?>
<a href="instructor-home.php" class="btn btn-primary fadeInFast big-shadow">Back</a>
</div>
</div>
</div>
<?php
$OUTPUT->footerStart();
include("tool-footer.html");
$OUTPUT->footerEnd();