convert question id to use string

This commit is contained in:
Ross
2021-05-26 23:46:34 +01:00
parent 880c0524e2
commit 9322a7345a
+9 -8
View File
@@ -256,7 +256,7 @@ async function loadExamList(data) {
`<li class="cache-item" data-qid=${q}>Question (${saved_exam.exam_type}): ${q}`
);
// If a single question is out of date we invalidate the lot...
const q_object = { qid: q, type: saved_exam.exam_type };
const q_object = { qid: toString(q), type: saved_exam.exam_type };
question_db.question_data
.get(q_object)
.then((d) => {
@@ -279,7 +279,7 @@ async function loadExamList(data) {
//question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
question_db.question_data
.where(["qid", "type"])
.equals([q, saved_exam.exam_type])
.equals([toString(q), saved_exam.exam_type])
.delete();
}
d = null;
@@ -299,7 +299,7 @@ async function loadExamList(data) {
//question_db.saved_exams.where("eid").equals(saved_exam.eid).delete();
question_db.question_data
.where(["qid", "type"])
.equals([q, saved_exam.exam_type])
.equals([toString(q), saved_exam.exam_type])
.delete();
});
}
@@ -566,6 +566,7 @@ function setUpPacket(data, path) {
if (!use_local_question_cache) {
// Save the details to the question database
var clone_data = Object.assign({}, data, { questions: "cached" });
console.log(clone_data)
//clone_data["cached_questions"] = Object.keys(data["questions"]);
question_db.saved_exams.put(clone_data);
}
@@ -596,7 +597,7 @@ function setUpPacket(data, path) {
(async () => {
for (let n in data["question_requests"]) {
question_number++;
n = parseInt(n);
n = toString(n);
let obj = { qid: n, type: question_type };
let question_in_db = await question_db.question_data.get(obj);
@@ -765,7 +766,7 @@ function setUpQuestions(load_previous) {
// Store question data into dexie
let d = {
//eid: exam_details.eid,
qid: parseInt(e),
qid: toString(e),
type: questions[e].type,
data: questions[e],
//timestamp: questions[e]["generated"],
@@ -849,8 +850,8 @@ async function loadQuestion(n, section = 1, force_reload = false) {
const cid = exam_details.cid;
const eid = exam_details.eid;
// Make sure we have an integer
n = parseInt(n);
// Make sure we have an string
n = toString(n);
//console.log("loading question (n)", n);
if (n == loaded_question && force_reload == false) {
@@ -1663,7 +1664,7 @@ function reviewQuestions() {
let overcall_number = 0;
let incorrectcall_number = 0;
exam_details.question_order.forEach(async function (qid, n) {
const q_object = { qid: qid, type: question_type };
const q_object = { qid: toString(qid), type: question_type };
let question = await question_db.question_data.get(q_object);
question = question.data;
if (question_type == "long") {