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

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 = []
necessary_questions.each do |question|
answers = get_user_answer(question,user)
if question.question_type != 4
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
# if answers.nil? || answers.count < 1
# uncomplete_question << question
# end
end
uncomplete_question
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,33 +1,56 @@
<%= stylesheet_link_tag 'polls', :media => 'all' %>
<div class="polls_content polls_box break_word">
<div class="ur_page_head" >
<div class="homepageRight mt0 ml10">
<div class="resources" >
<div class="testStatus">
<h1 class="ur_page_title">
<%= @poll.polls_name.empty? ? l(:label_poll_new) : @poll.polls_name %>
</h1>
<%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%>
<div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%></div>
</div>
<div class="ur_card">
<ol class="ur_questions">
<% @poll_questions.each do |poll_question|%>
<% if poll_question.question_type == 1%>
<% 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} %>
<% elsif poll_question.question_type == 2%>
</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} %>
<% elsif poll_question.question_type == 3%>
</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} %>
<% elsif poll_question.question_type == 4%>
</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} %>
<% end%>
<% end%>
</ol>
</div> <!--ur_cards end-->
<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>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>
</div><!--问卷内容end-->

View File

@ -18,7 +18,12 @@
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<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 class="cl"></div>
<div class="ur_inputs">
@ -101,7 +106,12 @@
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<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 class="cl"></div>
<div class="ur_inputs">
@ -183,7 +193,12 @@
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<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 class="cl"></div>
<div>
@ -224,7 +239,12 @@
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<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 class="cl"></div>
<% pq.poll_answers.each_with_index do |pa, i| %>