def showQuestions(id_survey, id_section): ''' Show all question of a section ''' stateSurvey = get_stateSurvey_or_error(id_survey,g.user,request.remote_addr) section = stateSurvey.nextSection() if section is None or section.id !=id_section: flash (gettext("access denied")) return abort (403) survey = Survey.query.get(id_survey) section = Section.query.get(id_section) questions = section.questions form = generate_form(questions) if form.validate_on_submit(): for question in questions: if writeQuestion(question, form): answer = generate_answer(question,form,g.user) db.session.add(answer) db.session.commit() stateSurvey.finishedSection(form.time.data) return redirect(url_for('surveys.logicSurvey',id_survey = id_survey)) return render_template('/surveys/showQuestions.html', title = survey.title, survey = survey, section = section, # form = form, form = form, questions = questions, percent = stateSurvey.percentSurvey() )
def showQuestions(id_survey, id_section): ''' Show all question of a section ''' stateSurvey = get_stateSurvey_or_error(id_survey,g.user,request.remote_addr) section = stateSurvey.nextSection() if section is None or section.id !=id_section: flash (gettext("access denied")) return abort (403) survey = Survey.query.get(id_survey) section = Section.query.get(id_section) questions = section.questions form = generate_form(questions) if form.validate_on_submit(): for question in questions: if writeQuestion(question, form): answer = generate_answer(question,form,g.user) db.session.add(answer) db.session.commit() stateSurvey.finishedSection(form.time.data) return redirect(url_for('surveys.logicSurvey',id_survey = id_survey)) #dirty fix to show number decision, if i know it before... decision = None if id_section in [40,41,42,43,44,45,46,47,48,49,50,51,32,33,23,52,53,54,55,56,57,58,59,60,61,62,63,38,39,27]: if id_section in [40,43,46,49,52,55,58,61]: decision = '<h3>Decisión %s, parte 1</h3>' % (get_number_decision(id_survey, id_section)) elif id_section in [41,44,47,50,53,56,59,62]: decision = '<h3>Decisión %s, parte 2</h3>' % (get_number_decision(id_survey, id_section)) elif id_section in [42,45,48,51,54,57,60,63]: decision = '<h3>Decisión %s, parte 3</h3>' % (get_number_decision(id_survey, id_section)-1) else: decision = '<h3>Decisión %s</h3>' % (get_number_decision(id_survey, id_section)) print "vamos",get_number_decision(id_survey, id_section) return render_template('/surveys/showQuestions.html', title = survey.title, survey = survey, section = section, # form = form, form = form, questions = questions, # percent = stateSurvey.percentSurvey(), decision = decision )