Skip to content

Commit 9fc935b

Browse files
bad code
1 parent 271678f commit 9fc935b

9 files changed

Lines changed: 453 additions & 17 deletions

File tree

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ app.post('/test/endpoint/:recordId', async (req, res) => {
232232
console.log(e);
233233
}
234234
} else {
235-
res.status(400).send("Unkown Request");
235+
res.status(400).send("Unknown Request");
236236
}
237237
});
238238

@@ -259,6 +259,9 @@ app.get('**', async (req, res) => {
259259
});
260260
});
261261

262+
// Eliminate events
263+
// possibleRedirects = []
264+
262265
let redirects = await extraneousRedirectsTable.read()
263266
redirects.forEach(extraneousRedirect => {
264267
possibleRedirects.push({

one-time-scripts/initialize-tests.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const { apiKey, baseID, sampleTestId } = require('./../secrets.js');
66

77
// baseID, apiKey, and tableName can alternatively be set by environment variables
88
const testsTable = new AirtablePlus({ tableName: "Tests", apiKey, baseID }),
9-
competitionsTable = new AirtablePlus({ tableName: "Competitions", apiKey, baseID });
9+
competitionsTable = new AirtablePlus({ tableName: "Competitions", apiKey, baseID }),
10+
volunteersTable = new AirtablePlus({ tableName: "Volunteers", apiKey, baseID });
1011

1112
(async () => {
1213
const tests = await testsTable.read();
@@ -18,6 +19,7 @@ const testsTable = new AirtablePlus({ tableName: "Tests", apiKey, baseID }),
1819
// NOTE: this assumes no tests are added and no competitions are changed while this is running
1920

2021
tests.forEach((test, testIndex) => {
22+
// console.log(test);
2123
const competitionId = test.fields.Competition[0];
2224
const comp = competitions.find(c => c.id == competitionId);
2325

@@ -28,7 +30,16 @@ const testsTable = new AirtablePlus({ tableName: "Tests", apiKey, baseID }),
2830
numQuestions++
2931
} else break;
3032
}
31-
const questionOrder = shuffle([...Array(numQuestions).keys()].map(x => ++x)).join(","); // Pretty proud of this line ngl
33+
34+
var questionOrder;
35+
36+
if(test.fields['Competition Name'][0].includes("Creative Thinking")) {
37+
questionOrder = [...Array(numQuestions).keys()].map(x => ++x).join(",");
38+
}
39+
else {
40+
questionOrder = shuffle([...Array(numQuestions).keys()].map(x => ++x)).join(","); // Pretty proud of this line ngl
41+
}
42+
3243

3344
let testGrader = [graders[testIndex % graders.length].id];
3445

@@ -55,4 +66,4 @@ function shuffle(array) {
5566
}
5667

5768
return array;
58-
}
69+
}

one-time-scripts/load-students-virtual.js

Lines changed: 403 additions & 0 deletions
Large diffs are not rendered by default.

schedule.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ let filterNonTestingRooms = (nonTestingRooms, groups, showDivision=false) => {
1919
name: name,
2020
openTime: room.fields.Start,
2121
closeTime: room.fields.End,
22-
openTimeText: new Date(room.fields.Start).toLocaleTimeString("CDT", { timeStyle: 'short', timeZone: "America/Chicago" }),
22+
openTimeText: new Date(test.fields["Competition Start Time"]).toLocaleString("CDT", { timeStyle: 'short', dateStyle: 'short', timeZone: "America/Chicago" }),
23+
closeTimeText: new Date(test.fields["Competition End Time"]).toLocaleString("CDT", { timeStyle: 'short', dateStyle: 'short', timeZone: "America/Chicago" }),
2324
id: room.fields.ID
2425
});
2526
});
@@ -67,19 +68,23 @@ module.exports = (app, { eventsTable, studentsTable, schoolsTable, testsTable, a
6768
name: test.fields["Competition Friendly Name"],
6869
openTime: test.fields["Competition Start Time"],
6970
closeTime: test.fields["Competition End Time"],
70-
openTimeText: new Date(test.fields["Competition Start Time"]).toLocaleTimeString("CDT", { timeStyle: 'short', timeZone: "America/Chicago" }),
71+
openTimeText: new Date(test.fields["Competition Start Time"]).toLocaleString("CDT", { timeStyle: 'short', dateStyle: 'short', timeZone: "America/Chicago" }),
72+
closeTimeText: new Date(test.fields["Competition End Time"]).toLocaleString("CDT", { timeStyle: 'short', dateStyle: 'short', timeZone: "America/Chicago" }),
7173
teamTest,
7274
students: test.fields["Student Names"],
7375
};
7476
}));
7577

78+
// let liveAlerts = websocket.getAlerts(alertsTable)
7679
let [nonTestingRooms, liveAlerts] = await Promise.all([eventsTable.read(), websocket.getAlerts(alertsTable)]);
80+
// eventsTable.read()
81+
// screw non testing rooms
7782

7883
let alertsObject = await websocket.getAlertObject(liveAlerts),
7984
alertsHtml = alertsObject.html;
8085

81-
let filteredNonTestingRooms = filterNonTestingRooms(nonTestingRooms, [school.fields.Division, "Students"])
82-
studentRooms = studentRooms.concat(filteredNonTestingRooms);
86+
// let filteredNonTestingRooms = filterNonTestingRooms(nonTestingRooms, [school.fields.Division, "Students"])
87+
// studentRooms = studentRooms.concat(filteredNonTestingRooms);
8388

8489
studentRooms.sort((a, b) => new Date(a.openTime) - new Date(b.openTime));
8590

@@ -110,6 +115,8 @@ module.exports = (app, { eventsTable, studentsTable, schoolsTable, testsTable, a
110115

111116
app.get('/coaches', async (req, res) => {
112117
let nonTestingRooms = await eventsTable.read();
118+
// screw non-testing rooms
119+
// await eventsTable.read();
113120
let filteredNonTestingRooms = filterNonTestingRooms(nonTestingRooms, ["Coaches"], showDivision=true);
114121

115122
let liveAlerts = await websocket.getAlerts(alertsTable);
@@ -139,6 +146,8 @@ module.exports = (app, { eventsTable, studentsTable, schoolsTable, testsTable, a
139146

140147
app.get('/parents', async (req, res) => {
141148
let nonTestingRooms = await eventsTable.read();
149+
// screw non-testing rooms
150+
// await eventsTable.read();
142151
let filteredNonTestingRooms = filterNonTestingRooms(nonTestingRooms, ["Parents"], showDivision=true);
143152

144153
let liveAlerts = await websocket.getAlerts(alertsTable);

tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const getOrderedQuestions = async (record, competitionCode, competitionId) => {
6363
}
6464

6565
const validateTime = (competition, record, allowExtra=false) => {
66+
return "true";
67+
6668
if (record.id === sampleTestId) {
6769
return "true";
6870
} else if (record.id === masterTestId) {

views/pages/links.ejs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,29 @@
4848
</h4>
4949
<table class="table table-hover">
5050
<tr class="header-row">
51-
<th></th>
51+
<th>Contest Window</th>
5252
<th>Event</th>
53-
<th>&nbsp;</th> <!-- Zoom Link -->
53+
<!-- <th>&nbsp;</th> --> <!-- Zoom Link -->
5454
<th style="text-align: center;">&nbsp;</th> <!-- Contest Link -->
5555
</tr>
5656

5757
<% for (var i=0; i < rooms.length; i++) { %>
5858
<tr class="<%= rooms[i].active ? " active-row" : "" %>">
5959
<td opentimetext="<%= rooms[i].openTimeText %>">
60-
<%= rooms[i].openTimeText %>
60+
<%= rooms[i].openTimeText %> CT - <br/ > <%= rooms[i].closeTimeText %> CT
6161
</td>
6262
<td>
6363
<%= rooms[i].name %> <br>
6464
<span class="supporting-text">
6565
<%= rooms[i].subtext %>
6666
</span>
6767
</td>
68-
<td>
68+
<!-- <td>
6969
<% if (rooms[i].zoomLink) { %>
7070
<button class="btn btn-primary" onclick="window.open('<%= rooms[i].zoomLink %>','_blank')"
7171
<%=rooms[i].active ? "" : "disabled" %>>Join Zoom Meeting</button>
7272
<% } %>
73-
</td>
73+
</td> -->
7474
<td>
7575
<% if (rooms[i].testLink) { %>
7676
<button class="btn btn-dark" style="display:block;margin:auto;"
@@ -98,8 +98,6 @@
9898
9999
</div>
100100
101-
<%- include('../partials/footer'); %>
102-
103101
<script>
104102
105103
</script>

views/pages/tests.ejs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,18 @@
376376
mainToast.show();
377377
}
378378
379-
if (minutes == 0 && seconds == 0) {
379+
console.log(questions)
380+
381+
if (competitionCode.endsWith('-C') && questionOnOpen) {
382+
383+
}
384+
385+
if (minutes < 0) {
380386
// TODO: MAKE SURE THIS ACTUALLY SUBMIT
381387
$(".next-button").click();
382388
clearInterval(counterInterval);
383389
// TODO: Add actual good looking alert
384-
alert("Time is Up! Your last question was automatically submitted.");
390+
alert("Time is up! Your last question was automatically submitted.");
385391
location.reload();
386392
}
387393
}

views/partials/footer.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!-- TODO: update and use other partials like this -->
22
<footer class="py-4 bg-black">
3+
34
<div class="container partners">
45
<div class="partner">
56
<a href="https://aops.com" class="text-reset">
@@ -31,6 +32,8 @@
3132
</div> -->
3233
</div>
3334
<div class="container">
35+
<p class="m-0 text-center text-white small">Having technical trouble? Visit <a href="https://bit.ly/jhmchelp">bit.ly/jhmchelp</a>
36+
for support. Link will be active from 7AM to 9PM CST on 03/12/22.</p>
3437
<p class="m-0 text-center text-white small">Copyright &copy; JHMC 2022</p>
3538
</div>
3639

views/partials/navbar.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
</ul>
6060
</div>
6161
</div>
62+
6263
</div>
6364
</nav>
6465
</div>

0 commit comments

Comments
 (0)