diff --git a/app/controllers/admin/surveys_controller.rb b/app/controllers/admin/surveys_controller.rb index 81f20c4..06c3e03 100644 --- a/app/controllers/admin/surveys_controller.rb +++ b/app/controllers/admin/surveys_controller.rb @@ -234,6 +234,9 @@ class Admin::SurveysController < OrbitAdminController end def delete_section + @section = SurveySection.find(params[:id]) + @section.destroy + redirect_to :back end def create_section diff --git a/app/controllers/surveys_controller.rb b/app/controllers/surveys_controller.rb index e5c3a26..c00527d 100644 --- a/app/controllers/surveys_controller.rb +++ b/app/controllers/surveys_controller.rb @@ -300,7 +300,9 @@ class SurveysController < ApplicationController end end @answer_model.save! - params[:url] = params[:show_page_url] + show_page = (OrbitHelper.page.nil? rescue true) ? Page.where(:page_id=>params["page_id"]).first : OrbitHelper.page + show_page_url = show_page.get_url rescue show_page.url + params[:url] = show_page_url OrbitHelper.set_params(params,current_user) redirect_to OrbitHelper.url_to_show(@survey.to_param) + "?method=answer_success&ans=#{@answer_model.id.to_s}" else diff --git a/app/models/questionnaire_survey.rb b/app/models/questionnaire_survey.rb index e2c0024..4bb8a44 100644 --- a/app/models/questionnaire_survey.rb +++ b/app/models/questionnaire_survey.rb @@ -67,17 +67,17 @@ class QuestionnaireSurvey end def check_need_update if self.result_criteria_changed? - old_colors = self.result_criteria_was.map{|c| c["color"].blank? ? '#ffffff' : c["color"]} - new_colors = self.result_criteria.map{|c| c["color"].blank? ? '#ffffff' : c["color"]} + old_colors = self.result_criteria_was.map{|c| c["color"].blank? ? '#ffffff' : c["color"]} rescue [] + new_colors = self.result_criteria.map{|c| c["color"].blank? ? '#ffffff' : c["color"]} rescue [] new_colors_uniq_count = new_colors.uniq.count self.need_assign_color = (new_colors_uniq_count > 1) if old_colors != new_colors self.need_update_color = true elsif new_colors_uniq_count > 1 - old_questions = self.result_criteria_was.map{|c| c["questions"]} - old_range = self.result_criteria_was.map{|c| c["range"]} - new_questions = self.result_criteria.map{|c| c["questions"]} - new_range = self.result_criteria.map{|c| c["range"]} + old_questions = self.result_criteria_was.map{|c| c["questions"]} rescue [] + old_range = self.result_criteria_was.map{|c| c["range"]} rescue [] + new_questions = self.result_criteria.map{|c| c["questions"]} rescue [] + new_range = self.result_criteria.map{|c| c["range"]} rescue [] if old_questions != new_questions || old_range != new_range self.need_update_color = true end @@ -193,6 +193,7 @@ class QuestionnaireSurvey if self.enable_consent_feature answers[i]["agree"] = (answer.consent_used ? agree_trans : disagree_trans) end + answers[i]["scored_points"] = answer.scored_points end SurveysHelper.set_locale(I18n.locale) survey_questions.each do |question| diff --git a/app/views/admin/surveys/answer_sets.html.erb b/app/views/admin/surveys/answer_sets.html.erb index f34dd20..96cc55d 100644 --- a/app/views/admin/surveys/answer_sets.html.erb +++ b/app/views/admin/surveys/answer_sets.html.erb @@ -57,7 +57,7 @@ <% @survey_answers.options = {} %>
-
- -
-
-
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %> <%= javascript_include_tag "survey/jquery.canvaswrapper.js" %> <%= javascript_include_tag "survey/jquery.flot_3.0.js" %> @@ -93,140 +90,168 @@ font-weight: bold; } - +<% end %> + <% else %> @@ -254,6 +275,8 @@ + <% @is_answer_list = true if !@answer_repeat%> + <% answers_nil = @survey_answers.nil? %> <% (@survey_answer_groups || @survey_answers).each do |sa| %> <% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %> @@ -268,6 +291,7 @@ <%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>) <% else %> + <% sa = sa.survey_answers.last if answers_nil %> <% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %> <% tmp_msgs = [] answer_model_attrs = sa.attributes diff --git a/app/views/admin/surveys/set_answers.html.erb b/app/views/admin/surveys/set_answers.html.erb index bc07d5a..6fd8e3d 100644 --- a/app/views/admin/surveys/set_answers.html.erb +++ b/app/views/admin/surveys/set_answers.html.erb @@ -9,6 +9,9 @@ border-bottom: 2px solid; padding-bottom: 15px; } + input.color_input{ + height: 2em; + } <% end %> <% content_for :page_specific_javascript do %> @@ -115,7 +118,8 @@ <% end %>
- + +
Save to add text
'; + html += '
Save to add text
'; $("#add-criteria").on("click",function(){ var newhtml = html.replace(/{index}/g,index); @@ -160,7 +164,9 @@ $("#criterias").append(newhtml); return false; }) - + $(document).on("click", ".recover_to_default", function(){ + $(this).siblings("label").find(".color_input").val("#ffffff"); + }) $(document).on("click", ".delete-critera" ,function(){ $(this).parent().parent().remove(); return false; diff --git a/app/views/survey_export/export.xlsx.axlsx b/app/views/survey_export/export.xlsx.axlsx index 4831999..6ce2562 100644 --- a/app/views/survey_export/export.xlsx.axlsx +++ b/app/views/survey_export/export.xlsx.axlsx @@ -10,6 +10,8 @@ wb.add_worksheet(name: title) do |sheet| row << survey.consent_contents row2 << "" end + row << I18n.t("survey.type.0") + row2 << "" survey_questions.each_with_index do |question, i| qnum = question.title.match(/^\d+./).nil? ? "#{i+1}. " : "" start_col = row2.count diff --git a/app/views/surveys/my_record.html.erb b/app/views/surveys/my_record.html.erb index 83ce5e9..a48b06d 100644 --- a/app/views/surveys/my_record.html.erb +++ b/app/views/surveys/my_record.html.erb @@ -37,9 +37,10 @@ <% end %> <% if type == "result_chart" %> +<% @survey_answers.options = {} %>
-
- -
-
-
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %> <%= javascript_include_tag "survey/jquery.canvaswrapper.js" %> <%= javascript_include_tag "survey/jquery.flot_3.0.js" %> @@ -71,144 +72,169 @@ .axisLabels { font-weight: bold; } - .flot_wrapper{ - position: relative; - } - +<% end %> + <% else %>
@@ -237,6 +258,8 @@ + <% @is_answer_list = true if !@answer_repeat%> + <% answers_nil = @survey_answers.nil? %> <% (@survey_answer_groups || @survey_answers).each do |sa| %> <% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %> @@ -251,6 +274,7 @@ "><%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>) <% else %> + <% sa = sa.survey_answers.last if answers_nil %> <% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %> <% tmp_msgs = [] answer_model_attrs = sa.attributes diff --git a/app/views/surveys/show.html.erb b/app/views/surveys/show.html.erb index a620c0a..636c236 100644 --- a/app/views/surveys/show.html.erb +++ b/app/views/surveys/show.html.erb @@ -92,9 +92,10 @@
    <% if @survey.enable_consent_feature %> - + <% end %> <% @questions.each_with_index do |question, i| %> <% header_count = i + 1 %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 83d6158..9c41295 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,6 +2,7 @@ en: module_name: survey: Survey survey: + recover_to_default: Recover to default 'true': 'Yes' 'false': 'No' consent_to_be_used_for_research: "Consent answer to be used for research" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index e4169a1..5923999 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -4,6 +4,7 @@ zh_tw: survey: 問卷調查 survey: + recover_to_default: 恢復成預設 'true': 已勾選 'false': 未勾選 consent_to_be_used_for_research: "同意填答結果被用於研究"