学生答完问卷后的显示界面调整,提交问卷时的必答题的判断,新建题目时先不输入标题会提示“标题不能为空”、接着输入标题后依然提示“标题不能为空”

This commit is contained in:
cxt 2016-10-13 11:22:38 +08:00
parent 8b4c02ec98
commit d87e4f368a
9 changed files with 125 additions and 83 deletions

View File

@ -617,9 +617,18 @@ class PollController < ApplicationController
uncomplete_question = [] uncomplete_question = []
necessary_questions.each do |question| necessary_questions.each do |question|
answers = get_user_answer(question,user) answers = get_user_answer(question,user)
if answers.nil? || answers.count < 1 if question.question_type != 4
uncomplete_question << question if answers.nil? || answers.count < 1
uncomplete_question << question
end
else
if answers.nil? || answers.count < question.poll_answers.count
uncomplete_question << question
end
end end
# if answers.nil? || answers.count < 1
# uncomplete_question << question
# end
end end
uncomplete_question uncomplete_question
end end

View File

@ -391,7 +391,7 @@ function insert_MCQ(quest_type,quest_num,quest_id){
if(title.length == 0){ if(title.length == 0){
alert("标题不能为空"); alert("标题不能为空");
doc.one('click', function(){ doc.one('click', function(){
add_poll_question($(this)); add_poll_question_new($(this));
}); });
}else{ }else{
doc.parent().parent().parent().submit(); doc.parent().parent().parent().submit();

View File

@ -1,6 +1,3 @@
<script>
</script>
<div> <div>
<div class="testEditTitle"> <div class="testEditTitle">
第<%= poll_question.question_number%>题: 第<%= poll_question.question_number%>题:

View File

@ -1,26 +1,25 @@
<li class="ur_question_item checkbox"> <div>
<div class="ur_title"> <div class="testEditTitle">
<span class="title_index"> 第<%= poll_question.question_number%>题:
第<%= poll_question.question_number%>题:
</span>
<%= poll_question.question_title %> <%= poll_question.question_title %>
<span class="title_index">[多选题]</span>
<%if poll_question.is_necessary == 1%> <%if poll_question.is_necessary == 1%>
<span class="ur_required" title="必答">*</span> <span class="ur_required" title="必答">*</span>
<%end%> <%end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
<table class="ur_table"> <table class="ur_table" style="width:675px;">
<tbody> <tbody>
<% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%> <% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%>
<tr> <tr>
<td> <td>
<%= answer.poll_answer.answer_text %> <p class="ml20">
<%= answer.poll_answer.answer_text == "" ? (answer.vote_text.nil? ? "其他" : answer.vote_text) : answer.poll_answer.answer_text %>
</p>
</td> </td>
</tr> </tr>
<% end%> <% end%>
</tbody> </tbody>
</table> </table>
</div> </div>
</li><!--多选题 end--> </div><!--多选题 end-->

View File

@ -1,22 +1,21 @@
<li class="ur_question_item radio"> <div>
<div class="ur_title"> <div class="testEditTitle">
<span class="title_index"> 第<%= poll_question.question_number%>题:
第<%= poll_question.question_number%>题:
</span>
<%= poll_question.question_title %> <%= poll_question.question_title %>
<span class="title_index">[单选题]</span>
<%if poll_question.is_necessary == 1%> <%if poll_question.is_necessary == 1%>
<span class="ur_required" title="必答">*</span> <span class="ur_required" title="必答">*</span>
<%end%> <%end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
<table class="ur_table" > <table class="ur_table" style="width:675px;">
<tbody> <tbody>
<% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%> <% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%>
<tr> <tr>
<td> <td>
<%= answer.poll_answer.answer_text %> <p class="ml20">
<%= answer.poll_answer.answer_text == "" ? (answer.vote_text.nil? ? "其他" : answer.vote_text) : answer.poll_answer.answer_text %>
</p>
</td> </td>
</tr> </tr>
<% end%> <% end%>
@ -24,4 +23,4 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</li><!--单选题 end--> </div><!--单选题 end-->

View File

@ -1,20 +1,18 @@
<li class="ur_question_item textarea"> <div>
<div class="ur_preview"> <div class="testEditTitle">
<div class="ur_title"> 第<%= poll_question.question_number%>题:
<span class="title_index"> <%= poll_question.question_title %>
第<%= poll_question.question_number%>题: <%if poll_question.is_necessary == 1%>
</span> <span class="ur_required" title="必答">*</span>
<%= poll_question.question_title %> <%end%>
<span class="title_index">[多行主观]</span> </div>
<%if poll_question.is_necessary == 1%> <div class="cl"></div>
<span class="ur_required" title="必答">*</span> <% poll_question.poll_answers.reorder("answer_position").each_with_index do |poll_answer, i| %>
<%end%> <div class="ml40 mb10">
</div> <p class="mb10"><%= i + 1 %>.<%= poll_answer.answer_text%></p>
<div class="cl"></div> <p class="ml20">
<div class="ur_inputs"> <%= get_anwser_vote_text(poll_question.id,User.current.id,poll_answer.id).html_safe%>
<p> </p>
<%= get_anwser_vote_text(poll_question.id,User.current.id).html_safe%>
</p>
</div>
</div> </div>
</li><!--多行输入 end--> <% end %>
</div>

View File

@ -1,18 +1,15 @@
<li class="ur_question_item text"> <div>
<div class="ur_title"> <div class="testEditTitle">
<span class="title_index"> 第<%= poll_question.question_number%>题:
第<%= poll_question.question_number%>题:
</span>
<%= poll_question.question_title %> <%= poll_question.question_title %>
<span class="title_index">[单行主观]</span>
<%if poll_question.is_necessary == 1%> <%if poll_question.is_necessary == 1%>
<span class="ur_required" title="必答">*</span> <span class="ur_required" title="必答">*</span>
<%end%> <%end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
<p> <p class="ml20">
<%= get_anwser_vote_text poll_question.id,User.current.id%> <%= get_anwser_vote_text poll_question.id,User.current.id%>
</p> </p>
</div> </div>
</li><!--当行输入 end--> </div><!--当行输入 end-->

View File

@ -1,34 +1,57 @@
<%= stylesheet_link_tag 'polls', :media => 'all' %> <%= stylesheet_link_tag 'polls', :media => 'all' %>
<div class="polls_content polls_box break_word"> <div class="homepageRight mt0 ml10">
<div class="ur_page_head" > <div class="resources" >
<h1 class="ur_page_title"> <div class="testStatus">
<%= @poll.polls_name.empty? ? l(:label_poll_new) : @poll.polls_name %> <h1 class="ur_page_title">
</h1> <%= @poll.polls_name.empty? ? l(:label_poll_new) : @poll.polls_name %>
<%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%> </h1>
<div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%></div>
</div>
<% 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="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<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_result', :locals => {:poll_question => poll_question} %>
</div>
</div>
<% end %>
</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_result', :locals => {:poll_question => poll_question} %>
</div>
</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_result', :locals => {:poll_question => poll_question} %>
</div>
</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_result', :locals => {:poll_question => poll_question} %>
</div>
</div>
<% end %>
</div> </div>
<div class="ur_card">
<ol class="ur_questions">
<% @poll_questions.each do |poll_question|%>
<% if poll_question.question_type == 1%>
<%= render :partial => 'show_MC_result', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 2%>
<%= render :partial => 'show_MCQ_result', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%>
<%= render :partial => 'show_single_result', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 4%>
<%= render :partial => 'show_mulit_result', :locals => {:poll_question => poll_question} %>
<% end%>
<% end%>
</ol>
</div> <!--ur_cards end-->
<div class="cl"></div> <div class="cl"></div>
<!-- 分页 -->
<div class="polls_content" id="polls">
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
</div> </div>
</div><!--问卷内容end--> </div><!--问卷内容end-->

View File

@ -18,7 +18,12 @@
<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"><%= l(:label_question_number,:question_number => pq.question_number) %><%= pq.question_title %> <div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
@ -101,7 +106,12 @@
<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"><%= l(:label_question_number,:question_number => pq.question_number) %><%= pq.question_title %> <div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="ur_inputs"> <div class="ur_inputs">
@ -183,7 +193,12 @@
<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"><%= l(:label_question_number,:question_number => pq.question_number) %><%= pq.question_title %> <div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div> <div>
@ -224,7 +239,12 @@
<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"><%= l(:label_question_number,:question_number => pq.question_number) %><%= pq.question_title %> <div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% 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| %>