Start extracting server communications to seperate module
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Submits answers
|
||||||
|
*/
|
||||||
|
function submitAnswers() {
|
||||||
|
console.log(
|
||||||
|
getJsonAnswers().then((a) => {
|
||||||
|
postAnswers(a);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts answers to url
|
||||||
|
* @param {*} ans - json representation of answers
|
||||||
|
*/
|
||||||
|
function postAnswers(ans) {
|
||||||
|
console.log(ans);
|
||||||
|
// ans = {"test" : 1}
|
||||||
|
$.post("http://localhost:8000/submit_answers", JSON.stringify(ans)).done(
|
||||||
|
(data) => {
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
|
||||||
|
}
|
||||||
+3
-26
@@ -1,6 +1,7 @@
|
|||||||
/* global Dexie, cornerstone, cornerstoneTools, cornerstoneBase64ImageLoader, cornerstoneWebImageLoader, cornerstoneWADOImageLoader */
|
/* global Dexie, cornerstone, cornerstoneTools, cornerstoneBase64ImageLoader, cornerstoneWebImageLoader, cornerstoneWADOImageLoader */
|
||||||
import * as helper from "./helpers.js";
|
import * as helper from "./helpers.js";
|
||||||
import * as viewer from "./viewer.js";
|
import * as viewer from "./viewer.js";
|
||||||
|
import * as interact from "./viewer.js";
|
||||||
// const { v4: uuidv4 } = require('uuid');
|
// const { v4: uuidv4 } = require('uuid');
|
||||||
|
|
||||||
// cid = null;
|
// cid = null;
|
||||||
@@ -92,6 +93,7 @@ async function loadPacketList(data) {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
window.packet_list = data.packets;
|
window.packet_list = data.packets;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#packet-list").empty();
|
$("#packet-list").empty();
|
||||||
window.packet_list.forEach(function (packet) {
|
window.packet_list.forEach(function (packet) {
|
||||||
let c = "";
|
let c = "";
|
||||||
@@ -968,7 +970,7 @@ $("#btn-local-file-load").click(function (evt) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#submit-button").click(function (evt) {
|
$("#submit-button").click(function (evt) {
|
||||||
submitAnswers();
|
interact.submitAnswers();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#review-button").click(function (evt) {
|
$("#review-button").click(function (evt) {
|
||||||
@@ -1032,21 +1034,6 @@ function getJsonAnswers() {
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Posts answers to url
|
|
||||||
* @param {*} ans - json representation of answers
|
|
||||||
*/
|
|
||||||
function postAnswers(ans) {
|
|
||||||
console.log(ans);
|
|
||||||
// ans = {"test" : 1}
|
|
||||||
$.post("http://localhost:8000/submit_answers", JSON.stringify(ans)).done(
|
|
||||||
(data) => {
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a local question set (from a file)
|
* Loads a local question set (from a file)
|
||||||
* This is call in index.html
|
* This is call in index.html
|
||||||
@@ -1089,16 +1076,6 @@ function loadLocalQuestionSet() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Submits answers
|
|
||||||
*/
|
|
||||||
function submitAnswers() {
|
|
||||||
console.log(
|
|
||||||
getJsonAnswers().then((a) => {
|
|
||||||
postAnswers(a);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the review question panel with a summary of marks
|
* Displays the review question panel with a summary of marks
|
||||||
|
|||||||
Reference in New Issue
Block a user