问卷类型按创建顺序排列

This commit is contained in:
cxt 2016-10-27 10:12:50 +08:00
parent 8cccaba9f3
commit f3d67dc26a
4 changed files with 177 additions and 141 deletions

View File

@ -1,77 +1,29 @@
<% mc_question_list = poll.poll_questions.where("question_type=1") %>
<% mcq_question_list = poll.poll_questions.where("question_type=2") %>
<% single_question_list = poll.poll_questions.where("question_type=3") %>
<% multi_question_list = poll.poll_questions.where("question_type=4") %>
<div class="poll-container" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<div class="pool-tool-bar">
<p class="mt10 mb10">
<span class="questionLabel">1</span>
<span class="c_red questionLabel ml5" title="必答">*</span>
</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>单选题</li>
<li>多选题</li>
<li>单行主观</li>
</ul>
</a>
<a class="poll-delete" title="删除"></a>
</div>
<div class="poll-content">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each do |poll_question| %>
<div id="poll_questions_<%= poll_question.id%>">
<div id="show_poll_questions_<%= poll_question.id %>">
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
</div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
</div>
</div>
<% end %>
</div>
</div>
<div class="testStatus" id="mcq_question_list" style="display: <%=mcq_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each do |poll_question| %>
<div id="poll_questions_<%= poll_question.id%>">
<div id="show_poll_questions_<%= poll_question.id %>">
<%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %>
</div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
<%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %>
</div>
<% poll.poll_questions.each do |poll_question|%>
<div id="poll_questions_<%= poll_question.id%>">
<div id="show_poll_questions_<%= poll_question.id %>">
<% if poll_question.question_type == 1%>
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 2%>
<%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%>
<%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 4%>
<%#= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %>
<% end%>
</div>
<% end %>
</div>
<div class="testStatus" id="single_question_list" style="display: <%=single_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单行主观题</h3>
<% single_question_list.each do |poll_question| %>
<div id="poll_questions_<%= poll_question.id%>">
<div id="show_poll_questions_<%= poll_question.id %>">
<%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %>
</div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
<%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %>
</div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
<% if poll_question.question_type == 1%>
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 2%>
<%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%>
<%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 4%>
<%#= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %>
<% end%>
</div>
<% end %>
</div>
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">多行主观题</h3>
<% multi_question_list.each do |poll_question| %>
<div id="poll_questions_<%= poll_question.id%>">
<div id="show_poll_questions_<%= poll_question.id %>">
<%= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %>
</div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
<%= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
<script>
$(".poll-add").mouseover(function(){

View File

@ -1,39 +1,55 @@
<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="c_red questionLabel ml5" title="必答">*</span>
<%end%>
<div class="poll-container">
<div class="pool-tool-bar">
<p class="mt10 mb10">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<%if poll_question.is_necessary == 1%>
<span class="c_red questionLabel ml5" title="必答">*</span>
<%end%>
</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('mc',<%=poll_question.id%>);insert_MC('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_MCQ('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=poll_question.id%>);insert_SINGLE('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
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>
<%= 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_mc_<%=poll_question.id%>" onclick="dismiss('mc',<%=poll_question.id%>);insert_MC('mc',<%=poll_question.question_number%>,<%=poll_question.id%>);"></a>
<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>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<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-->
<!-- 新增问题 -->

View File

@ -1,39 +1,54 @@
<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_mcq_<%=poll_question.id%>" onclick="dismiss('mcq',<%=poll_question.id%>);insert_MCQ('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs" style="width:675px;">
<table class="ur_table" style="width:675px;">
<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="checkbox" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
<%= poll_answer.answer_text%>
</label>
<% else %>
<label>
<input class="ur_radio" name="<%= poll_question %>" value="" type="checkbox">
</label>
<input placeholder="其它" readonly="readonly" class="disabled questionnaire-input w300" type="text">
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="poll-container">
<div class="pool-tool-bar">
<p class="mt10 mb10">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<%if poll_question.is_necessary == 1%>
<span class="c_red questionLabel ml5" title="必答">*</span>
<%end%>
</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('mcq',<%=poll_question.id%>);insert_MC('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_MCQ('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mcq',<%=poll_question.id%>);insert_SINGLE('mcq',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
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>
<div class="cl"></div>
<div class="ur_inputs" style="width:675px;">
<table class="ur_table" style="width:675px;">
<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="checkbox" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
<%= poll_answer.answer_text%>
</label>
<% else %>
<label>
<input class="ur_radio" name="<%= poll_question %>" value="" type="checkbox">
</label>
<input placeholder="其它" readonly="readonly" class="disabled questionnaire-input w300" type="text">
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div><!--多选题显示 end-->
<!-- 新增问题 -->
<div id="insert_new_poll_question_mcq_<%=poll_question.id%>">

View File

@ -1,3 +1,56 @@
<div class="poll-container">
<div class="pool-tool-bar">
<p class="mt10 mb10">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<%if poll_question.is_necessary == 1%>
<span class="c_red questionLabel ml5" title="必答">*</span>
<%end%>
</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('single',<%=poll_question.id%>);insert_MC('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_MCQ('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('single',<%=poll_question.id%>);insert_SINGLE('single',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
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>
<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>