Change the next question routes to include a no content status code
This commit is contained in:
parent
5519b04a46
commit
9da0104e73
@ -84,7 +84,7 @@ def next_hidden_answer():
|
|||||||
return jsonify(next_question.get_dict())
|
return jsonify(next_question.get_dict())
|
||||||
else:
|
else:
|
||||||
session.pop("hidden_answer_ids", None)
|
session.pop("hidden_answer_ids", None)
|
||||||
return jsonify(None)
|
return jsonify(None), 204
|
||||||
|
|
||||||
|
|
||||||
@app.route("/category/multiple_choice/next_question")
|
@app.route("/category/multiple_choice/next_question")
|
||||||
@ -99,7 +99,7 @@ def next_multiple_choice():
|
|||||||
return jsonify(next_question.get_dict_shuffled_choices())
|
return jsonify(next_question.get_dict_shuffled_choices())
|
||||||
else:
|
else:
|
||||||
session.pop("multiple_choice_ids", None)
|
session.pop("multiple_choice_ids", None)
|
||||||
return jsonify(None)
|
return jsonify(None), 204
|
||||||
|
|
||||||
|
|
||||||
@app.route("/login", methods=["GET", "POST"])
|
@app.route("/login", methods=["GET", "POST"])
|
||||||
|
@ -19,7 +19,16 @@ function get_new_question(difficulty) {
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: (data, textStatus, jqXHR) => {
|
success: (data, textStatus, jqXHR) => {
|
||||||
control_btns.attr("disabled", false);
|
control_btns.attr("disabled", false);
|
||||||
question_received(data);
|
if (textStatus !== "nocontent") {
|
||||||
|
question_received(data);
|
||||||
|
} else {
|
||||||
|
question_received(textStatus);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (jqXHR, textStatus, errorThrown) => {
|
||||||
|
control_btns.attr("disabled", false);
|
||||||
|
console.log(textStatus);
|
||||||
|
console.log(errorThrown);
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -57,11 +66,13 @@ function previous_question() {
|
|||||||
function question_received(data) {
|
function question_received(data) {
|
||||||
let difficulty = questions[current_difficulty-1];
|
let difficulty = questions[current_difficulty-1];
|
||||||
if (data) {
|
if (data) {
|
||||||
difficulty["questions"].push(data);
|
if (data !== "nocontent") {
|
||||||
difficulty["current_question"] += 1;
|
difficulty["questions"].push(data);
|
||||||
update_question();
|
difficulty["current_question"] += 1;
|
||||||
} else {
|
update_question();
|
||||||
difficulty["last_index"] = difficulty["current_question"];
|
} else {
|
||||||
update_question();
|
difficulty["last_index"] = difficulty["current_question"];
|
||||||
|
update_question();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user