-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
280 lines (279 loc) · 13.5 KB
/
index.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!DOCTYPE html>
<html>
<head>
<title>BPS Online Transportation Challenge</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="js/path.js"></script>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp"
crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clusterize.js/0.17.6/clusterize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.31.2/handsontable.full.min.js"></script>
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.core.min.css">
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.default.min.css">
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.bootstrap.min.css">
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/clusterize.js/0.17.6/clusterize.min.css">
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.31.2/handsontable.full.min.css">
<script src="https://www.gstatic.com/firebasejs/3.7.4/firebase.js"></script>
<!-- <link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css"> -->
<script src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.13/js/dataTables.bootstrap.min.js"></script>
<link rel="stylesheet" href="css/ladda-themeless.min.css">
<link rel="stylesheet" media="screen" href="css/style.css">
<script src="js/scoreboard.js"></script>
</head>
<body>
<header>
<div class="container">
<h1>Boston Public Schools<br/>
<small>Online Transportation Challenge</small>
</h1>
<div id="logos">
<a href="https://www.bostonpublicschools.org"><img src="img/bps.png" width="120px;" alt="BPS logo"/></a>
<a href="https://www.bu.edu"><img src="img/bu.gif" alt="BU logo"/></a>
</div>
</div>
</header>
<div id="shadow" class="ss-style-multitriangles"></div>
<main id="content" class="container">
<section id="session-area" class="card">
<h2 class="text-center">Download a solution template</h2>
<p class="text-center">Use the files below to structure your own candidate solutions. All solutions submitted for evaluation must exactly match the format of these template and example files.</p>
<hr/>
<div class="row">
<div class="col-md-12">
<table style="width:100%;">
<tr><td><a href="bps-tc-template.xlsx">Download solution <b>template</b></a> (to be filled out by you)</td></tr>
<tr><td><a href="bps-tc-example.xlsx">Download solution <b>example</b> file</a> (to see an example of the solution format)</td></tr>
<tr><td><a href="bps-tc-invalid.xlsx">Download <b>invalid</b> solution example file</a> (to see examples of validation errors)</td></tr>
<tr><td><a href="bps-tc-complete.xlsx">Download a <b>full-scale complete solution</b> file</a> (generated using <a href="https://github.com/Data-Mechanics/bps-simulated-data">bps-simulated-data</a>)</td></tr>
</table>
<br/>
</div>
</div>
</section>
<section id="session-area" class="card">
<h2 class="text-center">Load and evaluate your solution</h2>
<p class="text-center">Drag and drop your completed template file. Once the file has been loaded (<b>which may take a few minutes for complete solutions</b>) you can select your chosen criteria and evaluate your solution by clicking <b>Evaluate solution</b>.</p>
<hr/>
<div class="row">
<div class="col-md-4">
<div id="drop-area">
Drag and drop your solution file here
<br/>
<p>—or—</p><br/>
<button id="choose-file-button" class="btn btn-primary">Choose file</button>
</div>
<input type="file" id="choose-file" accept=".xlsx,.xls,.XLSX,.XLS">
</div>
<div id="criteria" class="col-md-8">
<span>Choose the criteria to use for evaluation:</span>
<div class="checkbox">
<label><input type="checkbox" value="">Student data matches challenge data.</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Student bus stop assignments adhere to constraints.</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Every student boards their assigned bus.</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Every student reaches their assigned school.</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Bus routes begin and end at bus yards.</label>
</div>
</div>
<div class="col-md-12">
<div id="simulation_view" style="display:none;">
<button class="btn btn-primary ladda-button btn-lg btn-block" onclick="simulate(workbook_js);">Evaluate solution</button>
<br/>
<div class="clusterize">
<table>
<thead>
<tr>
<th style="font-weight:normal;">Click <b>Evaluate solution</b> above to begin validating and evaluating your data. This area will display the results of the evaluation.</th>
</tr>
</thead>
</table>
<br/>
<div id="scrollArea" class="clusterize-scroll">
<table>
<tbody id="contentArea" class="clusterize-content">
<!--tr class="clusterize-no-data">
<td style="text-align:left; text-decoration:underline;"><b>Simulation Progress and Results</b></td>
</tr-->
</tbody>
</table>
</div>
</div>
<br/>
</div>
</div>
</div>
</section>
<section id="instructions" class="card">
<h2 class="text-center">Review your loaded solution</h2>
<p class="text-center">You may examine your loaded solution below, if you wish to do so.</p>
<span id="expand-table-button" class="arrow-down"></span>
<div id="tables-area">
<div id="spreadsheet_view" style="display:none;">
<div id="buttons"></div>
<div id="hot" style="overflow:scroll" class="handsontable"></div>
</div>
</div>
</section>
<section class="card">
<h2 class="text-center">Submit and post your score</h2>
<p class="text-center">If you are satisfied with your evaluation, you may post your score for the record. The name you specified will appear once it is approved by a moderator.</p>
<hr/>
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6">
</div>
</div>
<div class="row">
<div class="col-md-12">
<form>
<div class="row-fluid">
<table style="width:100%;">
<tr>
<td width="60px;"><b>Name* :</b> </td><td><input type="text" style="width:100%;" pattern="[a-zA-Z0-9\s]+" id="submitter_name"/></td>
<td style="text-align:center; font-size:18px;"><div class="result"><span id="buses">#</span> buses</div></td>
<td style="text-align:center; font-size:18px;"><div class="result"><span id="miles">#</span> miles</div></td>
</tr>
<tr>
<td></td><td><small>* as it will appear in the scoreboard after approval</small></td>
<td></td>
<td></td>
</tr>
</table>
<br/>
</div>
<input type="hidden" id="buses_submit" value=""/>
<input type="hidden" id="miles_submit" value=""/>
<button type="submit" id="submit" class="disabled non-active btn btn-primary ladda-button btn-lg btn-block" onclick="prepareSubmitData()">Submit</button>
</form>
</div>
</div>
</section>
<section class="card">
<h2 class="text-center">Scoreboard</h2>
<p class="text-center">The scores for past submissions can be viewed below.</p>
<hr/>
<div id="scoreboard_container" class="row">
<table id="scoreboard"></table>
</div>
</section>
</main>
<footer>
<div class="container">
View and contribute to the source code for this page <a href="https://github.com/Data-Mechanics/bps-challenge-score">on GitHub</a>.
</div>
</footer>
<script src="js/data.structs.js"></script>
<script src="js/xlsx.full.min.js"></script>
<script src="js/dropsheet.js"></script>
<script>
var sheets = {'Buses':true, 'Stop-Assignments':true, 'Routes':true};
var scoreboard;
var _target = document.getElementById('drop-area');
var _choose = document.getElementById('choose-file-button');
var spinner;
var _workstart = function() { spinner = new Spinner().spin(_target); }
var _workend = function(clusterize) {
return function() {
spinner.stop();
$("#criteria").fadeTo(250, 1);
$('#simulation_view').show();
$('#spreadsheet_view').show();
clusterize.clear();
};
};
var _badfile = function() { alertify.alert('This file does not appear to be a valid Excel file.', function(){}); };
var _pending = function() { alertify.alert('Please wait until the current file is processed.', function(){}); };
var _large = function(len, cb) { alertify.confirm("This file is " + (len/(1024*1024)).toFixed(2) + " MB and may take a few moments. Your browser may lock up during this process. Continue?", cb); };
var _failed = function(e) { alertify.alert('This format is not supported.', function(){}); };
var boldRenderer = function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.TextCell.renderer.apply(this, arguments);
$(td).css({'font-weight': 'bold'});
};
var make_buttons = function(sheetnames, cb) {
var $buttons = $('#buttons');
$buttons.html("");
sheetnames.forEach(function(s,idx) {
if (s in sheets) {
var button= $('<button/>').attr({ type:'button', name:'btn' +idx, text:s });
button.append(s);
button.click(function() { cb(idx); });
$buttons.append(button);
}
});
};
var $window, availableWidth, availableHeight;
var calculateSize = function () {
availableWidth = Math.max($('#drop').width(), 600);
availableHeight = Math.max($window.height() - 250, 400);
};
var _onsheet = function(json, cols, sheetnames, select_sheet_cb) {
make_buttons(sheetnames, select_sheet_cb);
calculateSize();
if (!json) json = []; /* add header row for table */
json.unshift(function(head){var o = {}; for(i=0;i!=head.length;++i) o[head[i]] = head[i]; return o;}(cols));
calculateSize();
$("#hot").handsontable({
data: json,
startRows: 5, startCols: 3, fixedRowsTop: 1,
stretchH: 'all',
rowHeaders: true,
columns: cols.map(function(x) { return {data:x}; }),
colHeaders: cols.map(function(x,i) { return XLS.utils.encode_col(i); }),
cells: function (r,c,p) { if(r === 0) this.renderer = boldRenderer; },
width: function () { return availableWidth; },
height: function () { return availableHeight; },
stretchH: 'all'
});
};
$(document).ready(function() {
$window = $(window);
$window.on('resize', calculateSize);
$( document ).on( "submitReadyEvent", function( event, arg1, arg2 ) {
console.log( "submission ready!" );
$("#submit").removeClass('disabled');
$("#submit").removeClass('non-active');
$("#submit").addClass('enabled');
});
});
var clusterize = new Clusterize({scrollId:'scrollArea', contentId:'contentArea'});
var workbook_js = DropSheet({
drop: _target, choose: _choose,
on: { workstart: _workstart, workend: _workend(clusterize), sheet: _onsheet },
errors: { badfile: _badfile, pending: _pending, failed: _failed, large: _large }
}, sheets);
$('#tables-area').hide();
$('#expand-table-button').click(function (e) {
$('#tables-area').slideToggle();
$(e.target).toggleClass('flip');
});
</script>
<script src="js/simulation.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js"></script>
</body>
</html>