From 7b9d88ecfeefd465be895efb398d961e6782be8b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 20 Jan 2015 11:42:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E8=B0=83=E6=9F=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E6=96=B0=E5=8F=91=E5=B8=83=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 20 +++++++++++-- app/views/poll/_poll.html.erb | 43 ++++++++++++++++++++++++++++ app/views/poll/index.html.erb | 39 +------------------------ app/views/poll/republish_poll.js.erb | 1 + config/routes.rb | 1 + 5 files changed, 63 insertions(+), 41 deletions(-) create mode 100644 app/views/poll/_poll.html.erb create mode 100644 app/views/poll/republish_poll.js.erb diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 739adfe1c..6890b8dd7 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,8 +1,8 @@ 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] + 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_container, :only => [:new,:create, :index] before_filter :is_member_of_course, :only => [:index,:show] - before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll] + before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll] include PollHelper def index if @course @@ -311,6 +311,19 @@ class PollController < ApplicationController end end + #重新发布问卷 + def republish_poll + @poll.poll_questions.each do |poll_question| + poll_question.poll_votes.destroy_all + end + @poll.poll_users.destroy_all + @poll.polls_status = 1 + @poll.save + respond_to do |format| + format.js + end + end + private def find_poll_and_course @poll = Poll.find params[:id] @@ -337,7 +350,8 @@ class PollController < ApplicationController end def is_course_teacher - render_403 unless(@course && User.current.allowed_to?(:as_teacher,@course)) + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + render_403 unless(@course && @is_teacher) end #获取未完成的题目 diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb new file mode 100644 index 000000000..8ae766516 --- /dev/null +++ b/app/views/poll/_poll.html.erb @@ -0,0 +1,43 @@ +
  • + <% if @is_teacher %> + <% if has_commit_poll?(poll.id ,User.current) %> + <%= poll.polls_name %> + <% else %> + <%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %> + <% end %> + <% else %> + <% if has_commit_poll?(poll.id ,User.current) && poll.polls_status == 2 %> + + <%= poll.polls_name %> + + <% elsif (!has_commit_poll?(poll.id ,User.current)) && poll.polls_status == 2 %> + <%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %> + <% end %> + <% end %> +
  • +
  • + <%if @is_teacher && poll.polls_status == 2%> + <%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%> + <% end%> +
  • +
  • + <% if @is_teacher %> + + <%= link_to(l(:button_delete), poll, + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml20 mr10") %> + <% end%> +
  • +
  • + <% if @is_teacher && poll.polls_status == 1%> + + <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%> + <% end%> +
  • +
  • + <% if @is_teacher && poll.polls_status == 2%> + <%= link_to "重新发布", republish_poll_poll_path(poll.id), :remote => true, :class => 'polls_de fr ml20' %> + <% end %> +
  • +
  • + <%= format_time poll.created_at%> +
  • \ No newline at end of file diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index e57674c7a..fa378fc7b 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -12,44 +12,7 @@
    <% @polls.each do |poll|%>
    <% end%> diff --git a/app/views/poll/republish_poll.js.erb b/app/views/poll/republish_poll.js.erb new file mode 100644 index 000000000..a7399af5b --- /dev/null +++ b/app/views/poll/republish_poll.js.erb @@ -0,0 +1 @@ +$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bd1b27dee..67b0118b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,6 +65,7 @@ RedmineApp::Application.routes.draw do post 'create_poll_question' post 'commit_poll' get 'publish_poll' + get 'republish_poll' end collection do delete 'delete_poll_question' From 77cb2b08934bc5569c0e702db6ab06978665808f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 20 Jan 2015 16:50:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=B7=B2=E5=AE=8C=E6=88=90=E7=9A=84=E9=97=AE=E5=8D=B7=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E8=BF=87=E9=95=BF=E6=97=B6=E6=98=BE=E7=A4=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=202.=E5=A2=9E=E5=8A=A0=E5=8F=96=E6=B6=88=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=B6=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll.html.erb | 4 ++- app/views/poll/_poll_republish.html.erb | 44 +++++++++++++++++++++++++ app/views/poll/index.html.erb | 27 +++++++++++++++ public/stylesheets/polls.css | 2 +- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 app/views/poll/_poll_republish.html.erb diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 8ae766516..dea4e175b 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -35,7 +35,9 @@
  • <% if @is_teacher && poll.polls_status == 2%> - <%= link_to "重新发布", republish_poll_poll_path(poll.id), :remote => true, :class => 'polls_de fr ml20' %> + + 取消发布 + <% end %>
  • diff --git a/app/views/poll/_poll_republish.html.erb b/app/views/poll/_poll_republish.html.erb new file mode 100644 index 000000000..3688ba883 --- /dev/null +++ b/app/views/poll/_poll_republish.html.erb @@ -0,0 +1,44 @@ + + + + + + + +
    +
    +
    +

    + 问卷取消发布后学生提交的问卷答案将会被清空, +
    + 是否确定取消发布该问卷? +

    +
    + <%= link_to "确 定",republish_poll_poll_path(poll.id), :class => "upload_btn", :onclick => "clickCanel();" %> + + 取  消 + +
    +
    +
    + +
    + +
    + + + diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index fa378fc7b..043e6898b 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -1,4 +1,31 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> +

    所有问卷 diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 58ae913b0..4141164c4 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -27,7 +27,7 @@ a.newbtn{ float:right; display:block; width:80px; height:30px; background:#64bdd a:hover.newbtn{ background:#55a1b9; text-decoration:none;} .polls_list ul{ padding-left:10px; border-bottom:1px dashed #c9c9c9; height:32px; padding-top:8px;} a.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 350px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;} -.polls_title{ font-weight:bold; color:#3e6d8e;} +.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 350px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;} a.pollsbtn{ display:block; width:66px; height:22px; text-align:center; border:1px solid #64bdd9; color:#64bdd9;} a:hover.pollsbtn{ background:#64bdd9; color:#fff; text-decoration:none;} .polls_date{ color:#666666;} From f3062da237ba7a010bc708a1a119a3ab4149b93c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 21 Jan 2015 09:18:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=EF=BC=8C=E8=AF=BE=E7=A8=8B=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BD(=E5=B1=85=E7=84=B6?= =?UTF-8?q?=E6=98=AF=E6=AD=BB=E5=BE=AA=E7=8E=AF=E3=80=82=E3=80=82=E3=80=82?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/course.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 927734b24..d427a9aea 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -122,6 +122,7 @@ else course_term = "春季学期" end%> + <%break if Time.new.strftime("%Y").to_i - year_now >= 2%> <% all_new_hot_course += find_all_new_hot_course(course_count-all_new_hot_course.count, @school_id, year_now, course_term)%> <% end%> <%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %> @@ -152,6 +153,7 @@ else course_term = "春季学期" end%> + <%break if Time.new.strftime("%Y").to_i - year_now >= 2%> <% all_new_hot_course += find_all_new_hot_course(9-(all_new_hot_course.count + cur_school_course.count), @school_id, year_now, course_term)%> <% end%> <%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %>