/* global Dexie, cornerstone, cornerstoneTools, cornerstoneBase64ImageLoader, cornerstoneWebImageLoader, cornerstoneWADOImageLoader */ import * as helper from "./helpers.js"; import * as viewer from "./viewer.js"; // cid = null; window.cid = 1234; window.eid = 5678; window.exam_mode = false; window.packet_list = []; window.questions = null; window.question_order = []; window.number_of_questions = null; window.question_type = null; window.loaded_question = null; window.review = false; window.exam_time = 60; window.allow_self_marking = true; //window.dfile = null; retrievePacketList(); /** * Retrieves a list of available packets via JSON ajax requests * Will initially try /packets/ (for example if index.php generates the list) * and then fallback to packets.json */ function retrievePacketList() { $.getJSON("packets/", function (data) { loadPacketList(data); }) .done(function () {}) .fail(function () { $.getJSON("packets/packets.json", function (data) { loadPacketList(data); }).fail(function () { console.log("No packet list available"); showLoginDialog(); }); }) .always(function () {}); // setUpPacket(questions); } /** * Generate a list of the packets that are available to be loaded * * @param {JSON} data - json containing available packets */ function loadPacketList(data) { window.packet_list = data.packets; window.packet_list.forEach(function (packet) { $("#packet-list").append( $("
") .text(packet) .click(function () { loadPacketFromAjax("packets/" + packet); }) .append( $( `` ).click(function () { console.log("packets/" + packet); event.stopPropagation(); }) ) ); }); $("#options-panel").show(); } /** * Loads the requisite packet into the quiz system * @param {string} path - relative path to the packet json file */ function loadPacketFromAjax(path) { console.log("loading packet from " + path); // $.getJSON(path, function (data) { // setUpPacket(data); // $("#options-panel").hide(); // }) $("#progress").html(`Requesting packet: ${path}`); $.ajax({ dataType: "json", url: path, progress: function (e) { if (e.lengthComputable) { var completedPercentage = Math.round((e.loaded * 100) / e.total); $("#progress").html( `${completedPercentage}%' + display_n + '.1Case normal/abnormal
' + display_n + '.1' + current_question.question + '
' + display_n + '.1Observations
' + display_n + '.2Interpretation
' + display_n + '.3Principal Diagnosis
' + display_n + '.4Differential Diagnosis
' + display_n + '.5Management (if appropriate)