From 07959cb0a82f438b3e9ba6f26bf9f014be03ef1f Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Dec 2021 17:43:40 +0000 Subject: [PATCH] numerous improvements --- css/base.css | 88 ++++-- css/main.css | 383 ++++++++++++++---------- index.html | 66 +++-- js/main.js | 822 ++++++++++++++++++++++++++++++--------------------- 4 files changed, 817 insertions(+), 542 deletions(-) diff --git a/css/base.css b/css/base.css index 2f72a42..f984c3f 100644 --- a/css/base.css +++ b/css/base.css @@ -1,18 +1,67 @@ -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, font, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td { +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +font, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +strong, +sub, +sup, +tt, +var, +dl, +dt, +dd, +ol, +ul, +li, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; - font-size: 100%; font-family: inherit; vertical-align: baseline; } @@ -27,7 +76,8 @@ body { background: white; } -ol, ul { +ol, +ul { list-style: none; } @@ -36,17 +86,21 @@ table { border-spacing: 0; } -caption, th, td { +caption, +th, +td { text-align: left; font-weight: normal; } -blockquote:before, blockquote:after, -q:before, q:after { +blockquote:before, +blockquote:after, +q:before, +q:after { content: ""; } -blockquote, q { - quotes: "" ""; -} - +blockquote, +q { + quotes: """"; +} \ No newline at end of file diff --git a/css/main.css b/css/main.css index 7504adb..3d76a45 100644 --- a/css/main.css +++ b/css/main.css @@ -3,7 +3,7 @@ @import url("https://fonts.googleapis.com/css?family=Noto+Sans:400,700"); /* Colourscheme from https://www.materialui.co/colors */ -* { +* { -webkit-font-smoothing: antialiased; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; @@ -17,7 +17,6 @@ appearance: none; font-family: "Noto Sans", sans-serif !important; font-weight: 400; - font-size: 1.6rem; text-rendering: optimizeLegibility; line-height: 1.5; } @@ -49,7 +48,12 @@ html { font-size: 62.5%; } -html, body, input:not([type=text]), button, select, option { +html, +body, +input:not([type=text]), +button, +select, +option { user-select: none; -moz-user-select: none; -webkit-user-select: none; @@ -57,11 +61,18 @@ html, body, input:not([type=text]), button, select, option { -o-user-select: none; } -html, body, input, button, select, option, textarea { - vertical-align:top; +html, +body, +input, +button, +select, +option, +textarea { + vertical-align: top; margin: 0; padding: 0; - color: black; /*#1d3850;*/ + color: black; + /*#1d3850;*/ /*font-family: 'Noto Sans', sans-serif;*/ overflow: hidden; } @@ -72,7 +83,11 @@ body { font-weight: 400; } -input, button, select, option, textarea { +input, +button, +select, +option, +textarea { background-color: white; font-size: 100%; padding: 0.4rem 0.8rem; @@ -174,8 +189,8 @@ td { } .question-list-flag { - float: right; - color: #311B92; + float: right; + color: #311B92; visibility: hidden; } @@ -247,7 +262,7 @@ td { } .no-touch .navigation:hover { - background-color: #1a237e; + background-color: #1a237e; border-color: #ddd; } @@ -275,7 +290,7 @@ td { overflow-y: auto; -webkit-overflow-scrolling: touch; } - + .question * { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); @@ -350,7 +365,7 @@ td { .canvas-panel { display: block; padding: 0; - margin: 0; + margin: 0; background-color: black; image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; @@ -529,7 +544,7 @@ img { width: 100vw; height: 100vh; overflow: auto; - background-color: rgba(0,0,0,0.4); + background-color: rgba(0, 0, 0, 0.4); text-align: center; } @@ -541,7 +556,7 @@ img { box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5); border-radius: 5px; padding: 0px; - + } .dialog-title { @@ -606,9 +621,9 @@ img { left: 0; right: 0; bottom: 0; - background-color: rgba(0,0,0,0.9); + background-color: rgba(0, 0, 0, 0.9); z-index: 2; - cursor: pointer; + cursor: pointer; color: lightgray; overflow: auto; } @@ -623,7 +638,7 @@ img { right: 0; bottom: 0; z-index: 2; - cursor: pointer; + cursor: pointer; color: lightgray; overflow: auto; } @@ -652,7 +667,8 @@ img { opacity: 1; } -.close:before, .close:after { +.close:before, +.close:after { position: absolute; left: 15px; content: ' '; @@ -796,7 +812,7 @@ select option:disabled { } .feedback { - padding-top: 0.8rem; + padding-top: 0.8rem; } #options-panel { @@ -816,72 +832,89 @@ select option:disabled { padding-top: 20px; } -.packet-button { - display:inline-block; - padding:0.35em 1.2em; - border:0.1em solid #FFFFFF; - margin:0 0.3em 0.3em 0; - border-radius:0.12em; + +.login-button { + display: inline-block; + padding: 0.35em 1.2em; + border: 0.1em solid purple; + margin: 0 0.3em 0.3em 0; + border-radius: 0.12em; box-sizing: border-box; - text-decoration:none; - font-family:'Roboto',sans-serif; - font-weight:300; - color:#FFFFFF; - text-align:center; + text-decoration: none; + font-family: 'Roboto', sans-serif; + font-weight: 300; + color: rgb(201, 0, 201); + text-align: center; + transition: all 0.2s; + background-color: black; +} + +.packet-button { + display: inline-block; + padding: 0.35em 1.2em; + border: 0.1em solid #FFFFFF; + margin: 0 0.3em 0.3em 0; + border-radius: 0.12em; + box-sizing: border-box; + text-decoration: none; + font-family: 'Roboto', sans-serif; + font-weight: 300; + color: #FFFFFF; + text-align: center; transition: all 0.2s; } -.packet-button.cached:after{ - content: "cached"; - width: 12px; - height: 12px; - color: gray; - border-radius: 50%; - position:relative; - transform: translate(15px, 5.5px) rotate(270deg); - display: inline-block; - right: 0; - font-size: 8px; +.packet-button.cached:after { + content: "cached"; + width: 12px; + height: 12px; + color: gray; + border-radius: 50%; + position: relative; + transform: translate(15px, 5.5px) rotate(270deg); + display: inline-block; + right: 0; + font-size: 8px; } -.packet-button.out-of-date{ - color: darkslategray +.packet-button.out-of-date { + color: darkslategray } .save-button { - display:inline-block; + display: inline-block; margin-left: 10px; - color:#FFFFFF; - border-bottom:2px solid transparent; + color: #FFFFFF; + border-bottom: 2px solid transparent; } -.save-button a { - color: inherit; -} +.save-button a { + color: inherit; +} .save-button:hover { - color: #311B92; - border-bottom:2px solid #311B92; + color: #311B92; + border-bottom: 2px solid #311B92; } -.packet-button:hover{ - color:lightblue; - border-color:blue; +.packet-button:hover { + color: lightblue; + border-color: blue; } .progress-block { - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - font-size: smaller; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: smaller; } #timer { - /* left: 50%; */ - margin: auto; - margin-right: 1em; - opacity: 25%; + /* left: 50%; */ + margin: auto; + margin-right: 1em; + opacity: 25%; } #timer:hover:before { @@ -889,69 +922,97 @@ select option:disabled { } .sk-cube-grid { - width: 60px; - height: 60px; + width: 60px; + height: 60px; } .sk-cube-grid .sk-cube { - width: 33%; - height: 33%; - background-color: #4527A0; - float: left; - -webkit-animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; - animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; + width: 33%; + height: 33%; + background-color: #4527A0; + float: left; + -webkit-animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; + animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; } + .sk-cube-grid .sk-cube1 { - -webkit-animation-delay: 0.2s; - animation-delay: 0.2s; } + -webkit-animation-delay: 0.2s; + animation-delay: 0.2s; +} + .sk-cube-grid .sk-cube2 { - -webkit-animation-delay: 0.3s; - animation-delay: 0.3s; } + -webkit-animation-delay: 0.3s; + animation-delay: 0.3s; +} + .sk-cube-grid .sk-cube3 { - -webkit-animation-delay: 0.4s; - animation-delay: 0.4s; } + -webkit-animation-delay: 0.4s; + animation-delay: 0.4s; +} + .sk-cube-grid .sk-cube4 { - -webkit-animation-delay: 0.1s; - animation-delay: 0.1s; } + -webkit-animation-delay: 0.1s; + animation-delay: 0.1s; +} + .sk-cube-grid .sk-cube5 { - -webkit-animation-delay: 0.2s; - animation-delay: 0.2s; } + -webkit-animation-delay: 0.2s; + animation-delay: 0.2s; +} + .sk-cube-grid .sk-cube6 { - -webkit-animation-delay: 0.3s; - animation-delay: 0.3s; } + -webkit-animation-delay: 0.3s; + animation-delay: 0.3s; +} + .sk-cube-grid .sk-cube7 { - -webkit-animation-delay: 0s; - animation-delay: 0s; } + -webkit-animation-delay: 0s; + animation-delay: 0s; +} + .sk-cube-grid .sk-cube8 { - -webkit-animation-delay: 0.1s; - animation-delay: 0.1s; } + -webkit-animation-delay: 0.1s; + animation-delay: 0.1s; +} + .sk-cube-grid .sk-cube9 { - -webkit-animation-delay: 0.2s; - animation-delay: 0.2s; } + -webkit-animation-delay: 0.2s; + animation-delay: 0.2s; +} @-webkit-keyframes sk-cubeGridScaleDelay { - 0%, 70%, 100% { - -webkit-transform: scale3D(1, 1, 1); - transform: scale3D(1, 1, 1); - } 35% { - -webkit-transform: scale3D(0, 0, 1); - transform: scale3D(0, 0, 1); - } + + 0%, + 70%, + 100% { + -webkit-transform: scale3D(1, 1, 1); + transform: scale3D(1, 1, 1); + } + + 35% { + -webkit-transform: scale3D(0, 0, 1); + transform: scale3D(0, 0, 1); + } } @keyframes sk-cubeGridScaleDelay { - 0%, 70%, 100% { - -webkit-transform: scale3D(1, 1, 1); - transform: scale3D(1, 1, 1); - } 35% { - -webkit-transform: scale3D(0, 0, 1); - transform: scale3D(0, 0, 1); - } + + 0%, + 70%, + 100% { + -webkit-transform: scale3D(1, 1, 1); + transform: scale3D(1, 1, 1); + } + + 35% { + -webkit-transform: scale3D(0, 0, 1); + transform: scale3D(0, 0, 1); + } } .displayblock { -display: block + display: block } .review-list-header { @@ -971,30 +1032,30 @@ display: block padding-bottom: 0px; opacity: 50%; text-align: center; - } +} #resume-exam-button { - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); } #pause-text { - position: fixed; - /* left: 50%; */ - width: 100%; - text-align: center; - top: 20%; - font-size: xxx-large; - transform: translate(0%, 20%); + position: fixed; + /* left: 50%; */ + width: 100%; + text-align: center; + top: 20%; + font-size: xxx-large; + transform: translate(0%, 20%); } #pause-time-remaining { - width: auto; - font-size: large; - /* position: fixed; */ - text-align: center; + width: auto; + font-size: large; + /* position: fixed; */ + text-align: center; } .packet-database-options { @@ -1048,36 +1109,40 @@ display: block .lds-ripple { - display: inline-block; - position: relative; - width: 80px; - height: 80px; + display: inline-block; + position: relative; + width: 80px; + height: 80px; } + .lds-ripple div { - position: absolute; - border: 4px solid #4527A0; - opacity: 1; - border-radius: 50%; - animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite; -} -.lds-ripple div:nth-child(2) { - animation-delay: -0.5s; -} -@keyframes lds-ripple { - 0% { - top: 36px; - left: 36px; - width: 0; - height: 0; + position: absolute; + border: 4px solid #4527A0; opacity: 1; - } - 100% { - top: 0px; - left: 0px; - width: 72px; - height: 72px; - opacity: 0; - } + border-radius: 50%; + animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite; +} + +.lds-ripple div:nth-child(2) { + animation-delay: -0.5s; +} + +@keyframes lds-ripple { + 0% { + top: 36px; + left: 36px; + width: 0; + height: 0; + opacity: 1; + } + + 100% { + top: 0px; + left: 0px; + width: 72px; + height: 72px; + opacity: 0; + } } #submit-error-overlay { @@ -1095,25 +1160,25 @@ display: block .cache-out-of-date { color: red; - } +} .user-text { color: darkslateblue; } .inactive::before { - content: "inactive"; + content: "inactive"; transform: rotate(45deg); - color: red; - font-size: 1rem; - font-weight: 900; - border: 0.25rem solid red; - display: inline-block; - /* padding: 0.25rem 1rem; */ - text-transform: uppercase; - border-radius: 1rem; - font-family: 'Courier'; - /* mix-blend-mode: multiply; */ + color: red; + font-size: 1rem; + font-weight: 900; + border: 0.25rem solid red; + display: inline-block; + /* padding: 0.25rem 1rem; */ + text-transform: uppercase; + border-radius: 1rem; + font-family: 'Courier'; + /* mix-blend-mode: multiply; */ opacity: 30%; margin-left: -2em; position: absolute; diff --git a/index.html b/index.html index 1b8143c..9c720d3 100644 --- a/index.html +++ b/index.html @@ -63,10 +63,20 @@

RTS

+
-

Available Packets (click to load):

+

Click buttons below to load an exam / packet

+ + +

Available Packets:

@@ -75,28 +85,28 @@
-
- -
    -
-
+
+ +
    +
+
- Options -
- - -
-
-
+ Options +
+ + +
+
+ -
-

Load local question set

- - -
- -
+
+

Load local question set

+ + +
+ +
@@ -138,7 +148,7 @@
@@ -153,12 +163,13 @@ - ' ); ap.append( '' + display_n + + '.2Reason

' ); // Handle changing display of optional answer fields and saving of data - $("#rapid-option").change(function (evt) { + $("#rapid-option").change(function(evt) { if (evt.target.value == "Abnormal") { $("#rapid-text").css("display", "block"); } else { @@ -1083,6 +1147,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { eid: eid, qid: qid, qidn: "1", + passcode: passcode, ans: evt.target.value, }; @@ -1092,14 +1157,14 @@ async function loadQuestion(n, section = 1, force_reload = false) { }); // Save long answers on textchange - $(".long-answer").change(function (evt) { + $(".long-answer").change(function(evt) { // ignore blank text and delete any stored value if (evt.target.value.length < 1) { db.answers.delete([aid, cid, eid, qid, "2"]); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-2" + exam_details.question_order.indexOf(qid) + + "-2" ).removeClass("question-saved-localdb"); return; } @@ -1110,6 +1175,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { eid: eid, qid: qid, qidn: "2", + passcode: passcode, ans: evt.target.value, }; // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); @@ -1117,8 +1183,8 @@ async function loadQuestion(n, section = 1, force_reload = false) { $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-2" + exam_details.question_order.indexOf(qid) + + "-2" ).addClass("question-saved-localdb"); saveSession(); @@ -1129,8 +1195,15 @@ async function loadQuestion(n, section = 1, force_reload = false) { // they have been loaded (should probably use then or after) db.answers - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" }) - .then(function (answer) { + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + passcode: passcode, + qidn: "1" + }) + .then(function(answer) { if (answer != undefined) { $("#rapid-option option:contains(" + answer.ans + ")").prop( "selected", @@ -1143,22 +1216,29 @@ async function loadQuestion(n, section = 1, force_reload = false) { $("#rapid-option-not-answered").remove(); } }) - .catch(function (error) { + .catch(function(error) { console.log("DB", cid, eid, qid); console.log("error-", error); }) .then( db.answers - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "2" }) - .then(function (answer) { - if (answer != undefined) { - $(".long-answer").text(answer.ans); - } - markAnswer(qid, question_data, n); - }) - .catch(function (error) { - console.log("error-", error); - }) + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: "2", + passcode: passcode, + }) + .then(function(answer) { + if (answer != undefined) { + $(".long-answer").text(answer.ans); + } + markAnswer(qid, question_data, n); + }) + .catch(function(error) { + console.log("error-", error); + }) ); addFlagEvents(); @@ -1170,22 +1250,22 @@ async function loadQuestion(n, section = 1, force_reload = false) { case "anatomy": { ap.append( '

' + - display_n + - '.1' + - question_data.question + - '

' + display_n + + '.1' + + question_data.question + + '

' ); - $(".long-answer").change(function (evt) { + $(".long-answer").change(function(evt) { // ignore blank text and delete any stored value if (evt.target.value.length < 1) { db.answers.delete([aid, cid, eid, qid, "1"]); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-1" + exam_details.question_order.indexOf(qid) + + "-1" ).removeClass("question-saved-localdb"); return; } @@ -1196,29 +1276,35 @@ async function loadQuestion(n, section = 1, force_reload = false) { eid: eid, qid: qid, qidn: "1", + passcode: passcode, ans: evt.target.value, }; - // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); db.answers.put(answer); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-1" + exam_details.question_order.indexOf(qid) + + "-1" ).addClass("question-saved-localdb"); saveSession(); updateQuestionListPanel(answer); }); db.answers - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" }) - .then(function (answer) { + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: "1" + }) + .then(function(answer) { if (answer != undefined) { $(".long-answer").text(answer.ans); } markAnswer(qid, question_data, n); }) - .catch(function (error) { + .catch(function(error) { console.log(error); }); @@ -1231,42 +1317,42 @@ async function loadQuestion(n, section = 1, force_reload = false) { case "long": { ap.append( '

' + - display_n + - '.1Observations

' + display_n + + '.1Observations

' ); ap.append( '

' + - display_n + - '.2Interpretation

' + display_n + + '.2Interpretation

' ); ap.append( '

' + - display_n + - '.3Principal Diagnosis

' + display_n + + '.3Principal Diagnosis

' ); ap.append( '

' + - display_n + - '.4Differential Diagnosis

' + display_n + + '.4Differential Diagnosis

' ); ap.append( '

' + - display_n + - '.5Management (if appropriate)

' + display_n + + '.5Management (if appropriate)

' ); // Save long answers on textchange - $(".long-answer").change(function (evt) { + $(".long-answer").change(function(evt) { const qidn = evt.target.dataset.qidn.toString(); // ignore blank text and delete any stored value @@ -1274,19 +1360,19 @@ async function loadQuestion(n, section = 1, force_reload = false) { db.answers.delete([aid, cid, eid, qid, qidn]); $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-" + - qidn + exam_details.question_order.indexOf(qid) + + "-" + + qidn ).removeClass("question-saved-localdb"); return; } - // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); const answer = { aid: aid, cid: cid, eid: eid, qid: qid, qidn: qidn, + passcode: passcode, ans: evt.target.value, }; @@ -1294,9 +1380,9 @@ async function loadQuestion(n, section = 1, force_reload = false) { $( "#question-list-item-" + - exam_details.question_order.indexOf(qid) + - "-" + - qidn + exam_details.question_order.indexOf(qid) + + "-" + + qidn ).addClass("question-saved-localdb"); saveSession(); updateQuestionListPanel(answer); @@ -1316,7 +1402,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { }; db.answers .get(obj) - .then(function (answer) { + .then(function(answer) { if (answer != undefined) { $(".long-answer") .eq(parseInt(answer.qidn) - 1) @@ -1327,7 +1413,7 @@ async function loadQuestion(n, section = 1, force_reload = false) { markAnswer(qid, question_data, n); } }) - .catch(function (error) { + .catch(function(error) { console.log(error); }); } @@ -1379,23 +1465,23 @@ function setFocus(section) { function updateQuestionListPanel(answer) { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-" + - answer.qidn + exam_details.question_order.indexOf(answer.qid) + + "-" + + answer.qidn ).addClass("question-saved-localdb"); if (question_type == "rapid" && answer.qidn == "1") { if (answer.ans == "Abnormal") { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-2" + exam_details.question_order.indexOf(answer.qid) + + "-2" ).css("display", "block"); } else { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-2" + exam_details.question_order.indexOf(answer.qid) + + "-2" ).css("display", "none"); } } @@ -1404,20 +1490,20 @@ function updateQuestionListPanel(answer) { function deleteQuestionListPanelFlags(answer) { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-" + - answer.qidn + - " span" + exam_details.question_order.indexOf(answer.qid) + + "-" + + answer.qidn + + " span" ).css("visibility", "hidden"); } function updateQuestionListPanelFlags(answer) { $( "#question-list-item-" + - exam_details.question_order.indexOf(answer.qid) + - "-" + - answer.qidn + - " span" + exam_details.question_order.indexOf(answer.qid) + + "-" + + answer.qidn + + " span" ).css("visibility", "visible"); } /** @@ -1431,34 +1517,42 @@ function rebuildQuestionListPanel() { const eid = exam_details.eid; db.answers - .where({ aid: aid, cid: cid, eid: eid }) + .where({ + aid: aid, + cid: cid, + eid: eid + }) .toArray() - .then(function (answers) { + .then(function(answers) { // Reset all classes (of question-list-item s) $(".question-list-panel div") .slice(1) .attr("class", "question-list-item"); // Loop through each saved answer - answers.forEach(function (answer, n) { + answers.forEach(function(answer, n) { updateQuestionListPanel(answer); }); // $(".long-answer").text(answer.ans); }) - .catch(function (error) { + .catch(function(error) { console.log("error - ", error); }); db.flags - .where({ aid: aid, cid: cid, eid: eid }) + .where({ + aid: aid, + cid: cid, + eid: eid + }) .toArray() - .then(function (answers) { - answers.forEach(function (answer, n) { + .then(function(answers) { + answers.forEach(function(answer, n) { updateQuestionListPanelFlags(answer); }); // $(".long-answer").text(answer.ans); }) - .catch(function (error) { + .catch(function(error) { console.log("error - ", error); }); @@ -1501,18 +1595,18 @@ function createQuestionListPanel() { const qn = n - 1; const el = $( '
' + - n + - "." + - qidn + - '
' + qn + + "-" + + qidn + + '" data-qid=' + + qn + + ' data-qidn="' + + qidn + + '" class="question-list-item">' + + n + + "." + + qidn + + '' ); $(".question-list-panel").append(el); // return the new element so it can be hidden if necessary @@ -1539,31 +1633,31 @@ function createQuestionListPanel() { } } - $(".question-list-item").click(function (evt) { + $(".question-list-item").click(function(evt) { loadQuestion($(this).attr("data-qid"), $(this).attr("data-qidn")); }); rebuildQuestionListPanel(); } -$("#btn-local-file-load").click(function (evt) { +$("#btn-local-file-load").click(function(evt) { loadLocalQuestionSet(); }); -$(".submit-button").click(function (evt) { +$(".submit-button").click(function(evt) { interact.submitAnswers(exam_details, db, config); }); -$("#review-button").click(function (evt) { +$("#review-button").click(function(evt) { $(".question-list-panel").toggle(); }); -$("#options-button").click(function (evt) { +$("#options-button").click(function(evt) { loadPacketList(null); $("#options-panel").toggle(); }); -$("#review-overlay-button").click(function (evt) { +$("#review-overlay-button").click(function(evt) { if (review_mode == true) { reviewQuestions(); } else { @@ -1571,7 +1665,7 @@ $("#review-overlay-button").click(function (evt) { } }); -$("#fullscreen-overlay-button").click(function (evt) { +$("#fullscreen-overlay-button").click(function(evt) { if (document.fullscreen == false) { document.documentElement.requestFullscreen(); } else { @@ -1579,25 +1673,25 @@ $("#fullscreen-overlay-button").click(function (evt) { } }); -$("#finish-exam, #time-up-review-button").click(function (evt) { +$("#finish-exam, #time-up-review-button").click(function(evt) { review_mode = true; reviewQuestions(); $.modal.close(); }); -$("#time-up-continue-button").click(function (evt) { +$("#time-up-continue-button").click(function(evt) { $.modal.close(); }); -$("#finish-cancel").click(function (evt) { +$("#finish-cancel").click(function(evt) { $.modal.close(); }); -$("#overlay-close").click(function (evt) { +$("#overlay-close").click(function(evt) { $("#options-panel").hide(); }); -$("#review-overlay-close").click(function (evt) { +$("#review-overlay-close").click(function(evt) { $("#review-overlay").hide(); }); @@ -1664,11 +1758,15 @@ function reviewQuestions() { loadQuestion(0, 0, true); db.answers - .where({ aid: aid, cid: cid, eid: eid }) + .where({ + aid: aid, + cid: cid, + eid: eid + }) .toArray() - .then(function (answers) { + .then(function(answers) { let current_answers = {}; - answers.forEach(function (arr, n) { + answers.forEach(function(arr, n) { let answer = arr["ans"]; if (answer == undefined) { answer = "Not answered"; @@ -1684,8 +1782,11 @@ function reviewQuestions() { let undercall_number = 0; let overcall_number = 0; let incorrectcall_number = 0; - exam_details.question_order.forEach(async function (qid, n) { - const q_object = { qid: String(qid), type: question_type }; + exam_details.question_order.forEach(async function(qid, n) { + const q_object = { + qid: String(qid), + type: question_type + }; let question = await question_db.question_data.get(q_object); question = question.data; if (question_type == "long") { @@ -1753,12 +1854,12 @@ function reviewQuestions() { // TOOD fix $("#review-answer-table tr") - .sort(function (a, b) { - return a.dataset.qid > b.dataset.qid - ? 1 - : a.dataset.qid < b.dataset.qid - ? -1 - : 0; + .sort(function(a, b) { + return a.dataset.qid > b.dataset.qid ? + 1 : + a.dataset.qid < b.dataset.qid ? + -1 : + 0; }) .appendTo("#review-answer-table"); return; @@ -1766,24 +1867,27 @@ function reviewQuestions() { $("#review-answer-list").append( "
  • Question " + - (n + 1) + - ": Not answered
  • " + qid + + "' data-qid=" + + n.toString().padStart(2, "0") + + "'>Question " + + (n + 1) + + ": Not answered" ); - $("#review-answer-list a").click(function (evt) { + $("#review-answer-list a").click(function(evt) { loadQuestion(this.dataset.qid); $("#review-overlay").hide(); }); db.user_answers - .where({ type: question_type, qid: qid }) + .where({ + type: question_type, + qid: qid + }) .toArray() - .then(function (answers) { + .then(function(answers) { // Merge the question answers with the user saved answers let question_answers = question["answers"]; if (answers != undefined) { @@ -1831,20 +1935,20 @@ function reviewQuestions() { if (normal) { el.html( "Answer: " + - user_answer + - " (Normal)" + c + + "'>Answer: " + + user_answer + + " (Normal)" ); } else { el.html( "Answer: " + - user_answer + - " (Abnormal: " + - question_answers.join(", ") + - ")" + c + + "'>Answer: " + + user_answer + + " (Abnormal: " + + question_answers.join(", ") + + ")" ); } } @@ -1896,8 +2000,7 @@ function reviewQuestions() { ); questions_correct[qid] = false; - if (section_1_answer == "Not Answered") { - } else if (section_1_answer == "Normal") { + if (section_1_answer == "Not Answered") {} else if (section_1_answer == "Normal") { undercall_number++; } else { // Incorrect calls could be correct if @@ -1941,9 +2044,9 @@ function reviewQuestions() { $("#review-score").text( "Score: " + - correct_count + - " out of " + - exam_details.question_order.length + correct_count + + " out of " + + exam_details.question_order.length ); if (question_type == "rapid") { @@ -1958,7 +2061,7 @@ function reviewQuestions() { $("#exam-stats").show(); } }) - .catch(function (error) { + .catch(function(error) { console.log("error-", error); }) .finally(() => { @@ -1967,18 +2070,18 @@ function reviewQuestions() { rebuildQuestionListPanel(); $("#review-answer-list li") - .sort(function (a, b) { - return a.dataset.qid > b.dataset.qid - ? 1 - : a.dataset.qid < b.dataset.qid - ? -1 - : 0; + .sort(function(a, b) { + return a.dataset.qid > b.dataset.qid ? + 1 : + a.dataset.qid < b.dataset.qid ? + -1 : + 0; }) .appendTo("#review-answer-list"); }); }); }) - .catch(function (error) { + .catch(function(error) { console.log("error - ", error); }); } @@ -2044,13 +2147,16 @@ function markAnswer(qid, current_question, n) { // Load user saved answers db.user_answers - .where({ type: type, qid: qid }) + .where({ + type: type, + qid: qid + }) .toArray() - .then(function (saved_user_answers) { + .then(function(saved_user_answers) { // check if given answer matches a user saved answer if (saved_user_answers != undefined) { //console.log(saved_user_answers); - saved_user_answers.forEach(function (saved_answer_object, n) { + saved_user_answers.forEach(function(saved_answer_object, n) { let saved_answer = saved_answer_object.ans; //console.log("ua", user_answer, saved_answer); ul.append("
  • " + saved_answer + "
  • "); @@ -2078,7 +2184,7 @@ function markAnswer(qid, current_question, n) { } // check if given answer matches an answer from the question - current_question.answers.forEach(function (answer, n) { + current_question.answers.forEach(function(answer, n) { ul.append("
  • " + answer + "
  • "); if (compareString(answer, user_answer)) { textarea.removeClass("incorrect").addClass("correct"); @@ -2099,7 +2205,7 @@ function markAnswer(qid, current_question, n) { if (allow_self_marking) { $(".answer-panel").append( $("").click( - function () { + function() { markCorrect(qid, user_answer, type); loadQuestion(n, 0, true); } @@ -2109,7 +2215,7 @@ function markAnswer(qid, current_question, n) { } } }) - .catch(function (error) { + .catch(function(error) { console.log("error-", error); }); addFeedback(current_question, qid); @@ -2126,8 +2232,8 @@ function addFeedback(current_question, qid) { $(".answer-panel").append( $( "

    Feedback

    " + - current_question.feedback + - "
    " + current_question.feedback + + "" ) ); } @@ -2192,8 +2298,8 @@ function compareString(a, b) { function answerInArray(arr, ans) { return ( arr - .map((v) => v.toLowerCase().replace(/\s/g, "")) - .includes(ans.toLowerCase().replace(/\s/g, "")) == true + .map((v) => v.toLowerCase().replace(/\s/g, "")) + .includes(ans.toLowerCase().replace(/\s/g, "")) == true ); } @@ -2203,7 +2309,7 @@ function addFlagEvents() { const eid = exam_details.eid; // Bind flag change events - $("button.flag").click(function (event) { + $("button.flag").click(function(event) { const el = $(this); const nqid = el.attr("data-qid"); const qid = exam_details.question_order[nqid]; @@ -2211,7 +2317,13 @@ function addFlagEvents() { el.toggleClass("flag flag-selected"); - const flag_db_data = { aid: aid, cid: cid, eid: eid, qid: qid, qidn: qidn }; + const flag_db_data = { + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: qidn + }; if (el.hasClass("flag")) { $("#question-list-item-" + nqid + "-" + qidn + " span").css( @@ -2237,15 +2349,21 @@ function loadFlagsFromDb(qid, n) { const cid = exam_details.cid; const eid = exam_details.eid; db.flags - .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: n }) - .then(function (answer) { + .get({ + aid: aid, + cid: cid, + eid: eid, + qid: qid, + qidn: n + }) + .then(function(answer) { if (answer != undefined) { $("button.flag, button.flag-selected") .eq(parseInt(answer.qidn) - 1) .toggleClass("flag flag-selected"); } }) - .catch(function (error) { + .catch(function(error) { console.log(error); }); } @@ -2254,12 +2372,32 @@ function showLoginDialog() { $("#login-dialog").modal(); } -$("#start-exam-button").click(function (evt) { - exam_details.cid = parseInt($("#candidate-number").val()); +$("#btn-candidate-login").click(function(evt) { + $("#login-dialog").modal({ + escapeClose: false, + clickClose: false, + showClose: false + }); + $("#options-panel").toggle(); + $(".exam-wrapper").toggle(); +}); + + +$("#login-button").click(function(evt) { + global_cid = parseInt($("#candidate-number").val()); + global_passcode = $("#passcode").val(); + + user_db.user.clear().then(() => { + user_db.user.add({ + cid: global_cid, + passcode: global_passcode + }) + location.reload(); + }); $.modal.close(); }); -$(".start-packet-button").click(function (evt) { +$(".start-packet-button").click(function(evt) { if (exam_details.exam_mode) { if (!Number.isInteger(parseInt($("#candidate-number2").val()))) { alert("Please enter a valid candidate number."); @@ -2274,11 +2412,16 @@ $(".start-packet-button").click(function (evt) { timer = new easytimer.Timer(); //exam_time = 2; - timer.start({ countdown: true, startValues: { seconds: exam_time } }); - timer.addEventListener("secondsUpdated", function (e) { + timer.start({ + countdown: true, + startValues: { + seconds: exam_time + } + }); + timer.addEventListener("secondsUpdated", function(e) { $("#timer").html("Time left: " + timer.getTimeValues().toString()); }); - timer.addEventListener("targetAchieved", function (e) { + timer.addEventListener("targetAchieved", function(e) { if (exam_details.exam_mode == true) { $( "#dialog-submit-button, #time-up-review-button, #time-up-continue-button" @@ -2336,7 +2479,7 @@ $(".start-packet-button").click(function (evt) { $.modal.close(); }); -$("#btn-delete-answer-databases").click(function (evt) { +$("#btn-delete-answer-databases").click(function(evt) { var r = confirm( "This will delete ALL saved answers (including saved correct answers)!" ); @@ -2357,10 +2500,9 @@ $("#btn-delete-answer-databases").click(function (evt) { .finally(() => { // Do what should be done next... }); - } else { - } + } else {} }); -$("#btn-delete-cached-questions").click(function (evt) { +$("#btn-delete-cached-questions").click(function(evt) { var r = confirm("Delete cached questions?"); if (r == true) { question_db @@ -2380,11 +2522,10 @@ $("#btn-delete-cached-questions").click(function (evt) { .finally(() => { // Do what should be done next... }); - } else { - } + } else {} }); -$("#btn-delete-current").click(function (evt) { +$("#btn-delete-current").click(function(evt) { if (exam_details.question_order.length < 1) { $.notify("No packet is currently loaded", "warn"); return; @@ -2394,7 +2535,7 @@ $("#btn-delete-current").click(function (evt) { .where("qid") .anyOf(exam_details.question_order) .delete() - .then(function (deleteCount) { + .then(function(deleteCount) { $.notify("Packet flags deleted", "success"); }) .catch((err) => { @@ -2406,7 +2547,7 @@ $("#btn-delete-current").click(function (evt) { .where("qid") .anyOf(exam_details.question_order) .delete() - .then(function (deleteCount) { + .then(function(deleteCount) { $.notify("Packet successfully reset", "success"); loadQuestion(0, 0, true); // $.notify("The page will now reload", "warn"); @@ -2422,7 +2563,7 @@ $("#btn-delete-current").click(function (evt) { }); }); -$("#btn-delete-current-saved-answers").click(function (evt) { +$("#btn-delete-current-saved-answers").click(function(evt) { if (exam_details.question_order.length < 1) { $.notify("No packet is currently loaded", "warn"); return; @@ -2433,7 +2574,7 @@ $("#btn-delete-current-saved-answers").click(function (evt) { .where("qid") .anyOf(exam_details.question_order) .delete() - .then(function (deleteCount) { + .then(function(deleteCount) { $.notify("Packet answers deleted", "success"); }) .catch((err) => { @@ -2442,11 +2583,11 @@ $("#btn-delete-current-saved-answers").click(function (evt) { }); }); -$(document).ajaxStart(function () { +$(document).ajaxStart(function() { $("#loading").show(); }); -$(document).ajaxStop(function () { +$(document).ajaxStop(function() { $("#loading").hide(); }); @@ -2472,6 +2613,7 @@ function saveSession(start_review) { eid: exam_details.eid, aid: exam_details.aid, cid: exam_details.cid, + passcode: exam_details.passcode, status: status, date: date_started, score: score, @@ -2511,4 +2653,4 @@ function compareDates(d1, d2) { console.log("compare striped", Date.parse(d1.split("+")[0]), Date.parse(d2.split("+")[0])); console.log("compare striped", Date.parse(d1.split("+")[0]), Date.parse(d2.split("+")[0])); return Date.parse(d1.split("+")[0]) != Date.parse(d2.split("+")[0]); -} +} \ No newline at end of file