diff --git a/.gitignore b/.gitignore index 5ab3728..7adc81d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.swp *.bak +packets packets/* img/* @@ -8,4 +9,4 @@ img/* node_modules -config.js \ No newline at end of file +config.js diff --git a/js/interact.js b/js/interact.js index 2168223..0cacc68 100644 --- a/js/interact.js +++ b/js/interact.js @@ -1,4 +1,3 @@ -import {exam_query_url} from "./config.js"; import * as helper from "./helpers.js"; /** * Submits answers diff --git a/js/main.js b/js/main.js index 5645fe3..a896f00 100644 --- a/js/main.js +++ b/js/main.js @@ -84,13 +84,17 @@ refreshDatabaseSettings(); * if exam_query_url is defined in config.js this will be used in preference */ function retrievePacketList() { - let url = "packets/"; + let url = "packets/packets.json"; //console.log(config.exam_query_url); + try { if (config.exam_query_url != undefined) { url = config.exam_query_url; } + } catch (e) { + // + } $.ajax({ dataType: "json", @@ -106,7 +110,7 @@ function retrievePacketList() { }) .done(function () {}) .fail(function () { - $.getJSON("packets/packets.json", function (data) { + $.getJSON("packets", function (data) { if (data.hasOwnProperty("exams")) { loadExamList(data); } else { @@ -159,6 +163,7 @@ async function loadExamList(data) { let exam_generated_map = {}; $("#packet-list").empty(); + //exam_list.sort((a, b) => (a.name > b.name) ? 1 : -1).forEach(function (exam) { exam_list.forEach(function (exam) { let name = exam["name"]; let url = exam["url"]; @@ -287,6 +292,17 @@ async function loadExamList(data) { }); }); + // Sort different lists + $('.packet-list.rapid div').sort(function(a,b) { + return a.dataset.eid > b.dataset.eid ? 1 : (a.dataset.eid < b.dataset.eid ? -1 : 0);; + }).appendTo('.packet-list.rapid'); + $('.packet-list.anatomy div').sort(function(a,b) { + return a.dataset.eid > b.dataset.eid ? 1 : (a.dataset.eid < b.dataset.eid ? -1 : 0);; + }).appendTo('.packet-list.anatomy'); + $('.packet-list.long div').sort(function(a,b) { + return a.dataset.eid > b.dataset.eid ? 1 : (a.dataset.eid < b.dataset.eid ? -1 : 0);; + }).appendTo('.packet-list.long'); + $("#options-panel").show(); } @@ -295,6 +311,7 @@ async function loadExamList(data) { * * @param {JSON} data - json containing available packets */ +// TODO: remove (data formats should be switched to the exam format) async function loadPacketList(data) { let sessions = await db.session.toArray().catch(function (error) { console.log("Error loading session", error); @@ -355,7 +372,7 @@ async function loadPacketList(data) { $(`
`) .text(packet) .click(function () { - loadPacketFromAjax("packets/" + packet); + loadPacketFromAjax("packets/" + packet, packet); }) .append( $( @@ -731,7 +748,7 @@ function setUpQuestions(load_previous) { if (exam_details.exam_mode) { $("#options-button, #review-overlay-button").hide(); } else { - $("#submit-button").hide(); + $(".submit-button").hide(); } questions = null; @@ -1558,6 +1575,7 @@ function reviewQuestions() { timer.stop(); } + const aid = exam_details.aid; const cid = exam_details.cid; const eid = exam_details.eid; $("#review-overlay").show(); @@ -1589,11 +1607,14 @@ function reviewQuestions() { let undercall_number = 0; let overcall_number = 0; let incorrectcall_number = 0; - exam_details.question_order.forEach(function (qid, n) { + exam_details.question_order.forEach(async function (qid, n) { + const q_object = { qid: qid, type: question_type }; + let question = await question_db.question_data.get(q_object) + question = question.data; if (question_type == "long") { $("#review-answer-table").append( $( - `