implement get_questions() API
This commit is contained in:
parent
f546ef5efd
commit
f3fa09e25f
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user