diff --git a/app/controllers/surveys_controller.rb b/app/controllers/surveys_controller.rb index 333aaa2..53caee4 100644 --- a/app/controllers/surveys_controller.rb +++ b/app/controllers/surveys_controller.rb @@ -8,18 +8,21 @@ class SurveysController < ApplicationController current_user = OrbitHelper.current_user surveys = questionnairesurveys.collect do |a| answer_present = (current_user.nil? ? false : (a.survey_answers.where(:user => current_user.id).count > 0 ? true : false)) - + show_link = OrbitHelper.url_to_show(a.to_param) if !OrbitHelper.params[:page_no].blank? - title = ('' + a.title + '').html_safe + title = ('' + a.title + '').html_safe else - title = ('' + a.title + '').html_safe + title = ('' + a.title + '').html_safe + end + result = QuestionnaireSurvey.result(a) + if answer_present && a.needs_login + result += "#{t('survey.my_record')}".html_safe end - { "title" => title, "time_range" => QuestionnaireSurvey.time_range(a), "write" => QuestionnaireSurvey.write(a), - "result" => QuestionnaireSurvey.result(a), + "result" => result, "answer_present" => answer_present } end diff --git a/app/models/survey_answer.rb b/app/models/survey_answer.rb index 1e55407..73f00e1 100644 --- a/app/models/survey_answer.rb +++ b/app/models/survey_answer.rb @@ -31,7 +31,7 @@ class SurveyAnswer end end before_destroy do - answer_group = SurveyAnswerGroup.where(:user=>user).first + answer_group = SurveyAnswerGroup.where(:user=>self.user,:questionnaire_survey_id=>self.questionnaire_survey_id).first if answer_group answer_group.survey_answer_ids.delete(self.id) if answer_group.survey_answer_ids.count == 0 diff --git a/modules/survey/index.html.erb b/modules/survey/index.html.erb new file mode 100644 index 0000000..3ff4fa3 --- /dev/null +++ b/modules/survey/index.html.erb @@ -0,0 +1,20 @@ +
{{th_title}} | +{{th_time_range}} | +{{th_write}} | +{{th_result}} | +
---|---|---|---|
{{title}} | +{{time_range}} | +{{write}} | +{{result}} | +