gui done enough

This commit is contained in:
Bel LaPointe
2023-04-07 13:33:09 -06:00
parent ef25a77254
commit c76da12b1a
2 changed files with 36 additions and 8 deletions

View File

@@ -71,7 +71,14 @@
}
function pushAnswer(idq, answer, passed) {
console.log(idq, answer, passed)
http("post", `/api/questions/${idq}/answers`, noopcallback,
JSON.stringify(
{
"answer": answer,
"passed": new Boolean(passed),
}
),
)
}
function nextQuestion(form) {
@@ -110,6 +117,23 @@
form.children.answer.retake = todo[1].Retake
}
function noopcallback(responseBody, responseStatus) {
console.log(responseStatus, responseBody)
}
function http(method, remote, callback, body) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
callback(xmlhttp.responseText, xmlhttp.status)
}
};
xmlhttp.open(method, remote, true);
if (typeof body == "undefined") {
body = null
}
xmlhttp.send(body);
}
nextQuestion(document.getElementById("flash"))
</script>
</footer>