From 9b6e011286d19fde38121aa32e538a3762bab844 Mon Sep 17 00:00:00 2001 From: Bohung Date: Tue, 9 Nov 2021 22:48:29 +0800 Subject: [PATCH] Fix bug. --- app/models/questionnaire_survey.rb | 7 ++++++- app/models/survey_answer.rb | 4 ++-- app/views/admin/surveys/answer_sets.html.erb | 9 +++++---- app/views/survey_export/export.xlsx.axlsx | 6 +++++- app/views/surveys/my_record.html.erb | 8 ++++---- config/locales/zh_tw.yml | 4 ++-- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/models/questionnaire_survey.rb b/app/models/questionnaire_survey.rb index 7f0ccf5..e2c0024 100644 --- a/app/models/questionnaire_survey.rb +++ b/app/models/questionnaire_survey.rb @@ -185,9 +185,14 @@ class QuestionnaireSurvey survey_answers = survey_answers.to_a chart_data = {} answers =(0...survey_answers.count).map{{}} + agree_trans = I18n.t("survey.true") + disagree_trans = I18n.t("survey.false") survey_answers.each_with_index do |answer,i| answers[i]["name"] = User.find(answer.user).member_name rescue "" - answers[i]["agree"] = I18n.t("self.#{answer.consent_used}") + answers[i]["time"] = answer.created_at.strftime((I18n.locale == :zh_tw ? "%Y/%m/%d %H:%M" : "%h %d, %Y - %H:%M")) + if self.enable_consent_feature + answers[i]["agree"] = (answer.consent_used ? agree_trans : disagree_trans) + end end SurveysHelper.set_locale(I18n.locale) survey_questions.each do |question| diff --git a/app/models/survey_answer.rb b/app/models/survey_answer.rb index 25b7f6e..329e137 100644 --- a/app/models/survey_answer.rb +++ b/app/models/survey_answer.rb @@ -21,7 +21,7 @@ class SurveyAnswer if answer_group.nil? answer_group = SurveyAnswerGroup.new(info) end - answer_group.last_modified = self.updated_at + answer_group.last_modified = self.created_at answer_group.survey_answer_ids << self.id answer_group.save end @@ -29,7 +29,7 @@ class SurveyAnswer after_save do answer_group = SurveyAnswerGroup.where(:questionnaire_survey_id=>self.questionnaire_survey.id,:user=>user).first if answer_group - answer_group.last_modified = self.updated_at + answer_group.last_modified = self.created_at answer_group.save end end diff --git a/app/views/admin/surveys/answer_sets.html.erb b/app/views/admin/surveys/answer_sets.html.erb index 19a57b6..f34dd20 100644 --- a/app/views/admin/surveys/answer_sets.html.erb +++ b/app/views/admin/surveys/answer_sets.html.erb @@ -54,6 +54,7 @@ <% end %> <% if type == "result_chart" %> +<% @survey_answers.options = {} %>