问卷调查显示页面的调整

This commit is contained in:
cxt 2016-10-27 10:55:12 +08:00
parent f3d67dc26a
commit 5d7af65bac
4 changed files with 326 additions and 352 deletions

View File

@ -7,8 +7,8 @@
<%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %> <%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%> <% elsif poll_question.question_type == 3%>
<%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %> <%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 4%> <% elsif poll_question.question_type == 4%>
<%#= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %> <%= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %>
<% end%> <% end%>
</div> </div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;"> <div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
@ -18,8 +18,8 @@
<%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %> <%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%> <% elsif poll_question.question_type == 3%>
<%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %> <%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 4%> <% elsif poll_question.question_type == 4%>
<%#= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %> <%= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %>
<% end%> <% end%>
</div> </div>
</div> </div>

View File

@ -1,15 +1,30 @@
<div> <div class="poll-container">
<div class="testEditTitle"> <div class="pool-tool-bar">
<p class="mt10 mb10">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span> <span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
<%if poll_question.is_necessary == 1%> <%if poll_question.is_necessary == 1%>
<span class="ur_required questionLabel ml5" title="必答">*</span> <span class="c_red questionLabel ml5" title="必答">*</span>
<%end%> <%end%>
</div> </p>
<a class="poll-up mb8" title="上移"></a>
<a class="poll-down mb8" title="下移"></a>
<a href="javascript:void(0);" class="poll-add pr mb8">
<ul class="poll-add-menu fontGrey3">
<li><a href="javascript:void(0);" onclick=" dismiss('mulit',<%=poll_question.id%>);insert_MC('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mulit',<%=poll_question.id%>);insert_MCQ('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mulit',<%=poll_question.id%>);insert_SINGLE('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %>
</div>
<div class="poll-content">
<div class="testEditTitle">
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
<span class="fontBlue">[多行主观题]</span>
</div>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a> <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mulit_<%=poll_question.id%>" onclick="dismiss('mulit',<%=poll_question.id%>);insert_MULIT('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);"></a>
<div class="cl"></div> <div class="cl"></div>
<% poll_question.poll_answers.reorder("answer_position").each_with_index do |poll_answer, i| %> <% poll_question.poll_answers.reorder("answer_position").each_with_index do |poll_answer, i| %>
<div class="ml40 mb10"> <div class="ml40 mb10">
@ -17,6 +32,7 @@
<input type="text" class="questionnaire-input" name="<%= poll_question %>" style="width:652px;" /> <input type="text" class="questionnaire-input" name="<%= poll_question %>" style="width:652px;" />
</div> </div>
<% end %> <% end %>
</div>
</div><!--多行展示 end--> </div><!--多行展示 end-->
<!-- 新增问题 --> <!-- 新增问题 -->
<div id="insert_new_poll_question_mulit_<%=poll_question.id%>"> <div id="insert_new_poll_question_mulit_<%=poll_question.id%>">

View File

@ -26,47 +26,10 @@
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a> <a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:647px;">
<tbody>
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
<tr>
<td>
<% if poll_answer.answer_text != '' %>
<label>
<input class="ur_radio" type="radio" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
<%= poll_answer.answer_text%>
</label>
<% else %>
<label>
<input class="ur_radio" name="<%= poll_question %>" value="" type="radio">
</label>
<input placeholder="其它" readonly="readonly" class="disabled questionnaire-input w300" type="text">
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div><!--单选题显示 end-->
<div>
<div class="testEditTitle">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
<%if poll_question.is_necessary == 1%>
<span class="ur_required questionLabel ml5" title="必答">*</span>
<%end%>
</div>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_single_<%=poll_question.id%>" onclick="dismiss('single',<%=poll_question.id%>);insert_SINGLE('single',<%=poll_question.question_number%>,<%=poll_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
<input class="questionnaire-input" type="text" size="" maxlength="" value="" style="width:692px;"> <input class="questionnaire-input" type="text" size="" maxlength="" value="" style="width:692px;">
</div> </div>
</div>
</div><!--单行文字展示 end--> </div><!--单行文字展示 end-->
<!-- 新增问题 --> <!-- 新增问题 -->
<div id="insert_new_poll_question_single_<%=poll_question.id%>"> <div id="insert_new_poll_question_single_<%=poll_question.id%>">

View File

@ -5,22 +5,21 @@
<h1 class="ur_page_title"> <h1 class="ur_page_title">
<%= @poll.polls_name %> <%= @poll.polls_name %>
</h1> </h1>
<div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe %></div> <div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe %></div>
</div> </div>
<% mc_question_list = @poll.poll_questions.where("question_type=1") %> <% @poll_questions.each do |pq| %>
<% mcq_question_list = @poll.poll_questions.where("question_type=2") %> <% if pq.question_type == 1 %>
<% single_question_list = @poll.poll_questions.where("question_type=3") %> <!-- 单选题 -->
<% multi_question_list = @poll.poll_questions.where("question_type=4") %> <div class="testStatus">
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each_with_index do |pq, list_index| %>
<div id="poll_questions_<%= pq.id %>"> <div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>"> <div id="show_poll_questions_<%= pq.id %>">
<div> <div>
<div class="testEditTitle"> <div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %> <%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %> <%= pq.question_title %>
<span class="fontBlue">[单选题]</span>
<% if pq.is_necessary == 1 %> <% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span> <span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %> <% end %>
@ -34,8 +33,7 @@
<td> <td>
<label> <label>
<script> <script>
function onblur_<%= pa.id %>(obj) function onblur_<%= pa.id %>(obj) {
{
$(window).unbind('beforeunload'); $(window).unbind('beforeunload');
$.ajax({ $.ajax({
type: "post", type: "post",
@ -53,8 +51,7 @@
} }
}); });
} }
function click_<%= pa.id %>(obj) function click_<%= pa.id %>(obj) {
{
$.ajax({ $.ajax({
type: "post", type: "post",
url: "<%= commit_answer_poll_path(@poll) %>", url: "<%= commit_answer_poll_path(@poll) %>",
@ -64,14 +61,12 @@
}, },
success: function (data) { success: function (data) {
var dataObj = eval(data); var dataObj = eval(data);
if(dataObj.text == "ok") if (dataObj.text == "ok") {
{
obj.checked = true; obj.checked = true;
$(obj).parent().parent().parent().parent().find("input[type='text']").attr("disabled", "disabled"); $(obj).parent().parent().parent().parent().find("input[type='text']").attr("disabled", "disabled");
$(obj).next('input').removeAttr("disabled"); $(obj).next('input').removeAttr("disabled");
} }
else else {
{
obj.checked = false; obj.checked = false;
$(obj).next('input').attr("disabled", "disabled"); $(obj).next('input').attr("disabled", "disabled");
} }
@ -100,17 +95,17 @@
</div> </div>
</div> </div>
</div> </div>
<% end %>
</div> </div>
<div class="testStatus" id="mcq_question_list" style="display: <%=mcq_question_list.count > 0 ? "" : "none" %>"> <% elsif pq.question_type == 2 %>
<h3 class="fontGrey3">多选题</h3> <!-- 多选题 -->
<% mcq_question_list.each do |pq| %> <div class="testStatus">
<div id="poll_questions_<%= pq.id %>"> <div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>"> <div id="show_poll_questions_<%= pq.id %>">
<div> <div>
<div class="testEditTitle"> <div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %> <%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %> <%= pq.question_title %>
<span class="fontBlue">[多选题]</span>
<% if pq.is_necessary == 1 %> <% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span> <span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %> <% end %>
@ -124,8 +119,7 @@
<td> <td>
<label> <label>
<script> <script>
function onblur_<%= pa.id %>(obj) function onblur_<%= pa.id %>(obj) {
{
$(window).unbind('beforeunload'); $(window).unbind('beforeunload');
$.ajax({ $.ajax({
type: "post", type: "post",
@ -143,8 +137,7 @@
} }
}); });
} }
function click_<%= pa.id %>(obj) function click_<%= pa.id %>(obj) {
{
$.ajax({ $.ajax({
type: "post", type: "post",
url: "<%= commit_answer_poll_path(@poll) %>", url: "<%= commit_answer_poll_path(@poll) %>",
@ -154,13 +147,11 @@
}, },
success: function (data) { success: function (data) {
var dataObj = eval(data); var dataObj = eval(data);
if(dataObj.text == "ok") if (dataObj.text == "ok") {
{
obj.checked = true; obj.checked = true;
$(obj).next('input').removeAttr("disabled"); $(obj).next('input').removeAttr("disabled");
} }
else else {
{
obj.checked = false; obj.checked = false;
$(obj).next('input').attr("disabled", "disabled"); $(obj).next('input').attr("disabled", "disabled");
} }
@ -186,20 +177,21 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div><!--多选题显示 end--> </div>
<!--多选题显示 end-->
</div> </div>
</div> </div>
<% end %>
</div> </div>
<div class="testStatus" id="single_question_list" style="display: <%=single_question_list.count > 0 ? "" : "none" %>"> <% elsif pq.question_type == 3 %>
<h3 class="fontGrey3">单行主观题</h3> <!-- 单行文字-->
<% single_question_list.each do |pq| %> <div class="testStatus">
<div id="poll_questions_<%= pq.id %>"> <div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>"> <div id="show_poll_questions_<%= pq.id %>">
<div> <div>
<div class="testEditTitle"> <div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %> <%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %> <%= pq.question_title %>
<span class="fontBlue">[主观题]</span>
<% if pq.is_necessary == 1 %> <% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span> <span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %> <% end %>
@ -207,8 +199,7 @@
<div class="cl"></div> <div class="cl"></div>
<div> <div>
<script> <script>
function onblur_<%= pq.id %>(obj) function onblur_<%= pq.id %>(obj) {
{
$(window).unbind('beforeunload'); $(window).unbind('beforeunload');
var val = $(obj).val().trim(); var val = $(obj).val().trim();
if (val != "") { if (val != "") {
@ -237,27 +228,26 @@
</div> </div>
</div> </div>
</div> </div>
<% end %>
</div> </div>
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>"> <% elsif pq.question_type == 4 %>
<h3 class="fontGrey3">多行主观题</h3> <!-- 多行文字-->
<% multi_question_list.each do |pq| %> <div class="testStatus">
<div id="poll_questions_<%= pq.id %>"> <div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>"> <div id="show_poll_questions_<%= pq.id %>">
<div> <div>
<div class="testEditTitle"> <div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %> <%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %> <%= pq.question_title %>
<span class="fontBlue">[多行主观题]</span>
<% if pq.is_necessary == 1 %> <% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span> <span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %> <% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<% pq.poll_answers.each_with_index do |pa, i| %> <% pq.poll_answers.each_with_index do |pa, i| %>
<div class="ml40 mb10"> <div class="ml20 mb10">
<script> <script>
function onblur_<%= pa.id %>(obj) function onblur_<%= pa.id %>(obj) {
{
$(window).unbind('beforeunload'); $(window).unbind('beforeunload');
var val = $(obj).val().trim(); var val = $(obj).val().trim();
if (val != "") { if (val != "") {
@ -283,14 +273,18 @@
} }
</script> </script>
<p class="mb10"><%= i + 1 %>.<%= pa.answer_text %></p> <p class="mb10"><%= i + 1 %>.<%= pa.answer_text %></p>
<input class="questionnaire-input" placeholder="在此填入答案" style="width: 93%" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>> <input class="questionnaire-input" placeholder="在此填入答案" style="width: 99%" type="text" value="<%= get_anwser_vote_text(pq.id, User.current.id, pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll ? "" : "disabled=disabled" %>>
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
<% end %>
</div> </div>
<% else %>
<!-- 未知题型 -->
<% end %>
<% end %>
<div class="ur_buttons" style="width: 77px;"> <div class="ur_buttons" style="width: 77px;">
<% if @poll.polls_status == 2 %> <% if @poll.polls_status == 2 %>
<%= link_to l(:button_submit), commit_poll_poll_path(@poll), :method => :post, :class => "BlueCirBtn", :format => 'js', :remote => true %> <%= link_to l(:button_submit), commit_poll_poll_path(@poll), :method => :post, :class => "BlueCirBtn", :format => 'js', :remote => true %>
@ -303,5 +297,6 @@
<span id="percent"><%= format "%.2f", @percent %></span>% <span id="percent"><%= format "%.2f", @percent %></span>%
</strong> </strong>
</div> </div>
</div><!--问卷内容end--> </div>
<!--问卷内容end-->
</div> </div>