Skip to content

Commit 45fc75f

Browse files
authored
Fix marked responses
2 parents 790a62f + c8593a0 commit 45fc75f

File tree

2 files changed

+45
-41
lines changed

2 files changed

+45
-41
lines changed

src/checker/admin.js

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,6 @@ try {
18951895
if (!a.flagged && b.flagged) return 1;
18961896
return b.id - a.id;
18971897
});
1898-
var seatCodes = [];
18991898
pagination.awaitingResponses.total = responses1.filter(r => ((r.status === 'Invalid Format') || (r.status === 'Unknown, Recorded')) && document.querySelector('.awaitingResponses .section')).length;
19001899
pagination.responses.total = responses1.filter(r => !((r.status === 'Invalid Format') || (r.status === 'Unknown, Recorded')) && document.querySelector('.responses .section')).length;
19011900
if (document.querySelector('.awaitingResponses #current-page')) document.querySelector('.awaitingResponses #current-page').innerText = `Page ${pagination.awaitingResponses.page + 1} of ${Math.ceil(pagination.awaitingResponses.total / pagination.awaitingResponses.perPage)}`;
@@ -1906,8 +1905,8 @@ try {
19061905
const normalResponses = responses1.filter(r => !(r.status === 'Invalid Format' || r.status === 'Unknown, Recorded'));
19071906
const awaitingPageResponses = awaitingSection ? awaitingResponses.slice(pagination.awaitingResponses.page * pagination.awaitingResponses.perPage, (pagination.awaitingResponses.page + 1) * pagination.awaitingResponses.perPage) : [];
19081907
const responsesPageResponses = responsesSection ? normalResponses.slice(pagination.responses.page * pagination.responses.perPage, (pagination.responses.page + 1) * pagination.responses.perPage) : [];
1909-
var responses2 = awaitingSection ? awaitingPageResponses : (responsesSection ? responsesPageResponses : []);
1910-
responses2.forEach(r => {
1908+
var pageResponses = [...awaitingPageResponses, ...responsesPageResponses];
1909+
pageResponses.forEach(r => {
19111910
if (document.querySelector('.responses .section') || document.querySelector('.awaitingResponses .section')) {
19121911
var responseString = r.response;
19131912
var isMatrix = null;
@@ -2042,35 +2041,36 @@ try {
20422041
});
20432042
}
20442043
});
2045-
responses1.forEach(r => {
2046-
if (document.querySelector('.seat-code-reports')) {
2047-
if (seatCodes.find(seatCode => seatCode.code === r.seatCode)) {
2048-
const seatCode = seatCodes.find(seatCode => seatCode.code === r.seatCode);
2049-
if (r.status === 'Correct') {
2050-
seatCode.correct++;
2051-
} else if (r.status === 'Incorrect') {
2052-
seatCode.incorrect++;
2053-
} else if (r.status.includes('Recorded')) {
2054-
seatCode.waiting++;
2044+
if (document.querySelector('.seat-code-reports')) {
2045+
var seatCodes = [];
2046+
responses1.forEach(r => {
2047+
if (document.querySelector('.seat-code-reports')) {
2048+
if (seatCodes.find(seatCode => seatCode.code === r.seatCode)) {
2049+
const seatCode = seatCodes.find(seatCode => seatCode.code === r.seatCode);
2050+
if (r.status === 'Correct') {
2051+
seatCode.correct++;
2052+
} else if (r.status === 'Incorrect') {
2053+
seatCode.incorrect++;
2054+
} else if (r.status.includes('Recorded')) {
2055+
seatCode.waiting++;
2056+
} else {
2057+
seatCode.other++;
2058+
}
2059+
seatCode.total++;
2060+
seatCode.responses.push(r);
20552061
} else {
2056-
seatCode.other++;
2062+
seatCodes.push({
2063+
code: r.seatCode,
2064+
correct: (r.status === 'Correct') ? 1 : 0,
2065+
incorrect: (r.status === 'Incorrect') ? 1 : 0,
2066+
other: ((r.status !== 'Correct') && (r.status !== 'Incorrect') && !r.status.includes('Recorded')) ? 1 : 0,
2067+
waiting: r.status.includes('Recorded') ? 1 : 0,
2068+
total: 1,
2069+
responses: [r],
2070+
});
20572071
}
2058-
seatCode.total++;
2059-
seatCode.responses.push(r);
2060-
} else {
2061-
seatCodes.push({
2062-
code: r.seatCode,
2063-
correct: (r.status === 'Correct') ? 1 : 0,
2064-
incorrect: (r.status === 'Incorrect') ? 1 : 0,
2065-
other: ((r.status !== 'Correct') && (r.status !== 'Incorrect') && !r.status.includes('Recorded')) ? 1 : 0,
2066-
waiting: r.status.includes('Recorded') ? 1 : 0,
2067-
total: 1,
2068-
responses: [r],
2069-
});
20702072
}
2071-
}
2072-
});
2073-
if (document.querySelector('.seat-code-reports')) {
2073+
});
20742074
var sortedSeatCodes = seatCodes.filter(seatCode => JSON.parse(courses.find(course => String(course.id) === document.getElementById("course-period-input")?.value).periods).includes(Number(String(seatCode.code)[0])));
20752075
if (document.getElementById('useRoster').checked) {
20762076
var currentCourseRosters = rosters.filter(roster => JSON.parse(courses.find(course => String(course.id) === document.getElementById("course-period-input").value)?.periods).includes(Number(String(roster.period))));
@@ -5933,18 +5933,20 @@ try {
59335933
if (!group) return;
59345934
pagination[group].page = pagination[group].page - 1;
59355935
updateResponses();
5936-
paginationSection.getElementById('current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
5937-
paginationSection.getElementById('next-page').disabled = false;
5938-
paginationSection.getElementById('previous-page').disabled = (pagination[group].page - 1 < 0) ? true : false;
5936+
paginationSection.parentElement.querySelector('#current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
5937+
paginationSection.parentElement.querySelector('#next-page-button').disabled = false;
5938+
paginationSection.parentElement.querySelector('#previous-page-button').disabled = (pagination[group].page - 1 < 0) ? true : false;
59395939
}
59405940

59415941
function nextPage(paginationSection) {
59425942
const group = Array.from(paginationSection.parentElement.parentElement.classList).find(a => Object.keys(pagination).includes(a));
59435943
if (!group) return;
59445944
pagination[group].page = pagination[group].page + 1;
59455945
updateResponses();
5946-
paginationSection.getElementById('current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
5947-
paginationSection.getElementById('next-page').disabled = (pagination[group].page + 1 >= Math.ceil(pagination[group].total / pagination[group].perPage)) ? true : false;
5946+
console.log(paginationSection)
5947+
paginationSection.parentElement.querySelector('#current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
5948+
paginationSection.parentElement.querySelector('#next-page-button').disabled = (pagination[group].page + 1 >= Math.ceil(pagination[group].total / pagination[group].perPage)) ? true : false;
5949+
paginationSection.parentElement.querySelector('#previous-page-button').disabled = false;
59485950
}
59495951
} catch (error) {
59505952
if (storage.get("developer")) {

src/checker/ta.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ try {
294294
const normalResponses = responses1.filter(r => !(r.status === 'Invalid Format' || r.status === 'Unknown, Recorded'));
295295
const awaitingPageResponses = awaitingSection ? awaitingResponses.slice(pagination.awaitingResponses.page * pagination.awaitingResponses.perPage, (pagination.awaitingResponses.page + 1) * pagination.awaitingResponses.perPage) : [];
296296
const responsesPageResponses = responsesSection ? normalResponses.slice(pagination.responses.page * pagination.responses.perPage, (pagination.responses.page + 1) * pagination.responses.perPage) : [];
297-
var responses2 = awaitingSection ? awaitingPageResponses : (responsesSection ? responsesPageResponses : []);
298-
responses2.forEach(r => {
297+
var pageResponses = [...awaitingPageResponses, ...responsesPageResponses];
298+
pageResponses.forEach(r => {
299299
var responseString = r.response;
300300
var isMatrix = null;
301301
if (responseString.includes('[[')) {
@@ -776,18 +776,20 @@ try {
776776
if (!group) return;
777777
pagination[group].page = pagination[group].page - 1;
778778
updateResponses();
779-
paginationSection.getElementById('current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
780-
paginationSection.getElementById('next-page').disabled = false;
781-
paginationSection.getElementById('previous-page').disabled = (pagination[group].page - 1 < 0) ? true : false;
779+
paginationSection.parentElement.querySelector('#current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
780+
paginationSection.parentElement.querySelector('#next-page-button').disabled = false;
781+
paginationSection.parentElement.querySelector('#previous-page-button').disabled = (pagination[group].page - 1 < 0) ? true : false;
782782
}
783783

784784
function nextPage(paginationSection) {
785785
const group = Array.from(paginationSection.parentElement.parentElement.classList).find(a => Object.keys(pagination).includes(a));
786786
if (!group) return;
787787
pagination[group].page = pagination[group].page + 1;
788788
updateResponses();
789-
paginationSection.getElementById('current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
790-
paginationSection.getElementById('next-page').disabled = (pagination[group].page + 1 >= Math.ceil(pagination[group].total / pagination[group].perPage)) ? true : false;
789+
console.log(paginationSection)
790+
paginationSection.parentElement.querySelector('#current-page').innerText = `Page ${pagination[group].page + 1} of ${Math.ceil(pagination[group].total / pagination[group].perPage)}`;
791+
paginationSection.parentElement.querySelector('#next-page-button').disabled = (pagination[group].page + 1 >= Math.ceil(pagination[group].total / pagination[group].perPage)) ? true : false;
792+
paginationSection.parentElement.querySelector('#previous-page-button').disabled = false;
791793
}
792794
} catch (error) {
793795
if (storage.get("developer")) {

0 commit comments

Comments
 (0)