-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUsage.php
100 lines (72 loc) · 3.03 KB
/
Usage.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
<?php
require_once "../config.php";
require_once "dao/FlashcardsDAO.php";
require_once "util/FlashcardUtils.php";
use \Tsugi\Core\LTIX;
use \Flashcards\DAO\FlashcardsDAO;
// Retrieve the launch data if present
$LAUNCH = LTIX::requireData();
$p = $CFG->dbprefix;
$flashcardsDAO = new FlashcardsDAO($PDOX, $p);
$OUTPUT->header();
include("tool-header.html");
$OUTPUT->bodyStart();
if ( $USER->instructor ) {
include("menu.php");
$setId = $_GET["SetID"];
$set = $flashcardsDAO->getFlashcardSetById($setId);
echo('
<ul class="breadcrumb">
<li><a href="index.php">All Card Sets</a></li>
<li>' .$set["CardSetName"].'</li>
</ul>
');
$cardsInSet = $flashcardsDAO->getCardsInSet($setId);
$totalCards = count($cardsInSet);
$rosterData = LTIX::getRosterMembers($LAUNCH);
if ($rosterData) {
echo('<div class="row">
<div class="col-sm-12">
<h3><a href="actions/ExportActivity.php?SetID='.$setId.'" class="btn btn-link pull-right">Export Usage to Excel</a><span class="fa fa-bar-chart"></span> '.$set["CardSetName"].' Usage</h3>
</div>
</div>');
echo('<div class="row"><div class="col-sm-4"><h4>Student Name</h4></div><div class="col-md-6"><h4>Progress</h4></div></div>');
usort($rosterData, array('FlashcardUtils', 'compareStudentsLastName'));
foreach($rosterData as $student) {
// Only want students
if (in_array($student->sakai_ext->sakai_role, ['Student', 'Learner'])) {
echo('<div class="row">
<div class="col-sm-4">'.$student->family_name.', '.$student->given_name.'</div>');
$userId = $flashcardsDAO->getTsugiUserId($student->lti11_legacy_user_id);
if (!$userId) {
$numberCompleted = 0;
} else {
$numberCompleted = $flashcardsDAO->getNumberOfSeenCards($userId, $setId);
}
$percentComplete = $numberCompleted / $totalCards * 100;
if($percentComplete < 25) {
$progressClass = 'danger';
} else if ($percentComplete < 75) {
$progressClass = 'warning';
} else {
$progressClass = 'success';
}
echo('<div class="col-sm-6">
<div class="progress">
<div class="progress-bar progress-bar-'.$progressClass.'" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:'.$percentComplete.'%">
'.$numberCompleted.' / '.$totalCards.' Cards Viewed
</div>
</div>
</div>
</div>
');
}
}
}
} else {
// student so send back to index
header( 'Location: '.addSession('index.php') ) ;
}
$OUTPUT->footerStart();
include("tool-footer.html");
$OUTPUT->footerEnd();