<% data = action_data @survey = data["survey"] @user = data["user"] @survey_answers = data["survey_answers"] @table_fields = data["table_fields"] @is_answer_list = data["is_answer_list"] %> <% if @user.nil? %>

"><%=t("survey.please_login_first")%>

<% else %>

<%= @survey.title %>

<%=t('survey.taken_by')%>: <%=@user.member_name%>

<% if @is_answer_list %> <% type = 'result_chart' if params[:type] == 'result_chart' %>
<%=t("survey.table")%> <%=t("survey.result_chart")%>
<% end %> <% if type == "result_chart" %>
<%= javascript_include_tag "survey/jquery.colorhelpers.js" %> <%= javascript_include_tag "survey/jquery.canvaswrapper.js" %> <%= javascript_include_tag "survey/jquery.flot_3.0.js" %> <%= javascript_include_tag "survey/jquery.flot.time.min.js" %> <%= javascript_include_tag "survey/jquery.flot.uiConstants.js" %> <%= javascript_include_tag "survey/jquery.flot.saturated.js" %> <%= javascript_include_tag "survey/jquery.flot.browser.js" %> <%= javascript_include_tag "survey/jquery.flot.drawSeries.js" %> <%= javascript_include_tag "survey/jquery.flot.axislabels.js" %> <%= javascript_include_tag "survey/jquery.flot.hover.js" %> <%= javascript_include_tag "survey/jquery.flot.animator.min.js" %> <%= javascript_include_tag "survey/moment.min.js" %> <% else %> <% @table_fields.each do |f| %> <%= thead(f) %> <% end %> <% (@survey_answer_groups || @survey_answers).each do |sa| %> <% user = sa.user.nil? ? nil : (User.find(sa.user) rescue nil) %> <% if !user.nil? %> <% else %> <% end %> <% end %>
<%= user.member_name rescue user.name %>NA<%= (@is_answer_list ? sa.updated_at : sa.last_modified).strftime("%h %d, %Y - %H:%M") rescue nil %> <% if @answer_repeat && !@is_answer_list %> "><%= t("survey.view") %>(<%=sa.survey_answer_ids.count%>) <% else %> <% if @survey.result_type == QuestionnaireSurvey::ResultCriteria %> <% tmp_msgs = [] answer_model_attrs = sa.attributes weight_relations = @survey.survey_questions.map{|q| [q.id.to_s,(q.weight.nil? ? 1 : q.weight)]}.to_h types = [] %> <% @survey.result_criteria.each do |criteria| %> <% total_criteria_score = 0 total_weight = 0 ((criteria["questions"][0].to_i - 1)..(criteria["questions"][1].to_i - 1)).each do |x| total_criteria_score = (total_criteria_score + sa.individual_total[x].to_i) rescue 0 k = weight_relations.keys[x] if k && answer_model_attrs.has_key?(k) total_weight += weight_relations[k] end end type = criteria["type"].to_i %> <% if type == 0 %> <% if (criteria["range"][0].to_i..criteria["range"][1].to_i).cover?(total_criteria_score) %> <% tmp_msgs << criteria["msg"] %> <% types << type %> <% end %> <% else %> <% if ((criteria["range"][0].to_i..criteria["range"][1].to_i).cover?(total_criteria_score / total_weight) rescue false) %> <% tmp_msgs << criteria["msg"] %> <% types << type %> <% end %> <% end %> <% end %> <% if types.include?(0) %>

Your total score is <%= sa.scored_points %>

<% end %> <% if types.include?(1) %>

Your average score is <%= sa.get_avg_points %>

<% end %> <% tmp_msgs.each do |msg| %>
<%=msg.html_safe%>
<% end %> <% else %> "><%= t("survey.view_answers") %> <% end %> <% end %>
<%= create_pagination((@survey_answer_groups || @survey_answers).total_pages).html_safe %> <% end %> <% end %>