added custom fields for radio group and added to answer sets. now answer sets can be viewed also for login not required surveys

This commit is contained in:
Harry Bomrah 2016-11-15 19:33:12 +08:00
parent 5c03cf68d0
commit 730d6b896a
7 changed files with 33 additions and 12 deletions

View File

@ -149,10 +149,11 @@ function onQuestionTypeChanged ( $fieldType, _val ){
$fieldType.fadeOut(300);
} else {
$fieldType.fadeIn(300);
if(_val < 5) {
$fieldType.find('.rgl, hr').addClass('hide').siblings('.allow').removeClass('hide');
} else {
$fieldType.find('.rgl, hr').removeClass('hide').siblings('.allow').addClass('hide');
$fieldType.find('.rgl, hr').removeClass('hide').siblings('.allow').removeClass('hide');
}
};
}

View File

@ -159,6 +159,11 @@ class SurveysController < ApplicationController
@answer_model.errors.add question.title, t('survey_question.required_error')
end
end
if question.custom_option
unless answer[oid]["custom_group_field"].blank?
@answer_model[qid]["#{oid}_custom_group_field"] = answer[oid]["custom_group_field"]
end
end
end
individual_total << t
end

View File

@ -40,11 +40,12 @@
<td><%= (survey.postdate) ? (format_value survey.postdate) : t(:no_deadline) %></td>
<td><%= (survey.deadline) ? (format_value survey.deadline) : t(:no_deadline) %></td>
<td>
<% if survey.needs_login %>
<a href="/admin/surveys/<%=survey.id.to_s%>/answer_sets"> <%= survey.survey_answers.count %></a>
<% else %>
<%= survey.survey_answers.count %>
<% end %>
<%# if survey.needs_login %>
<!-- <a href="/admin/surveys/<%=survey.id.to_s%>/answer_sets"> <%#= survey.survey_answers.count %></a> -->
<%# else %>
<%#= survey.survey_answers.count %>
<%# end %>
</td>
<td><%= survey.update_user.user_name rescue ''%></td>
</tr>

View File

@ -69,9 +69,13 @@
<div class="radiogroup">
<% sq.survey_question_options.each do |sqo| %>
<% if !@survey_answer[sq.id.to_s].nil? %>
<% if sq.custom_option %>
<%= @survey_answer[sq.id.to_s]["#{sqo.id}_custom_group_field"].blank? ? sqo.name : @survey_answer[sq.id.to_s]["#{sqo.id}_custom_group_field"] %> : <%= @survey_answer[sq.id.to_s][sqo.id.to_s] %> <br />
<% else %>
<%= sqo.name %> : <%= @survey_answer[sq.id.to_s][sqo.id.to_s] %> <br />
<% end %>
<% end %>
<% end %>
</div>
<% when SurveyQuestion::Oneline, SurveyQuestion::Multiline %>
<%= @survey_answer[sq.id.to_s] rescue "" %>

View File

@ -15,9 +15,9 @@
<% if !user.nil? %>
<td><%= user.name %></td>
<% else %>
<td>&nbsp;</td>
<td>NA</td>
<% end %>
<td><%= sa.created_at.strftime("%y-%M-%d %h:%m") rescue nil %></td>
<td><%= sa.created_at.strftime("%h %d, %Y - %H:%M") rescue nil %></td>
<td><a href="/admin/surveys/<%= sa.id.to_s %>/answer_set"><%= t("survey.view_answers") %></a></td>
</tr>
<% end %>

View File

@ -106,6 +106,9 @@
<thead>
<tr>
<th></th>
<% if question.custom_option %>
<th></th>
<% end %>
<% question.survey_question_radiogroups.each do |radiogroup| %>
<th>
<%= radiogroup.name %>
@ -119,6 +122,13 @@
<th class="o-question-title">
<%= option.name %>
</th>
<% if question.custom_option %>
<%= f.fields_for "#{option.id}" do |oid| %>
<td>
<%= oid.text_field "custom_group_field" %>
</td>
<% end %>
<% end %>
<% question.survey_question_radiogroups.each do |radiogroup| %>
<td>
<%= rgf.radio_button option.id, radiogroup.id %>
@ -147,8 +157,8 @@
<script type="text/javascript">
<% if @survey.jump_mode %>
var answers = <%== @answers.to_json %>;
var jump_tos_map = <%== @jump_tos_map.to_json %>;
var answers = <%= @answers.to_json %>;
var jump_tos_map = <%= @jump_tos_map.to_json %>;
var $current_question = $('.question-item').eq(0);
var current_index = parseInt($current_question.attr('data-index'));
$current_question.removeClass('hide');