-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathslipdays.html
executable file
·179 lines (160 loc) · 7.6 KB
/
slipdays.html
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
---
layout: default
title: Check Your Slip Days!
permalink: slipdays/index.html
---
{% include nav.html %}
{% include quicklinks.html %}
<script src="{{ site.baseurl }}/assets/directory-concat.js"></script>
<link href="{{ site.baseurl }}/assets/css/cs10style.css" rel="stylesheet"/>
<script>
{% include_relative assets/cs10.js %}
</script>
<h1>Check Your Slip Day Usage</h1>
<div class="page-section">
<br>
<h2>Please enter your SID</h2>
<form class="form-inline" id='sid-form'>
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Your SID</label>
<div class="input-group">
<input type="text" class="form-control" id="sidInput" placeholder="12345678">
</div>
</div>
<button type="submit" class="btn btn-primary">Check my days!</button>
</form>
<br />
<br />
<div id="msg" class="alert hidden" role="alert">
</div>
<br />
<div id="panel" class="panel panel-primary">
<div class="panel-heading">
Slip Day Results
</div>
<div class="table-responsive">
<table border="0" id="results" class="table table-striped table-responsive">
<thead>
<tr>
<th width="60%">Assignment Name</th>
<th width="10%">Slip Days Used</th>
<th width="10%">View Assignment</th>
<th width="20%">Verified By Reader</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<em>Verified</em> means a reader has checked the slip days and you can count on that number. Otherwise, the counter could change, and you should use this as an estimation only. Please let your TA know if any of these numbers are wrong.
</td>
</tr>
</tfoot>
<tbody id="table-contents">
</tbody>
</table>
</div>
</div>
</div>
<style type="text/css">
.good {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAltJREFUSA3tVL9PFFEQnr3Di9y5BBIKAgkNjbWNhRSXkNjbEwrD32Ar0PMfKAUJrX8ACUYTKWysbWggGkmOwO3Pt+zdPuYbbo536565oMbGucz7NTPfNzPv3RL9l3/dAe9PJPDy8Nlibcr7VvTs0t7z4+8uZs3d3Get4CuPVwgk2Ls4v0Xggmd5RvPL8z+R3JugDG5yI4kriVYxpQudNbCqn2UftMVcGwK4591eZ+e0Q2RpW31HKlDwcf1EkOuTZimlJiVrraiCv1n7tAVfyJBAA2cXZikxCVWRqA9sSZpQnMRUFAXZwtLF2YVk7oKDYPhMN9+vWoBLNhzQnG5Sq9mik68nhHZJNvxKAB7HsYB7NY+g3fNuJbjEYBDhvl39uJJskFUYhhRF0bASPEGAR2FEQRhI5vD7FThwhxVgs3m0usUnr1tzLSFC6b7vkz/jw0xBEFAYhHKhyDzpJmMzlwAe6rrA/GX/9MOTjWUvN3m73qgLiUn5hfDPGEPBZSAthK8J+Vly1eWew+bKSAVq0Eoa043bSviVqOA55lk+EThiRipQEK2k3+u30QrOVIhg7+W9icHhX0kAg5LwPbSxBwkudZK2iP9gGEsAO5N85DvBso2B/047b9eOd3iJ1qrCVNnqsgFO+OPh8/FgMCOB2vq7p68s3/TBi8+7vFfBxUC5LNE+z9w/4guSGeccdicAb7A+YsW7fMgKIpAIEc+atQsOYCiAU9ZooNc8F+WPHVjhiE8jQLAuE/CRiGavBMg+Y0UMcETcCnCgbUI1UN1r5vBxxa0Ea5ApMea/LzcsIEQubh6TAQAAAABJRU5ErkJggg==');
}
.bad {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEt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PvKKGO5mbTfDBYtyuVqkb4sAHPglHpyXyr9WiTx2NWJidBm58HsaoKOLQbly5Jcjz+bUaSboX9/gaCc1h66dlZ4DQN7AiPhkJ1byH8HCrvM0KBSk8g9Hh9e7tZuXtXh5oQSMU/cflyMrm09B1m/wNUdAEXl0X8/kZSSk2Qmp4GIHhDgykWCtX+kU6/in5jz7PK88fXNzWZ6ehp7Cg9URiCiStXDOgx44hUXslEYmDc55M0LDsRN0/hR0jD9t7g8ViYIBwhXx3MNG1oamJC5jGWa+rqgEPo7atXJem50izUgFNDyM+e9ePGkoodaaqtBa6sDGbu35ewO382/OCfD/3wsM0m/bltGxsqKEhSa2cd/mVCeTlnsSQnt25l5ysr6UM/bHzoKUz69SnAmhqAQYHnu2RNG3wX/3LwhQmNEkxGpyN/hqahqWT9GPt8jjuK/eL9HuDYGECSfLJgvKE5LaZuJCNorhGcfHQgjpkcU3BuGG0KfwN/3QP6oaQZ+wAAAABJRU5ErkJggg==');
}
.good, .bad {
content: ' ';
background-repeat: no-repeat;
background-position: center;
}
</style>
<!--
This makes a call to the slip day tracker
The API format is entirely custom but pretty simple. View it here:
https://github.com/cs10/Alonzo/blob/master/scripts/cs10-slipdays.js#L128-L175
-->
<script type="text/javascript">
var buildTable = function(result, xhr, other) {
var table = $('#table-contents'),
msg = $('#msg'),
panel = $('#panel');
// Reset the view
table.html('');
msg.html('');
msg.removeClass('hidden alert-danger alert-success alert-warning');
panel.removeClass('panel-danger panel-success panel-warning');
if (result.errors) {
msg.addClass('alert-danger');
result.errors.forEach(function(error, idx) {
if (!idx) {
msg.append($('<strong>').html(error));
msg.append($('<ul>'));
msg = $('#msg>ul');
} else {
msg.append($('<li>').html(error));
}
});
return;
}
// Add any warning messages
var days = result.daysRemaining;
var notice = '', bsClass = '';
if (days > 0) {
bsClass = 'success';
notice = 'Good work! You\'ve got some breathing room!';
} else if (days === 0) {
bsClass = 'warning';
notice = 'You\'re at the limit of slip days! Be careful, or you\'ll lose points.';
} else {
bsClass = 'danger';
notice = 'Uh-oh! We\'ll need to dock some points.';
}
panel.addClass('panel-' + bsClass);
msg.addClass('alert-' + bsClass);
msg.append($('<strong>').html(notice));
msg.append('<br>');
msg.append('You have used ' + result.totalDays + ' slip days and have ' +
days + ' slip days remaining.');
result.assignments.forEach(function(item) {
var row = $('<tr>');
var link = $('<a>').attr({
'href':item.url.replace('?preview=1', ''), 'target':'_blank' }).html('View Submission');
link = link[0].outerHTML;
var good = item.verified ? 'good' : 'bad';
var cells = '<td>' + item.title + '</td>';
cells += '<td>' + item.slipDays + '</td>';
cells += '<td>' + link + '</td>';
cells += '<td class="' + good + '"><span class="sr-only">' + item.verified + '</span></td>';
row.append(cells);
table.append(row);
});
};
var makeSlipDaysCall = function(sid) {
var dom = 'alonzo.herokuapp.com';
// Local hosts use a local Alonzo URL
if (location.port === '4000') {
dom = 'localhost:8080';
}
var url = 'https://' + dom + '/slipdays/' + sid;
$.ajax({
url: url,
cache: true,
crossDomain: true,
success: buildTable,
error: function(a, b, c) { // TODO: Better error handling..
var table = $('#table-contents');
table.append($('<tr>').html($('<td>').html('Whoops, an error occured! Sorry!')));
}
});
}
$(document).ready(function() {
var search = location.search.split('?');
if (search.length > 1 && search[1]) {
makeSlipDaysCall(search[1]);
}
$('#sid-form').submit(function(evt) {
makeSlipDaysCall($('#sidInput').val());
evt.preventDefault();
});
});
</script>