From 0fea528dcd82274d742d1da6ba8ff70c72bb56e0 Mon Sep 17 00:00:00 2001 From: Faisal N Date: Fri, 4 Oct 2024 00:27:19 -0400 Subject: [PATCH 1/8] timestamps, convert matched reply to button --- admin/responses.html | 4 +++ src/checker/admin.js | 58 +++++++++++++++++++++++++++++++++++++++++++- src/design.css | 5 ++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/admin/responses.html b/admin/responses.html index ba2b3a7..b36b3b3 100644 --- a/admin/responses.html +++ b/admin/responses.html @@ -98,6 +98,7 @@

Awaiting Scoring

+
@@ -108,6 +109,7 @@

Awaiting Scoring

+
@@ -142,6 +144,7 @@

Marked Responses

+
@@ -152,6 +155,7 @@

Marked Responses

+
diff --git a/src/checker/admin.js b/src/checker/admin.js index 543b305..c56a3a7 100644 --- a/src/checker/admin.js +++ b/src/checker/admin.js @@ -776,10 +776,13 @@ function updateResponses() { }); r.response = responseString; } + const date = new Date(r.timestamp); + let hours = date.getHours(); + const minutes = date.getMinutes(); var buttonGrid = document.createElement('div'); buttonGrid.className = "button-grid inputs"; buttonGrid.id = `response-${r.id}`; - buttonGrid.innerHTML = `${(r.flagged == '1') ? `` : ``}${((r.status === 'Incorrect') && r.reason) ? `` : ''}`; + buttonGrid.innerHTML = `${(r.flagged == '1') ? `` : ``}${(r.status === 'Incorrect') ? `` : ''}`; document.querySelector('.responses .section').appendChild(buttonGrid); if ((r.status === 'Invalid Format') || (r.status === 'Unknown, Recorded')) document.querySelector('.awaitingResponses .section').appendChild(buttonGrid); var trend = trendingResponses.find(t => (t.segment === r.segment) && (t.question_id === r.question_id) && (t.response === r.response) && (t.status === r.status)); @@ -929,4 +932,57 @@ function markIncorrectConfirm(reason, e) { ui.view("api-fail"); if (document.querySelector('[data-polling]')) pollingOff(); }); +} + +function editReason() { + if (!active) return; + ui.modal({ + title: 'Edit Reason', + body: '

Edit your reason that this response is incorrect.

', + input: { + type: 'text', + placeholder: responses.find(r => r.id == this.parentElement.querySelector('#response-id-input').value)., + defaultValue: '', + }, + buttons: [ + { + text: 'Cancel', + class: 'cancel-button', + close: true, + }, + { + text: 'Continue', + class: 'submit-button', + onclick: (inputValue) => { + editReasonConfirm(inputValue, this); + }, + close: true, + }, + ], + }); +} + +function editReasonConfirm(reason, e) { + if (!active) return; + fetch(domain + '/edit_reason', { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + question_id: questions.find(q => q.number == e.parentElement.querySelector('#response-question-input').value).id, + answer: e.parentElement.querySelector('#response-response-input').value, + reason: reason + }), + }) + .then(q => q.json()) + .then(() => { + ui.toast("Successfully updated status.", 3000, "success", "bi bi-check-lg"); + init(); + }) + .catch((e) => { + console.error(e); + ui.view("api-fail"); + if (document.querySelector('[data-polling]')) pollingOff(); + }); } \ No newline at end of file diff --git a/src/design.css b/src/design.css index d67fc77..8daa9c0 100644 --- a/src/design.css +++ b/src/design.css @@ -409,6 +409,7 @@ div.ML__keyboard { } .small, + .smedium, .medium, square { max-width: unset !important; @@ -447,6 +448,10 @@ div.ML__keyboard { max-width: 75px; } +.smedium { + max-width: 125px; +} + .medium { max-width: 175px; } From 956e80bfe8611e89e0a8aedda727c5a8d748d124 Mon Sep 17 00:00:00 2001 From: Faisal N Date: Fri, 4 Oct 2024 00:28:17 -0400 Subject: [PATCH 2/8] edit reply --- src/checker/admin.js | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/checker/admin.js b/src/checker/admin.js index c56a3a7..d6ff64b 100644 --- a/src/checker/admin.js +++ b/src/checker/admin.js @@ -782,7 +782,7 @@ function updateResponses() { var buttonGrid = document.createElement('div'); buttonGrid.className = "button-grid inputs"; buttonGrid.id = `response-${r.id}`; - buttonGrid.innerHTML = `${(r.flagged == '1') ? `` : ``}${(r.status === 'Incorrect') ? `` : ''}`; + buttonGrid.innerHTML = `${(r.flagged == '1') ? `` : ``}${(r.status === 'Incorrect') ? `` : ''}`; document.querySelector('.responses .section').appendChild(buttonGrid); if ((r.status === 'Invalid Format') || (r.status === 'Unknown, Recorded')) document.querySelector('.awaitingResponses .section').appendChild(buttonGrid); var trend = trendingResponses.find(t => (t.segment === r.segment) && (t.question_id === r.question_id) && (t.response === r.response) && (t.status === r.status)); @@ -808,6 +808,7 @@ function updateResponses() { document.querySelectorAll('#mark-incorrect-button').forEach(a => a.addEventListener('click', markIncorrect)); document.querySelectorAll('[data-flag-response]').forEach(a => a.addEventListener('click', flagResponse)); document.querySelectorAll('[data-unflag-response]').forEach(a => a.addEventListener('click', unflagResponse)); + document.querySelectorAll('[data-edit-reason]').forEach(a => a.addEventListener('click', editReason)); active = true; } @@ -941,8 +942,8 @@ function editReason() { body: '

Edit your reason that this response is incorrect.

', input: { type: 'text', - placeholder: responses.find(r => r.id == this.parentElement.querySelector('#response-id-input').value)., - defaultValue: '', + placeholder: responses.find(r => r.id == this.parentElement.querySelector('#response-id-input').value).reason || '', + defaultValue: responses.find(r => r.id == this.parentElement.querySelector('#response-id-input').value).reason || '', }, buttons: [ { @@ -954,35 +955,10 @@ function editReason() { text: 'Continue', class: 'submit-button', onclick: (inputValue) => { - editReasonConfirm(inputValue, this); + markIncorrectConfirm(inputValue, this); }, close: true, }, ], }); -} - -function editReasonConfirm(reason, e) { - if (!active) return; - fetch(domain + '/edit_reason', { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - question_id: questions.find(q => q.number == e.parentElement.querySelector('#response-question-input').value).id, - answer: e.parentElement.querySelector('#response-response-input').value, - reason: reason - }), - }) - .then(q => q.json()) - .then(() => { - ui.toast("Successfully updated status.", 3000, "success", "bi bi-check-lg"); - init(); - }) - .catch((e) => { - console.error(e); - ui.view("api-fail"); - if (document.querySelector('[data-polling]')) pollingOff(); - }); } \ No newline at end of file From 913ecc62ea2818d7165ff160b29588c094f59fcf Mon Sep 17 00:00:00 2001 From: Faisal N Date: Fri, 4 Oct 2024 14:45:42 -0400 Subject: [PATCH 3/8] credits --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0a64039..ff5b37b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ Next generation AI-powered homework checking, cloud hosted ☁️🚀✅ Vite will start a development server at `localhost:5173` +### Credits + +- [khui0](https://github.com/khui0) - Base Virtual Clicker + ## Build `npm run build` From e3893f497b1bc5ee65eb80613758817f2a9acdda Mon Sep 17 00:00:00 2001 From: Faisal N Date: Fri, 4 Oct 2024 17:54:05 -0400 Subject: [PATCH 4/8] time between checks, bug fixes --- admin/responses.html | 42 ++++++++------- src/checker/admin.js | 118 ++++++++++++++++++++++++++++++------------- src/design.css | 15 +++++- 3 files changed, 121 insertions(+), 54 deletions(-) diff --git a/admin/responses.html b/admin/responses.html index b36b3b3..c90a2dc 100644 --- a/admin/responses.html +++ b/admin/responses.html @@ -94,9 +94,10 @@

Awaiting Scoring

- - - + + + + @@ -105,9 +106,10 @@

Awaiting Scoring

- - - + + + + @@ -115,19 +117,19 @@

Awaiting Scoring

-
+

Trends

- - + +
- - + + @@ -140,9 +142,10 @@

Marked Responses

- - - + + + + @@ -151,9 +154,10 @@

Marked Responses

- - - + + + + @@ -171,6 +175,10 @@

Marked Responses

+