Fix bug.
This commit is contained in:
parent
dedbe340ac
commit
9b6e011286
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% if type == "result_chart" %>
|
||||
<% @survey_answers.options = {} %>
|
||||
<div style="clear: both;"></div>
|
||||
<style type="text/css">
|
||||
#tooltip{
|
||||
|
@ -94,7 +95,7 @@
|
|||
</style>
|
||||
<script>
|
||||
<% if @survey.need_assign_color %>
|
||||
<% data = @survey_answers.order_by(:updated_at=>1).group_by(&:color).map{|k,sas| [k, sas.map{|sa| [sa.updated_at.to_i * 1000 , sa.scored_points ]} ] }.to_h %>
|
||||
<% data = @survey_answers.order_by(:created_at=>1).group_by(&:color).map{|k,sas| [k, sas.map{|sa| [sa.created_at.to_i * 1000 , sa.scored_points ]} ] }.to_h %>
|
||||
var min_time = <%= data.map{|k,d| d[0][0] rescue 0}.min %>;
|
||||
var max_time = <%= data.map{|k,d| d[-1][0] rescue 0}.max %>;
|
||||
<% all_data = data.values.flatten(1) %>
|
||||
|
@ -102,7 +103,7 @@
|
|||
var min_y = <%= y_data.min.to_i %>;
|
||||
var max_y = <%= y_data.max.to_i %>;
|
||||
<% else %>
|
||||
<% data = @survey_answers.order_by(:updated_at=>1).map{|sa| [sa.updated_at.to_i * 1000 , sa.scored_points ]} %>
|
||||
<% data = @survey_answers.order_by(:created_at=>1).map{|sa| [sa.created_at.to_i * 1000 , sa.scored_points ]} %>
|
||||
var min_time = <%= data[0][0] rescue 0 %>;
|
||||
var max_time = <%= data[-1][0] rescue 0 %>;
|
||||
var min_y = <%= data.map{|a| a[1]}.min.to_i %>;
|
||||
|
@ -224,7 +225,7 @@
|
|||
var x = item.datapoint[0].toFixed(2),
|
||||
y = item.datapoint[1].toFixed(0);
|
||||
var date = new moment(Math.round(x));
|
||||
var tp = "(" + date.format("yyyy/MM/DD hh:mm") + ")"
|
||||
var tp = "(" + date.format("yyyy/MM/DD HH:mm") + ")"
|
||||
$("#tooltip").html("<%=t("survey.type.0")%>: "+y+"<br>"+tp);
|
||||
var left = 0;
|
||||
var content_width = tp.length*8.2
|
||||
|
@ -261,7 +262,7 @@
|
|||
<% else %>
|
||||
<td>NA</td>
|
||||
<% end %>
|
||||
<td><%= (@is_answer_list ? sa.updated_at : sa.last_modified).strftime("%h %d, %Y - %H:%M") rescue nil %></td>
|
||||
<td><%= (@is_answer_list ? sa.created_at : sa.last_modified).strftime((I18n.locale == :zh_tw ? "%Y/%m/%d %H:%M" : "%h %d, %Y - %H:%M")) rescue nil %></td>
|
||||
<td>
|
||||
<% if @answer_repeat && !@is_answer_list %>
|
||||
<a class="btn btn-primary" href="/admin/surveys/<%= sa.id.to_s %>/answer_list"><%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>)</a>
|
||||
|
|
|
@ -4,8 +4,12 @@ wb = xlsx_package.workbook
|
|||
title = survey.title
|
||||
title = "WorkSheet1" if title.blank?
|
||||
wb.add_worksheet(name: title) do |sheet|
|
||||
row = [I18n.t("survey.taken_by"), I18n.t("survey.consent_to_be_used_for_research")]
|
||||
row = [I18n.t("survey.taken_by"), I18n.t("survey.taken_date")]
|
||||
row2 = ["", ""]
|
||||
if survey.enable_consent_feature
|
||||
row << survey.consent_contents
|
||||
row2 << ""
|
||||
end
|
||||
survey_questions.each_with_index do |question, i|
|
||||
qnum = question.title.match(/^\d+./).nil? ? "#{i+1}. " : ""
|
||||
start_col = row2.count
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</style>
|
||||
<script>
|
||||
<% if @survey.need_assign_color %>
|
||||
<% data = @survey_answers.order_by(:updated_at=>1).group_by(&:color).map{|k,sas| [k, sas.map{|sa| [sa.updated_at.to_i * 1000 , sa.scored_points ]} ] }.to_h %>
|
||||
<% data = @survey_answers.order_by(:created_at=>1).group_by(&:color).map{|k,sas| [k, sas.map{|sa| [sa.created_at.to_i * 1000 , sa.scored_points ]} ] }.to_h %>
|
||||
var min_time = <%= data.map{|k,d| d[0][0] rescue 0}.min %>;
|
||||
var max_time = <%= data.map{|k,d| d[-1][0] rescue 0}.max %>;
|
||||
<% all_data = data.values.flatten(1) %>
|
||||
|
@ -85,7 +85,7 @@
|
|||
var min_y = <%= y_data.min.to_i %>;
|
||||
var max_y = <%= y_data.max.to_i %>;
|
||||
<% else %>
|
||||
<% data = @survey_answers.order_by(:updated_at=>1).map{|sa| [sa.updated_at.to_i * 1000 , sa.scored_points ]} %>
|
||||
<% data = @survey_answers.order_by(:created_at=>1).map{|sa| [sa.created_at.to_i * 1000 , sa.scored_points ]} %>
|
||||
var min_time = <%= data[0][0] rescue 0 %>;
|
||||
var max_time = <%= data[-1][0] rescue 0 %>;
|
||||
var min_y = <%= data.map{|a| a[1]}.min.to_i %>;
|
||||
|
@ -207,7 +207,7 @@
|
|||
var x = item.datapoint[0].toFixed(2),
|
||||
y = item.datapoint[1].toFixed(0);
|
||||
var date = new moment(Math.round(x));
|
||||
var tp = "(" + date.format("yyyy/MM/DD hh:mm") + ")"
|
||||
var tp = "(" + date.format("yyyy/MM/DD HH:mm") + ")"
|
||||
$("#tooltip").html("<%=t("survey.type.0")%>: "+y+"<br>"+tp);
|
||||
var left = 0;
|
||||
var content_width = tp.length*8.2
|
||||
|
@ -245,7 +245,7 @@
|
|||
<% else %>
|
||||
<td>NA</td>
|
||||
<% end %>
|
||||
<td><%= (@is_answer_list ? sa.updated_at : sa.last_modified).strftime("%h %d, %Y - %H:%M") rescue nil %></td>
|
||||
<td><%= (@is_answer_list ? sa.created_at : sa.last_modified).strftime((I18n.locale == :zh_tw ? "%Y/%m/%d %H:%M" : "%h %d, %Y - %H:%M")) rescue nil %></td>
|
||||
<td>
|
||||
<% if @answer_repeat && !@is_answer_list %>
|
||||
<a class="btn btn-primary" href="/admin/surveys/<%= sa.id.to_s %>/answer_list" title="<%= t("survey.view") %>"><%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>)</a>
|
||||
|
|
|
@ -4,8 +4,8 @@ zh_tw:
|
|||
survey: 問卷調查
|
||||
|
||||
survey:
|
||||
'true': 是
|
||||
'false': 否
|
||||
'true': 已勾選
|
||||
'false': 未勾選
|
||||
consent_to_be_used_for_research: "同意填答結果被用於研究"
|
||||
agree: 同意
|
||||
consent_contents: '"同意書"內容'
|
||||
|
|
Loading…
Reference in New Issue