def results_texts(): user = auth.get_logged_in_user() question_id = request.form['question_id'] qions = Question.select().join(Questionnaire).join(Category).where( Category.teacher == user).where(Question.id == question_id) for qion in qions: strtype = qtype2str(qion.typ) ret = {'question_type': strtype, 'question_answers': []} answers = Answer.select(Answer, Student).where(Answer.question == qion) for answer in answers: if answer.text: ret['question_answers'].append({ 'text': answer.text, 'student': answer.student.name, 'id': answer.id }) return json.dumps(ret) return response_error('question_not_found')
def results_texts(): user = auth.get_logged_in_user() question_id = request.form['question_id'] qions = Question.select().join(Questionnaire).join(Category).where(Category.teacher == user).where(Question.id == question_id) for qion in qions: strtype = qtype2str(qion.typ) ret = {'question_type': strtype, 'question_answers': []} answers = Answer.select(Answer, Student).where(Answer.question == qion) for answer in answers: if answer.text: ret['question_answers'].append({'text': answer.text, 'student': answer.student.name, 'id': answer.id}) return json.dumps(ret) return response_error('question_not_found')