parent
ecd052b9af
commit
783e919dae
|
@ -256,6 +256,7 @@ class SurveysController < ApplicationController
|
|||
if @answer_model.errors.empty?
|
||||
@answer_model.scored_points = total
|
||||
@answer_model.individual_total = individual_total
|
||||
@answer_model.consent_used = answer[:consent_used]
|
||||
@answer_model.save!
|
||||
params[:url] = params[:show_page_url]
|
||||
OrbitHelper.set_params(params,current_user)
|
||||
|
|
|
@ -12,6 +12,8 @@ class QuestionnaireSurvey
|
|||
include OrbitCategory::Categorizable
|
||||
|
||||
scope :can_display, ->{where(is_hidden: false)}
|
||||
field :enable_consent_feature, :type => Boolean, :default => false
|
||||
field :consent_contents, :type => String, :default => "", :localize => true
|
||||
field :already_fix_data, :type => Boolean, :default => false
|
||||
field :copy_id
|
||||
field :except_clone_relations, :type=>Array, :default => []
|
||||
|
@ -426,7 +428,7 @@ class QuestionnaireSurvey
|
|||
else
|
||||
oid = d['oid']
|
||||
end
|
||||
t2 += tmp[oid]["base"] rescue nil
|
||||
t2 = tmp[oid]["base"] rescue nil
|
||||
if t2
|
||||
t += t2
|
||||
level2s.each do |level2_id|
|
||||
|
|
|
@ -4,6 +4,7 @@ class SurveyAnswer
|
|||
include Mongoid::Attributes::Dynamic
|
||||
|
||||
field :user, type: BSON::ObjectId
|
||||
field :consent_used, type: Boolean, :default => false
|
||||
field :scored_points, type: Integer, :default => 0
|
||||
field :avg_points, type: Integer
|
||||
field :individual_total, type: Array, :default => []
|
||||
|
|
|
@ -124,7 +124,31 @@
|
|||
<%= f.text_field :redirect_url, :class=>"input-xlarge", :placeholder=>"Redirect URL" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="enable_consent_feature"><%= t('survey.enable_consent_feature') %></label>
|
||||
<div class="controls">
|
||||
<%= f.check_box :enable_consent_feature, :id =>'enable_consent_feature' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group enable_consent_feature <%= 'hide' unless @survey.enable_consent_feature %>">
|
||||
<label class="control-label muted" for="consent_contents"><%= t('survey.consent_contents') %></label>
|
||||
<div class="controls">
|
||||
<div class="tab-content textarea-lang">
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#textarea_<%= locale %>_consent_0" data-toggle="tab"><%= t(locale.to_s) %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<div class="tab-pane fade in <%= ( i == 0 ) ? "active" : '' %>" id="textarea_<%= locale %>_consent_0">
|
||||
<%= f.fields_for :consent_contents_translations do |f| %>
|
||||
<%= f.text_area locale, :class=>'resizable', :value => (@survey.consent_contents_translations[locale] rescue nil), :placeholder => "#{t("survey.consent_contents")}", :rows=>"3" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- questions -->
|
||||
<div class="questions">
|
||||
|
@ -146,4 +170,8 @@
|
|||
$("#questionnaire_survey_needs_login").click(function(){
|
||||
$("#answer_repeat_block").toggleClass("hide");
|
||||
})
|
||||
$("#enable_consent_feature").click(function(){
|
||||
$(".enable_consent_feature").toggleClass("hide");
|
||||
$(".enable_consent_feature .btn.active").click();
|
||||
})
|
||||
</script>
|
|
@ -53,6 +53,11 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="set">
|
||||
<% if @survey_answer.consent_used %>
|
||||
<div class="qa" style="font-size: 1.5em;">
|
||||
<%= t('survey.consent_to_be_used_for_research') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% @survey.survey_questions.each_with_index do |sq, index| %>
|
||||
<div class="qa">
|
||||
<div class="question">
|
||||
|
|
|
@ -52,7 +52,16 @@
|
|||
qnum = 0
|
||||
show_page_url = data["show_page_url"]
|
||||
%>
|
||||
|
||||
<style type="text/css">
|
||||
.survey_consent_contents{
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
@media (max-width: 767px){
|
||||
.survey_consent_contents{
|
||||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<% if @survey.needs_login && current_user.nil? %>
|
||||
<script type="text/javascript">
|
||||
window.location.href = "<%= new_session_path %>";
|
||||
|
@ -82,6 +91,11 @@
|
|||
<%= nl2br(@survey.description) %>
|
||||
</div>
|
||||
<ol class="o-question-list">
|
||||
<% if @survey.enable_consent_feature %>
|
||||
<div class="survey_consent_contents o-question-title">
|
||||
<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>
|
||||
</div>
|
||||
<% end %>
|
||||
<% @questions.each_with_index do |question, i| %>
|
||||
<% header_count = i + 1 %>
|
||||
<% if headers.include?(header_count) %>
|
||||
|
|
|
@ -2,6 +2,10 @@ en:
|
|||
module_name:
|
||||
survey: Survey
|
||||
survey:
|
||||
consent_to_be_used_for_research: "Consent answer to be used for research"
|
||||
agree: Agree
|
||||
consent_contents: '"Consent" contents'
|
||||
enable_consent_feature: 'Enable "Consent" feature'
|
||||
result_score: Result score
|
||||
table: Table
|
||||
result_chart: Result chart
|
||||
|
|
|
@ -4,6 +4,10 @@ zh_tw:
|
|||
survey: 問卷調查
|
||||
|
||||
survey:
|
||||
consent_to_be_used_for_research: "同意填答結果被用於研究"
|
||||
agree: 同意
|
||||
consent_contents: '"同意書"內容'
|
||||
enable_consent_feature: '開啟"同意書"功能'
|
||||
result_score: 結果分數
|
||||
table: 列表
|
||||
result_chart: 結果圖表
|
||||
|
|
Loading…
Reference in New Issue