Fix bug.
change result chart to year seperated. Add color recover to default feature. change consent checkbox to required.
This commit is contained in:
parent
9b6e011286
commit
cc4131c05e
|
@ -234,6 +234,9 @@ class Admin::SurveysController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_section
|
def delete_section
|
||||||
|
@section = SurveySection.find(params[:id])
|
||||||
|
@section.destroy
|
||||||
|
redirect_to :back
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_section
|
def create_section
|
||||||
|
|
|
@ -300,7 +300,9 @@ class SurveysController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@answer_model.save!
|
@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)
|
OrbitHelper.set_params(params,current_user)
|
||||||
redirect_to OrbitHelper.url_to_show(@survey.to_param) + "?method=answer_success&ans=#{@answer_model.id.to_s}"
|
redirect_to OrbitHelper.url_to_show(@survey.to_param) + "?method=answer_success&ans=#{@answer_model.id.to_s}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -67,17 +67,17 @@ class QuestionnaireSurvey
|
||||||
end
|
end
|
||||||
def check_need_update
|
def check_need_update
|
||||||
if self.result_criteria_changed?
|
if self.result_criteria_changed?
|
||||||
old_colors = self.result_criteria_was.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"]}
|
new_colors = self.result_criteria.map{|c| c["color"].blank? ? '#ffffff' : c["color"]} rescue []
|
||||||
new_colors_uniq_count = new_colors.uniq.count
|
new_colors_uniq_count = new_colors.uniq.count
|
||||||
self.need_assign_color = (new_colors_uniq_count > 1)
|
self.need_assign_color = (new_colors_uniq_count > 1)
|
||||||
if old_colors != new_colors
|
if old_colors != new_colors
|
||||||
self.need_update_color = true
|
self.need_update_color = true
|
||||||
elsif new_colors_uniq_count > 1
|
elsif new_colors_uniq_count > 1
|
||||||
old_questions = self.result_criteria_was.map{|c| c["questions"]}
|
old_questions = self.result_criteria_was.map{|c| c["questions"]} rescue []
|
||||||
old_range = self.result_criteria_was.map{|c| c["range"]}
|
old_range = self.result_criteria_was.map{|c| c["range"]} rescue []
|
||||||
new_questions = self.result_criteria.map{|c| c["questions"]}
|
new_questions = self.result_criteria.map{|c| c["questions"]} rescue []
|
||||||
new_range = self.result_criteria.map{|c| c["range"]}
|
new_range = self.result_criteria.map{|c| c["range"]} rescue []
|
||||||
if old_questions != new_questions || old_range != new_range
|
if old_questions != new_questions || old_range != new_range
|
||||||
self.need_update_color = true
|
self.need_update_color = true
|
||||||
end
|
end
|
||||||
|
@ -193,6 +193,7 @@ class QuestionnaireSurvey
|
||||||
if self.enable_consent_feature
|
if self.enable_consent_feature
|
||||||
answers[i]["agree"] = (answer.consent_used ? agree_trans : disagree_trans)
|
answers[i]["agree"] = (answer.consent_used ? agree_trans : disagree_trans)
|
||||||
end
|
end
|
||||||
|
answers[i]["scored_points"] = answer.scored_points
|
||||||
end
|
end
|
||||||
SurveysHelper.set_locale(I18n.locale)
|
SurveysHelper.set_locale(I18n.locale)
|
||||||
survey_questions.each do |question|
|
survey_questions.each do |question|
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
<% @survey_answers.options = {} %>
|
<% @survey_answers.options = {} %>
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#tooltip{
|
.tooltip{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
@ -65,16 +65,13 @@
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: none;
|
display: none;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
font-size: 1em;
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
.flot_wrapper{
|
.flot_wrapper{
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="flot_wrapper">
|
|
||||||
<span id="tooltip"></span>
|
|
||||||
<div class="legend-container"></div>
|
|
||||||
<div id="resultchart-container" class="flot-placeholder"></div>
|
|
||||||
</div>
|
|
||||||
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %>
|
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %>
|
||||||
<%= javascript_include_tag "survey/jquery.canvaswrapper.js" %>
|
<%= javascript_include_tag "survey/jquery.canvaswrapper.js" %>
|
||||||
<%= javascript_include_tag "survey/jquery.flot_3.0.js" %>
|
<%= javascript_include_tag "survey/jquery.flot_3.0.js" %>
|
||||||
|
@ -93,9 +90,25 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<% @survey_answers = @survey_answers.order_by(:created_at=>1) %>
|
||||||
|
<% last_year = @survey_answers.last.created_at.year %>
|
||||||
|
<% first_year = @survey_answers.first.created_at.year %>
|
||||||
|
<% all_years = (first_year..last_year).to_a.reverse %>
|
||||||
|
<% all_years.each do |year|%>
|
||||||
|
<% start_d = DateTime.parse("#{year}/1/1 #{Time.zone}") %>
|
||||||
|
<% end_d = start_d.end_of_year %>
|
||||||
|
<% survey_answers_sep = @survey_answers.where(:created_at.gte=>start_d).and(:created_at.lte=>end_d) %>
|
||||||
|
<% next if survey_answers_sep.count == 0 %>
|
||||||
|
<div class="flot_wrapper" id="<%=year%>_block">
|
||||||
|
<h4 style="text-align: center;"><%= year %></h4>
|
||||||
|
<span class="tooltip"></span>
|
||||||
|
<div class="legend-container"></div>
|
||||||
|
<div class="flot-placeholder"></div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
(function(){
|
||||||
<% if @survey.need_assign_color %>
|
<% if @survey.need_assign_color %>
|
||||||
<% 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 %>
|
<% data = survey_answers_sep.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 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 %>;
|
var max_time = <%= data.map{|k,d| d[-1][0] rescue 0}.max %>;
|
||||||
<% all_data = data.values.flatten(1) %>
|
<% all_data = data.values.flatten(1) %>
|
||||||
|
@ -103,7 +116,7 @@
|
||||||
var min_y = <%= y_data.min.to_i %>;
|
var min_y = <%= y_data.min.to_i %>;
|
||||||
var max_y = <%= y_data.max.to_i %>;
|
var max_y = <%= y_data.max.to_i %>;
|
||||||
<% else %>
|
<% else %>
|
||||||
<% data = @survey_answers.order_by(:created_at=>1).map{|sa| [sa.created_at.to_i * 1000 , sa.scored_points ]} %>
|
<% data = survey_answers_sep.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 min_time = <%= data[0][0] rescue 0 %>;
|
||||||
var max_time = <%= data[-1][0] rescue 0 %>;
|
var max_time = <%= data[-1][0] rescue 0 %>;
|
||||||
var min_y = <%= data.map{|a| a[1]}.min.to_i %>;
|
var min_y = <%= data.map{|a| a[1]}.min.to_i %>;
|
||||||
|
@ -209,24 +222,36 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var chart_height = $(window).outerWidth(true)*0.2;
|
var chart_height = $(window).outerWidth(true)*0.2;
|
||||||
$("#resultchart-container").height(chart_height).plot(chart_data,options);
|
$("#<%=year%>_block .flot-placeholder").height(chart_height).plot(chart_data,options);
|
||||||
|
})
|
||||||
|
$(window).resize(function(){
|
||||||
|
var chart_height = $(window).outerWidth(true)*0.2;
|
||||||
|
$("#<%=year%>_block .flot-placeholder").height(chart_height).plot(chart_data,options);
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
$(".flot-placeholder").bind("plothover", function (event, pos, item) {
|
$(".flot-placeholder").bind("plothover", function (event, pos, item) {
|
||||||
if (!pos.x || !pos.y) {
|
if (!pos.x || !pos.y) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!item) {
|
if (!item) {
|
||||||
$("#tooltip").hide();
|
$(this).siblings(".tooltip").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(".flot-placeholder").bind("plotclick", function (event, pos, item) {
|
$(".flot-placeholder").bind("plotclick", function (event, pos, item) {
|
||||||
if (!pos.x || !pos.y) {
|
if (!pos.x || !pos.y || item == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var tooltip = $(this).siblings(".tooltip");
|
||||||
|
console.log(tooltip)
|
||||||
var x = item.datapoint[0].toFixed(2),
|
var x = item.datapoint[0].toFixed(2),
|
||||||
y = item.datapoint[1].toFixed(0);
|
y = item.datapoint[1].toFixed(0);
|
||||||
var date = new moment(Math.round(x));
|
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);
|
tooltip.html("<%=t("survey.type.0")%>: "+y+"<br>"+tp);
|
||||||
var left = 0;
|
var left = 0;
|
||||||
var content_width = tp.length*8.2
|
var content_width = tp.length*8.2
|
||||||
if (content_width+item.pageX+5>$(window).width()){
|
if (content_width+item.pageX+5>$(window).width()){
|
||||||
|
@ -235,14 +260,10 @@
|
||||||
left = item.pageX - content_width / 2;
|
left = item.pageX - content_width / 2;
|
||||||
}
|
}
|
||||||
var offset = $(this).parents(".flot_wrapper").eq(0).offset();
|
var offset = $(this).parents(".flot_wrapper").eq(0).offset();
|
||||||
$("#tooltip").css({top: item.pageY+5-offset.top, left: left-offset.left})
|
tooltip.css({top: item.pageY+5-offset.top, left: left-offset.left})
|
||||||
.fadeIn(200);
|
.fadeIn(200);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
$(window).resize(function(){
|
|
||||||
var chart_height = $(window).outerWidth(true)*0.2;
|
|
||||||
$("#resultchart-container").height(chart_height).plot(chart_data,options);
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
<% else %>
|
<% else %>
|
||||||
<table class="table main-list">
|
<table class="table main-list">
|
||||||
|
@ -254,6 +275,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% @is_answer_list = true if !@answer_repeat%>
|
||||||
|
<% answers_nil = @survey_answers.nil? %>
|
||||||
<% (@survey_answer_groups || @survey_answers).each do |sa| %>
|
<% (@survey_answer_groups || @survey_answers).each do |sa| %>
|
||||||
<tr>
|
<tr>
|
||||||
<% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %>
|
<% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %>
|
||||||
|
@ -268,6 +291,7 @@
|
||||||
<a class="btn btn-primary" href="/admin/surveys/<%= sa.id.to_s %>/answer_list"><%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>)</a>
|
<a class="btn btn-primary" href="/admin/surveys/<%= sa.id.to_s %>/answer_list"><%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>)</a>
|
||||||
<button class="btn btn-primary export-xls" data-href="/admin/surveys/<%= sa.id.to_s %>/export_answers"><%= t("survey.export") %></button>
|
<button class="btn btn-primary export-xls" data-href="/admin/surveys/<%= sa.id.to_s %>/export_answers"><%= t("survey.export") %></button>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% sa = sa.survey_answers.last if answers_nil %>
|
||||||
<% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %>
|
<% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %>
|
||||||
<% tmp_msgs = []
|
<% tmp_msgs = []
|
||||||
answer_model_attrs = sa.attributes
|
answer_model_attrs = sa.attributes
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
border-bottom: 2px solid;
|
border-bottom: 2px solid;
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
input.color_input{
|
||||||
|
height: 2em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
|
@ -115,7 +118,8 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="criteria" style="margin-left:0px;display:block;margin-bottom:50px;">
|
<div class="criteria" style="margin-left:0px;display:block;margin-bottom:50px;">
|
||||||
<label style="padding-left:0px;" for="" class="radio inline"> Color : <input type="color" name="questionnaire_survey[result_criteria][<%= idx %>][color]" value="<%=criteria["color"].blank? ? "#ffffff" : criteria["color"] %>"></label>
|
<label style="padding-left:0px;" for="" class="radio inline"> Color : <input class="color_input" type="color" name="questionnaire_survey[result_criteria][<%= idx %>][color]" value="<%=criteria["color"].blank? ? "#ffffff" : criteria["color"] %>"></label>
|
||||||
|
<button type="button" class="btn btn-primary btn-small recover_to_default"><%=I18n.t("survey.recover_to_default")%></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="criteria">
|
<div class="criteria">
|
||||||
<label for="" class="radio inline">
|
<label for="" class="radio inline">
|
||||||
|
@ -151,7 +155,7 @@
|
||||||
<% [0,1].each do |i| %>
|
<% [0,1].each do |i| %>
|
||||||
html += '<option value="<%=i%>"><%=t("survey.type.#{i}")%></option>'
|
html += '<option value="<%=i%>"><%=t("survey.type.#{i}")%></option>'
|
||||||
<% end %>
|
<% end %>
|
||||||
html += '</select></label></div><div data-critera-number="criteria_{index}" class="criteria" style="width:800px;"><label style="padding-left:0px;" for="" class="radio inline"> From : <input name="questionnaire_survey[result_criteria][{index}][range][]" class="span1" max="<%= @survey.total_points %>" type="number"></label><label for="" class="radio inline"> To : <input name="questionnaire_survey[result_criteria][{index}][range][]" class="span1" max="<%= @survey.total_points %>" type="number"></label><a href="" style="margin-left:5px;" class="btn btn-primary delete-critera"><i class="icon icon-trash"></i></a><span class="radio inline">Save to add text</span></div><div class="criteria" style="margin-left:0px;display:block;"><label style="padding-left:0px;" for="" class="radio inline"> Color : <input type="color" name="questionnaire_survey[result_criteria][{index}][color]" value="#ffffff"></label></div></div>';
|
html += '</select></label></div><div data-critera-number="criteria_{index}" class="criteria" style="width:800px;"><label style="padding-left:0px;" for="" class="radio inline"> From : <input name="questionnaire_survey[result_criteria][{index}][range][]" class="span1" max="<%= @survey.total_points %>" type="number"></label><label for="" class="radio inline"> To : <input name="questionnaire_survey[result_criteria][{index}][range][]" class="span1" max="<%= @survey.total_points %>" type="number"></label><a href="" style="margin-left:5px;" class="btn btn-primary delete-critera"><i class="icon icon-trash"></i></a><span class="radio inline">Save to add text</span></div><div class="criteria" style="margin-left:0px;display:block;"><label style="padding-left:0px;" for="" class="radio inline"> Color : <input class="color_input" type="color" name="questionnaire_survey[result_criteria][{index}][color]" value="#ffffff"></label><button type="button" class="btn btn-primary btn-small recover_to_default"><%=I18n.t("survey.recover_to_default")%></button></div></div>';
|
||||||
|
|
||||||
$("#add-criteria").on("click",function(){
|
$("#add-criteria").on("click",function(){
|
||||||
var newhtml = html.replace(/{index}/g,index);
|
var newhtml = html.replace(/{index}/g,index);
|
||||||
|
@ -160,7 +164,9 @@
|
||||||
$("#criterias").append(newhtml);
|
$("#criterias").append(newhtml);
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
|
$(document).on("click", ".recover_to_default", function(){
|
||||||
|
$(this).siblings("label").find(".color_input").val("#ffffff");
|
||||||
|
})
|
||||||
$(document).on("click", ".delete-critera" ,function(){
|
$(document).on("click", ".delete-critera" ,function(){
|
||||||
$(this).parent().parent().remove();
|
$(this).parent().parent().remove();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -10,6 +10,8 @@ wb.add_worksheet(name: title) do |sheet|
|
||||||
row << survey.consent_contents
|
row << survey.consent_contents
|
||||||
row2 << ""
|
row2 << ""
|
||||||
end
|
end
|
||||||
|
row << I18n.t("survey.type.0")
|
||||||
|
row2 << ""
|
||||||
survey_questions.each_with_index do |question, i|
|
survey_questions.each_with_index do |question, i|
|
||||||
qnum = question.title.match(/^\d+./).nil? ? "#{i+1}. " : ""
|
qnum = question.title.match(/^\d+./).nil? ? "#{i+1}. " : ""
|
||||||
start_col = row2.count
|
start_col = row2.count
|
||||||
|
|
|
@ -37,9 +37,10 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if type == "result_chart" %>
|
<% if type == "result_chart" %>
|
||||||
|
<% @survey_answers.options = {} %>
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#tooltip{
|
.tooltip{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
@ -47,13 +48,13 @@
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: none;
|
display: none;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
font-size: 1em;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.flot_wrapper{
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="flot_wrapper">
|
|
||||||
<span id="tooltip"></span>
|
|
||||||
<div class="legend-container"></div>
|
|
||||||
<div id="resultchart-container" class="flot-placeholder"></div>
|
|
||||||
</div>
|
|
||||||
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %>
|
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %>
|
||||||
<%= javascript_include_tag "survey/jquery.canvaswrapper.js" %>
|
<%= javascript_include_tag "survey/jquery.canvaswrapper.js" %>
|
||||||
<%= javascript_include_tag "survey/jquery.flot_3.0.js" %>
|
<%= javascript_include_tag "survey/jquery.flot_3.0.js" %>
|
||||||
|
@ -71,13 +72,26 @@
|
||||||
.axisLabels {
|
.axisLabels {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.flot_wrapper{
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
<% @survey_answers = @survey_answers.order_by(:created_at=>1) %>
|
||||||
|
<% last_year = @survey_answers.last.created_at.year %>
|
||||||
|
<% first_year = @survey_answers.first.created_at.year %>
|
||||||
|
<% all_years = (first_year..last_year).to_a.reverse %>
|
||||||
|
<% all_years.each do |year|%>
|
||||||
|
<% start_d = DateTime.parse("#{year}/1/1 #{Time.zone}") %>
|
||||||
|
<% end_d = start_d.end_of_year %>
|
||||||
|
<% survey_answers_sep = @survey_answers.where(:created_at.gte=>start_d).and(:created_at.lte=>end_d) %>
|
||||||
|
<% next if survey_answers_sep.count == 0 %>
|
||||||
|
<div class="flot_wrapper" id="<%=year%>_block">
|
||||||
|
<h4 style="text-align: center;"><%= year %></h4>
|
||||||
|
<span class="tooltip"></span>
|
||||||
|
<div class="legend-container"></div>
|
||||||
|
<div class="flot-placeholder"></div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
(function(){
|
||||||
<% if @survey.need_assign_color %>
|
<% if @survey.need_assign_color %>
|
||||||
<% 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 %>
|
<% data = survey_answers_sep.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 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 %>;
|
var max_time = <%= data.map{|k,d| d[-1][0] rescue 0}.max %>;
|
||||||
<% all_data = data.values.flatten(1) %>
|
<% all_data = data.values.flatten(1) %>
|
||||||
|
@ -85,7 +99,7 @@
|
||||||
var min_y = <%= y_data.min.to_i %>;
|
var min_y = <%= y_data.min.to_i %>;
|
||||||
var max_y = <%= y_data.max.to_i %>;
|
var max_y = <%= y_data.max.to_i %>;
|
||||||
<% else %>
|
<% else %>
|
||||||
<% data = @survey_answers.order_by(:created_at=>1).map{|sa| [sa.created_at.to_i * 1000 , sa.scored_points ]} %>
|
<% data = survey_answers_sep.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 min_time = <%= data[0][0] rescue 0 %>;
|
||||||
var max_time = <%= data[-1][0] rescue 0 %>;
|
var max_time = <%= data[-1][0] rescue 0 %>;
|
||||||
var min_y = <%= data.map{|a| a[1]}.min.to_i %>;
|
var min_y = <%= data.map{|a| a[1]}.min.to_i %>;
|
||||||
|
@ -191,24 +205,36 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var chart_height = $(window).outerWidth(true)*0.2;
|
var chart_height = $(window).outerWidth(true)*0.2;
|
||||||
$("#resultchart-container").height(chart_height).plot(chart_data,options);
|
$("#<%=year%>_block .flot-placeholder").height(chart_height).plot(chart_data,options);
|
||||||
|
})
|
||||||
|
$(window).resize(function(){
|
||||||
|
var chart_height = $(window).outerWidth(true)*0.2;
|
||||||
|
$("#<%=year%>_block .flot-placeholder").height(chart_height).plot(chart_data,options);
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
$(".flot-placeholder").bind("plothover", function (event, pos, item) {
|
$(".flot-placeholder").bind("plothover", function (event, pos, item) {
|
||||||
if (!pos.x || !pos.y) {
|
if (!pos.x || !pos.y) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!item) {
|
if (!item) {
|
||||||
$("#tooltip").hide();
|
$(this).siblings(".tooltip").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(".flot-placeholder").bind("plotclick", function (event, pos, item) {
|
$(".flot-placeholder").bind("plotclick", function (event, pos, item) {
|
||||||
if (!pos.x || !pos.y) {
|
if (!pos.x || !pos.y || item == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var tooltip = $(this).siblings(".tooltip");
|
||||||
|
console.log(tooltip)
|
||||||
var x = item.datapoint[0].toFixed(2),
|
var x = item.datapoint[0].toFixed(2),
|
||||||
y = item.datapoint[1].toFixed(0);
|
y = item.datapoint[1].toFixed(0);
|
||||||
var date = new moment(Math.round(x));
|
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);
|
tooltip.html("<%=t("survey.type.0")%>: "+y+"<br>"+tp);
|
||||||
var left = 0;
|
var left = 0;
|
||||||
var content_width = tp.length*8.2
|
var content_width = tp.length*8.2
|
||||||
if (content_width+item.pageX+5>$(window).width()){
|
if (content_width+item.pageX+5>$(window).width()){
|
||||||
|
@ -217,15 +243,10 @@
|
||||||
left = item.pageX - content_width / 2;
|
left = item.pageX - content_width / 2;
|
||||||
}
|
}
|
||||||
var offset = $(this).parents(".flot_wrapper").eq(0).offset();
|
var offset = $(this).parents(".flot_wrapper").eq(0).offset();
|
||||||
|
tooltip.css({top: item.pageY+5-offset.top, left: left-offset.left})
|
||||||
$("#tooltip").css({top: item.pageY+5-offset.top, left: left-offset.left})
|
|
||||||
.fadeIn(200);
|
.fadeIn(200);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
$(window).resize(function(){
|
|
||||||
var chart_height = $(window).outerWidth(true)*0.2;
|
|
||||||
$("#resultchart-container").height(chart_height).plot(chart_data,options);
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
<% else %>
|
<% else %>
|
||||||
<table class="table main-list">
|
<table class="table main-list">
|
||||||
|
@ -237,6 +258,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% @is_answer_list = true if !@answer_repeat%>
|
||||||
|
<% answers_nil = @survey_answers.nil? %>
|
||||||
<% (@survey_answer_groups || @survey_answers).each do |sa| %>
|
<% (@survey_answer_groups || @survey_answers).each do |sa| %>
|
||||||
<tr>
|
<tr>
|
||||||
<% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %>
|
<% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %>
|
||||||
|
@ -251,6 +274,7 @@
|
||||||
<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>
|
<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>
|
||||||
<button class="btn btn-primary export-xls" data-href="/admin/surveys/<%= sa.id.to_s %>/export_answers" title="<%= t("survey.export") %>"><%= t("survey.export") %></button>
|
<button class="btn btn-primary export-xls" data-href="/admin/surveys/<%= sa.id.to_s %>/export_answers" title="<%= t("survey.export") %>"><%= t("survey.export") %></button>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% sa = sa.survey_answers.last if answers_nil %>
|
||||||
<% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %>
|
<% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %>
|
||||||
<% tmp_msgs = []
|
<% tmp_msgs = []
|
||||||
answer_model_attrs = sa.attributes
|
answer_model_attrs = sa.attributes
|
||||||
|
|
|
@ -92,9 +92,10 @@
|
||||||
</div>
|
</div>
|
||||||
<ol class="o-question-list">
|
<ol class="o-question-list">
|
||||||
<% if @survey.enable_consent_feature %>
|
<% if @survey.enable_consent_feature %>
|
||||||
<div class="survey_consent_contents o-question-title">
|
<li class="survey_consent_contents question-item ">
|
||||||
<label for="survey_consent_used"><%= f.check_box :consent_used , {:id=>"survey_consent_used", :title=>t('survey.agree')} %><span style="margin-left: 0.2em;"><%= @survey.consent_contents.to_s.html_safe %></span></label>
|
<span class="required-star">(*)</span>
|
||||||
</div>
|
<label for="survey_consent_used" class="o-question-title"><%= f.check_box :consent_used , {:id=>"survey_consent_used", :title=>t('survey.agree'), :required=>"required"} %><span style="margin-left: 0.2em;"><%= @survey.consent_contents.to_s.html_safe %></span></label>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% @questions.each_with_index do |question, i| %>
|
<% @questions.each_with_index do |question, i| %>
|
||||||
<% header_count = i + 1 %>
|
<% header_count = i + 1 %>
|
||||||
|
|
|
@ -2,6 +2,7 @@ en:
|
||||||
module_name:
|
module_name:
|
||||||
survey: Survey
|
survey: Survey
|
||||||
survey:
|
survey:
|
||||||
|
recover_to_default: Recover to default
|
||||||
'true': 'Yes'
|
'true': 'Yes'
|
||||||
'false': 'No'
|
'false': 'No'
|
||||||
consent_to_be_used_for_research: "Consent answer to be used for research"
|
consent_to_be_used_for_research: "Consent answer to be used for research"
|
||||||
|
|
|
@ -4,6 +4,7 @@ zh_tw:
|
||||||
survey: 問卷調查
|
survey: 問卷調查
|
||||||
|
|
||||||
survey:
|
survey:
|
||||||
|
recover_to_default: 恢復成預設
|
||||||
'true': 已勾選
|
'true': 已勾選
|
||||||
'false': 未勾選
|
'false': 未勾選
|
||||||
consent_to_be_used_for_research: "同意填答結果被用於研究"
|
consent_to_be_used_for_research: "同意填答結果被用於研究"
|
||||||
|
|
Loading…
Reference in New Issue