diff --git a/.vscode/settings.json b/.vscode/settings.json
index 3cdf6f8..0ec6bc1 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -4,5 +4,5 @@
"javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.enable": false,
- "liveServer.settings.port": 5501
+ "liveServer.settings.port": 5502
}
\ No newline at end of file
diff --git a/js/interact.js b/js/interact.js
index a829979..976b423 100644
--- a/js/interact.js
+++ b/js/interact.js
@@ -8,6 +8,8 @@ export function submitAnswers(exam_details, db, config) {
.then((a) => {
let json = {
eid: exam_details.eid,
+ cid: exam_details.cid,
+ start_time: exam_details.start_time,
answers: JSON.stringify(a),
};
postAnswers(json, config, exam_details);
@@ -25,10 +27,10 @@ export function submitAnswers(exam_details, db, config) {
export function getJsonAnswers(exam_details, db) {
console.log(exam_details)
console.log({
- aid: exam_details.aid,
- cid: exam_details.cid,
- eid: exam_details.eid,
- })
+ aid: exam_details.aid,
+ cid: exam_details.cid,
+ eid: exam_details.eid,
+ })
return db.answers
.where({
aid: exam_details.aid,
@@ -56,7 +58,7 @@ export function postAnswers(ans, config, exam_details) {
);
if (ret) {
- $( document ).trigger( "saveSessionEvent", [ true ] );
+ $(document).trigger("saveSessionEvent", [true]);
if (config.exam_results_url != "") {
let url = config.exam_results_url;
@@ -70,8 +72,7 @@ export function postAnswers(ans, config, exam_details) {
);
}
$("#options-panel").show();
- } else {
- }
+ } else {}
} else {
alert(`${data.question_count} answers sucessfully submitted.`);
}
@@ -100,13 +101,13 @@ function submissionError(data, answer_json, exam_details) {
let answer_map = {}
- answers.forEach((ans, n) => {
+ answers.forEach((ans, n) => {
if (!answer_map.hasOwnProperty(ans.qid)) {
answer_map[ans.qid] = [];
}
answer_map[ans.qid].push(ans);
-
+
});
let html = $("
");
@@ -114,13 +115,13 @@ function submissionError(data, answer_json, exam_details) {
exam_details.question_order.forEach((i, j) => {
console.log(i, answer_map)
if (i in answer_map) {
- console.log("YES", i, answer_map)
+ console.log("YES", i, answer_map)
let ans_array = answer_map[i];
ans_array.forEach((x, y) => {
- $(html).append(`Question ${j+1}.${y}: ${x.ans}`);
+ $(html).append(`Question ${j+1}.${y}: ${x.ans}`);
});
}
-
+
})
console.log(exam_details.question_order);
@@ -145,7 +146,7 @@ export function getQuestion(url, question_number, question_total) {
return $.ajax({
dataType: "json",
url: url,
- progress: function (e) {
+ progress: function(e) {
$("#progress").html(
`Downloading question [${question_number}/${question_total}]
This file is compressed (no size available)`
);
@@ -170,14 +171,18 @@ export function getQuestion(url, question_number, question_total) {
}
export function postSavedAnswer(type, qid, answer, e, db_object, db) {
-console.log("post", type, qid, answer, e)
-return $.ajax({
+ console.log("post", type, qid, answer, e)
+ return $.ajax({
type: "POST",
url: config.question_answer_submit_url,
- data: JSON.stringify({ qid: `${type}/${qid}`, answer: answer, status: 2 }),
+ data: JSON.stringify({
+ qid: `${type}/${qid}`,
+ answer: answer,
+ status: 2
+ }),
contentType: "application/json; charset=utf-8",
dataType: "json",
- success: function(data){
+ success: function(data) {
db_object.submitted = true;
db.user_answers.put(db_object);
e.target.remove()
@@ -185,7 +190,7 @@ return $.ajax({
},
error: function(errMsg) {
- alert(errMsg);
+ alert(errMsg);
}
-});
-}
+ });
+}
\ No newline at end of file
diff --git a/js/main.js b/js/main.js
index 2c7db80..a2004f0 100644
--- a/js/main.js
+++ b/js/main.js
@@ -13,6 +13,7 @@ let exam_details = {
exam_mode: false,
number_of_questions: null,
question_order: [],
+ start_time: null,
};
let packet_list = [];
@@ -2449,6 +2450,8 @@ $(".start-packet-button").click(function(evt) {
}
}
+ exam_details.start_time = new Date().getTime() / 1000;
+
if (timer != null) {
timer.stop();
}