survey redirection fixed

This commit is contained in:
Harry Bomrah 2015-11-30 18:21:58 +08:00
parent 7c511361ff
commit 5de4fd7777
1 changed files with 2 additions and 0 deletions

View File

@ -44,6 +44,7 @@ class SurveysController < ApplicationController
survey = QuestionnaireSurvey.find_by(uid: params[:uid]) survey = QuestionnaireSurvey.find_by(uid: params[:uid])
current_user = OrbitHelper.current_user current_user = OrbitHelper.current_user
answer_present = (current_user.nil? ? false : (survey.survey_answers.where(:user => current_user.id).count > 0 ? true : false)) answer_present = (current_user.nil? ? false : (survey.survey_answers.where(:user => current_user.id).count > 0 ? true : false))
answer_present = (!survey.needs_login ? false : answer_present)
link_to_answer_set = (answer_present ? "/admin/surveys/#{survey.survey_answers.where(:user => current_user.id).first.id.to_s}/answer_set" : "") link_to_answer_set = (answer_present ? "/admin/surveys/#{survey.survey_answers.where(:user => current_user.id).first.id.to_s}/answer_set" : "")
{ {
'survey' => survey, 'survey' => survey,
@ -74,6 +75,7 @@ class SurveysController < ApplicationController
questions = survey.survey_questions.all.entries questions = survey.survey_questions.all.entries
current_user = OrbitHelper.current_user current_user = OrbitHelper.current_user
answer_present = (current_user.nil? ? false : (survey.survey_answers.where(:user => current_user.id).count > 0 ? true : false)) answer_present = (current_user.nil? ? false : (survey.survey_answers.where(:user => current_user.id).count > 0 ? true : false))
answer_present = (!survey.needs_login ? false : answer_present)
link_to_answer_set = (answer_present ? "/admin/surveys/#{survey.survey_answers.where(:user => current_user.id).first.id.to_s}/answer_set" : "") link_to_answer_set = (answer_present ? "/admin/surveys/#{survey.survey_answers.where(:user => current_user.id).first.id.to_s}/answer_set" : "")
if survey.jump_mode if survey.jump_mode
answers = Hash[questions.collect{ |o| [o.id.to_s, o.id.to_s] }] answers = Hash[questions.collect{ |o| [o.id.to_s, o.id.to_s] }]