forked from tsugitools/quickwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults-download.php
More file actions
119 lines (101 loc) · 3.41 KB
/
results-download.php
File metadata and controls
119 lines (101 loc) · 3.41 KB
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
<?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);
$students = $QW_DAO->getUsersWithAnswers($_SESSION["qw_id"]);
$studentAndDate = array();
foreach ($students as $student) {
$studentAndDate[$student["user_id"]] = new DateTime($QW_DAO->getMostRecentAnswerDate($student["user_id"], $_SESSION["qw_id"]));
}
$questions = $QW_DAO->getQuestions($_SESSION["qw_id"]);
$totalQuestions = count($questions);
$toolTitle = $QW_DAO->getMainTitle($_SESSION["qw_id"]);
if (!$toolTitle) {
$toolTitle = "Quick Write";
}
include("menu.php");
// Start of the output
$OUTPUT->header();
include("tool-header.html");
?>
<style>
#results {
display: none;
}
</style>
<?php
$OUTPUT->bodyStart();
$OUTPUT->topNav($menu);
echo '<div class="container-fluid">';
$OUTPUT->flashMessages();
$OUTPUT->pageTitle('Download Results', true, false);
?>
<p class="lead">Click on the link below to download the student results.</p>
<table id="results" class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>Student Name</th>
<th>Most Recent Submission</th>
<?php
foreach($questions as $q) {
echo '<th>Question '.$q["question_num"].': '.$q["question_txt"].'</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ($studentAndDate as $student_id => $mostRecentDate) {
if (!$QW_DAO->isUserInstructor($CONTEXT->id, $student_id)) {
$formattedMostRecentDate = $mostRecentDate->format("m/d/y") . " " . $mostRecentDate->format("h:i A");
$numberAnswered = $QW_DAO->getNumberQuestionsAnswered($student_id, $_SESSION["qw_id"]);
?>
<tr>
<td><?= $QW_DAO->findDisplayName($student_id) ?></td>
<td><?= $formattedMostRecentDate ?></td>
<?php
foreach ($questions as $question) {
$response = $QW_DAO->getStudentAnswerForQuestion($question["question_id"], $student_id);
?>
<td><?= $response["answer_txt"] ?></td>
<?php
}
?>
</tr>
<?php
}
}
?>
</tbody>
</table>
<?php
echo '</div>';
$OUTPUT->helpModal("Quick Write Help", __('
<h4>Downloading Results</h4>
<p>Click on the link to download an Excel file with all of the results for this Quick Write.</p>'));
$OUTPUT->footerStart();
?>
<script>
$(document).ready(function () {
$("#results").DataTable({
order: [[0, "asc"]],
dom: '<"h4"B>t',
buttons: [
{
extend: 'excelHtml5',
text: '<span class="fa fa-download" aria-hidden="true"></span> Download All Results (.xlsx)',
title: '<?=$CONTEXT->title?>_<?=$toolTitle?>_Results',
className: 'btn btn-primary'
}
]
});
});
</script>
<?php
include("tool-footer.html");
$OUTPUT->footerEnd();