add support for seperate qusetion requests
This commit is contained in:
+28
-1
@@ -1,3 +1,4 @@
|
||||
import * as helper from "./helpers.js";
|
||||
/**
|
||||
* Submits answers
|
||||
*/
|
||||
@@ -67,7 +68,7 @@ export function postAnswers(ans) {
|
||||
alert(`${data.question_count} answers sucessfully submitted.`);
|
||||
}
|
||||
} else {
|
||||
submissionError(data, ans);
|
||||
submissionError(data, ans);
|
||||
}
|
||||
})
|
||||
.fail((e) => {
|
||||
@@ -108,3 +109,29 @@ function submissionError(data, ans) {
|
||||
"z-index": 5000,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: async request
|
||||
export function getQuestion(url, question_number, question_total) {
|
||||
console.log("Downloading ", url, question_number, question_total);
|
||||
return $.ajax({
|
||||
dataType: "json",
|
||||
url: url,
|
||||
progress: function (e) {
|
||||
console.log(e);
|
||||
if (e.lengthComputable) {
|
||||
var completedPercentage = Math.round((e.loaded * 100) / e.total);
|
||||
|
||||
$("#progress").html(
|
||||
`Downloading [${question_number}/${question_total}]${completedPercentage}%<br/>${helper.formatBytes(
|
||||
e.total
|
||||
)}`
|
||||
);
|
||||
}
|
||||
},
|
||||
//success: function (data) {
|
||||
// strReturn = data;
|
||||
//},
|
||||
//async: false,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user