增加学生答完问卷之后。能看到自己答题结果的功能

This commit is contained in:
sw 2015-01-21 17:51:12 +08:00
parent 6193c6c558
commit 54c8ee9d4d
9 changed files with 144 additions and 9 deletions

View File

@ -1,7 +1,7 @@
class PollController < ApplicationController
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll]
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result]
before_filter :find_container, :only => [:new,:create, :index]
before_filter :is_member_of_course, :only => [:index,:show]
before_filter :is_member_of_course, :only => [:index,:show,:poll_result]
before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll]
include PollHelper
def index
@ -330,6 +330,14 @@ class PollController < ApplicationController
end
end
#显示某个学生某份问卷的填写结果
def poll_result
@poll_questions = paginateHelper @poll.poll_questions,5
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
end
private
def find_poll_and_course
@poll = Poll.find params[:id]

View File

@ -73,5 +73,5 @@ module PollHelper
"多行主观题"
end
end
end

View File

@ -1,20 +1,19 @@
<% has_commit = has_commit_poll?(poll.id ,User.current)%>
<% poll_name = poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%>
<li title="<%= poll.polls_name %>">
<% if @is_teacher %>
<% if has_commit %>
<sapn class="polls_title fl">
<%= poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%>
<%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 550px;width: 550px;" %>
</sapn>
<% else %>
<%= link_to (poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name), poll_path(poll.id), :class => "polls_title polls_title_w fl" %>
<%= link_to poll_name, poll_path(poll.id), :class => "polls_title polls_title_w fl" %>
<% end %>
<% else %>
<% if has_commit && poll.polls_status == 2 %>
<sapn class="polls_title fl" style="max-width: 500px;">
<%= poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name %>
</sapn>
<%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 500px;width: auto;" %>
<% elsif !has_commit && poll.polls_status == 2 %>
<%= link_to (poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name), poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 550px;width: 550px;" %>
<%= link_to poll_name, poll_path(poll.id), :class => "polls_title polls_title_w fl", :style => "max-width: 550px;width: 550px;" %>
<% end %>
<% end %>
</li>

View File

@ -0,0 +1,26 @@
<li class="ur_question_item checkbox">
<div class="ur_title">
<span class="title_index">
第<%= 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">
<tbody>
<% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%>
<tr>
<td>
<%= answer.poll_answer.answer_text %>
</td>
</tr>
<% end%>
</tbody>
</table>
</div>
</li><!--多选题 end-->

View File

@ -0,0 +1,27 @@
<li class="ur_question_item radio">
<div class="ur_title">
<span class="title_index">
第<%= 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" >
<tbody>
<% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%>
<tr>
<td>
<%= answer.poll_answer.answer_text %>
</td>
</tr>
<% end%>
</tbody>
</table>
</div>
</li><!--单选题 end-->

View File

@ -0,0 +1,20 @@
<li class="ur_question_item textarea">
<div class="ur_preview">
<div class="ur_title">
<span class="title_index">
第<%= 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%>
</p>
</div>
</div>
</li><!--多行输入 end-->

View File

@ -0,0 +1,18 @@
<li class="ur_question_item text">
<div class="ur_title">
<span class="title_index">
第<%= 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%>
</p>
</div>
</li><!--当行输入 end-->

View File

@ -0,0 +1,36 @@
<%= stylesheet_link_tag 'polls', :media => 'all' %>
<div class="polls_content polls_box">
<div class="ur_page_head" >
<h1 class="ur_page_title">
<%= @poll.polls_name.empty? ? l(:label_poll_new) : @poll.polls_name %>
</h1>
<p class="ur_prefix_content">
<%= @poll.polls_description%>
</p>
</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="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><!--问卷内容end-->

View File

@ -66,6 +66,7 @@ RedmineApp::Application.routes.draw do
post 'commit_poll'
get 'publish_poll'
get 'republish_poll'
get 'poll_result'
end
collection do
delete 'delete_poll_question'