diff --git a/QuizTheWord/__init__.py b/QuizTheWord/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/QuizTheWord/admin/__init__.py b/QuizTheWord/admin/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/QuizTheWord/admin/admin.py b/QuizTheWord/admin/admin.py index 5786d56..702e860 100644 --- a/QuizTheWord/admin/admin.py +++ b/QuizTheWord/admin/admin.py @@ -24,12 +24,21 @@ def questions(): @roles_required("admin") def edit_question(question_id): if request.method == "POST": - print(f"edit question: {request.form.get('question_text')}") - database.update_question(question_id, - request.form.get("question_text"), - request.form.get("answer"), - request.form.get("addresses") - ) + data = { + "question_text": request.form.get("question_text"), + "answer": request.form.get("answer"), + "addresses": request.form.get("addresses"), + } + multiple_choice_difficulty = request.form.get("multiple_choice_difficulty", None, int) + wrong_answers = request.form.getlist("wrong_answers") + hidden_answer_difficulty = request.form.get("hidden_answer_difficulty", None, int) + if multiple_choice_difficulty is not None: + data["multiple_choice_difficulty"] = multiple_choice_difficulty + if len(wrong_answers) > 0: + data["wrong_answers"] = wrong_answers + if hidden_answer_difficulty is not None: + data["hidden_answer_difficulty"] = hidden_answer_difficulty + database.update_question(question_id, data) return redirect(url_for("admin.edit_question", question_id=question_id)) question: database.AllQuestions = get_question(database.AllQuestions, question_id) if "application/json" in request.accept_mimetypes.values(): @@ -54,7 +63,7 @@ def query_questions(): response_dict["rows"].append({ "id": question.question_id, "question_id": question.question_id, - "question": question.question, + "question": question.question_text, "answer": question.answer, "multiple_choice": getattr(question, "multiple_choice", None) is not None, "hidden_answer": getattr(question, "hidden_answer", None) is not None, diff --git a/QuizTheWord/admin/templates/admin/edit_question.html b/QuizTheWord/admin/templates/admin/edit_question.html index 2dd8cda..096c308 100644 --- a/QuizTheWord/admin/templates/admin/edit_question.html +++ b/QuizTheWord/admin/templates/admin/edit_question.html @@ -4,7 +4,7 @@