add answer submission
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as helper from "./helpers.js";
|
||||
import * as config from "./config.js";
|
||||
/**
|
||||
* Submits answers
|
||||
*/
|
||||
@@ -167,3 +168,24 @@ export function getQuestion(url, question_number, question_total) {
|
||||
//async: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function postSavedAnswer(type, qid, answer, e, db_object, db) {
|
||||
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 }),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
db_object.submitted = true;
|
||||
db.user_answers.put(db_object);
|
||||
e.target.remove()
|
||||
console.log(data);
|
||||
|
||||
},
|
||||
error: function(errMsg) {
|
||||
alert(errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user