implement get_questions() API

This commit is contained in:
Thomas Rubini 2023-03-11 18:15:48 +01:00
parent f546ef5efd
commit f3fa09e25f
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -9,4 +9,26 @@ routes_api_admin = flask.Blueprint("api_admin", __name__)
@routes_api_admin.route("/getQuestions", methods=["GET", "POST"]) @routes_api_admin.route("/getQuestions", methods=["GET", "POST"])
def get_questions(): def get_questions():
pass lang = flask.request.values.get("lang")
if lang is None:
return {"error": 1, "msg": "lang not set"}
results = db.session.execute(
select(QuestionType, Locale)
.join(Locale)
.filter(Locale.LANG==lang)
.order_by(QuestionType.QUESTION_TYPE_ID)
)
data = []
old_question_type_id = None
for question_type, locale in results:
if question_type.QUESTION_TYPE_ID != old_question_type_id:
old_question_type_id = question_type.QUESTION_TYPE_ID
data.append([])
data[-1].append({"text": locale.TEXT})
return data