From 54c8ee9d4d29ab264c3baa3deebd345ca0aabe3a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 21 Jan 2015 17:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=A6=E7=94=9F=E7=AD=94?= =?UTF-8?q?=E5=AE=8C=E9=97=AE=E5=8D=B7=E4=B9=8B=E5=90=8E=E3=80=82=E8=83=BD?= =?UTF-8?q?=E7=9C=8B=E5=88=B0=E8=87=AA=E5=B7=B1=E7=AD=94=E9=A2=98=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 12 +++++-- app/helpers/poll_helper.rb | 2 +- app/views/poll/_poll.html.erb | 11 +++---- app/views/poll/_show_MCQ_result.html.erb | 26 +++++++++++++++ app/views/poll/_show_MC_result.html.erb | 27 ++++++++++++++++ app/views/poll/_show_mulit_result.html.erb | 20 ++++++++++++ app/views/poll/_show_single_result.html.erb | 18 +++++++++++ app/views/poll/poll_result.html.erb | 36 +++++++++++++++++++++ config/routes.rb | 1 + 9 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 app/views/poll/_show_MCQ_result.html.erb create mode 100644 app/views/poll/_show_MC_result.html.erb create mode 100644 app/views/poll/_show_mulit_result.html.erb create mode 100644 app/views/poll/_show_single_result.html.erb create mode 100644 app/views/poll/poll_result.html.erb diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 42ab98e10..4abddaa5e 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -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] diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 17ef02a36..60d82c096 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -73,5 +73,5 @@ module PollHelper "多行主观题" end end - + end \ No newline at end of file diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 3290ff2dc..c53f09361 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -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%>
  • <% if @is_teacher %> <% if has_commit %> - <%= 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;" %> <% 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 %> - - <%= 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: 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 %>
  • diff --git a/app/views/poll/_show_MCQ_result.html.erb b/app/views/poll/_show_MCQ_result.html.erb new file mode 100644 index 000000000..f46882881 --- /dev/null +++ b/app/views/poll/_show_MCQ_result.html.erb @@ -0,0 +1,26 @@ +
  • +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [多选题] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    + + + <% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%> + + + + <% end%> + +
    + <%= answer.poll_answer.answer_text %> +
    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/_show_MC_result.html.erb b/app/views/poll/_show_MC_result.html.erb new file mode 100644 index 000000000..7f2cbbd83 --- /dev/null +++ b/app/views/poll/_show_MC_result.html.erb @@ -0,0 +1,27 @@ +
  • +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [单选题] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    + + + <% poll_question.poll_votes.where("user_id = #{User.current.id}").each do |answer|%> + + + + <% end%> + + +
    + <%= answer.poll_answer.answer_text %> +
    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/_show_mulit_result.html.erb b/app/views/poll/_show_mulit_result.html.erb new file mode 100644 index 000000000..e54cca505 --- /dev/null +++ b/app/views/poll/_show_mulit_result.html.erb @@ -0,0 +1,20 @@ +
  • +
    +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [多行主观] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    +

    + <%= get_anwser_vote_text poll_question.id,User.current.id%> +

    +
    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/_show_single_result.html.erb b/app/views/poll/_show_single_result.html.erb new file mode 100644 index 000000000..07559773d --- /dev/null +++ b/app/views/poll/_show_single_result.html.erb @@ -0,0 +1,18 @@ +
  • +
    + + 第<%= poll_question.question_number%>题: + + <%= poll_question.question_title %> + [单行主观] + <%if poll_question.is_necessary == 1%> + * + <%end%> +
    +
    +
    +

    + <%= get_anwser_vote_text poll_question.id,User.current.id%> +

    +
    +
  • \ No newline at end of file diff --git a/app/views/poll/poll_result.html.erb b/app/views/poll/poll_result.html.erb new file mode 100644 index 000000000..a7cb415b3 --- /dev/null +++ b/app/views/poll/poll_result.html.erb @@ -0,0 +1,36 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> +
    +
    +

    + <%= @poll.polls_name.empty? ? l(:label_poll_new) : @poll.polls_name %> +

    +

    + <%= @poll.polls_description%> +

    +
    +
    +
      + <% @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%> +
    +
    +
    + + +
    + +
    +
    +
    + diff --git a/config/routes.rb b/config/routes.rb index 67b0118b0..524373378 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'