From 97c7ccac1627286f489c43cab4ca428d7d5a5dbf Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 27 Jan 2015 09:45:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E9=97=AD=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=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 | 14 +++++- app/views/poll/_poll.html.erb | 69 ++++++++++++++++++++---------- app/views/poll/close_poll.js.erb | 2 + app/views/poll/index.html.erb | 24 +++++++++++ config/routes.rb | 1 + public/stylesheets/polls.css | 4 +- 6 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 app/views/poll/close_poll.js.erb diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 8926c0be6..d49694e6f 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,:republish_poll,:poll_result] + 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,:close_poll] before_filter :find_container, :only => [:new,:create, :index] 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] + before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll] include PollHelper def index if @course @@ -339,6 +339,16 @@ class PollController < ApplicationController end end + #关闭问卷 + def close_poll + @poll.polls_status = 3 + if @poll.save + respond_to do |format| + format.js + end + end + end + private def find_poll_and_course @poll = Poll.find params[:id] diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 1bf6b3716..fdf534405 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -22,7 +22,7 @@ <% end %> <%if @is_teacher%> - <% if poll.polls_status == 1 %> + <% if poll.polls_status == 1 || poll.polls_status == 3 %>
  • 统计结果
  • <% elsif poll.polls_status == 2%>
  • @@ -31,38 +31,61 @@ <% end%> <% end%> -
  • - <%if @is_teacher %> + +<%if @is_teacher %> <% if poll.polls_status == 1 %> - 发布问卷 +
  • + + 发布问卷 + +
  • <% elsif poll.polls_status == 2%> - 取消发布 +
  • + + 取消发布 + +
  • + <% else%> +
  • + 发布问卷 +
  • <% end%> - <% end%> - +<% 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") %> + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml15 mr10") %> <% end%>
  • -
  • - <% if @is_teacher%> - <% if poll.polls_status == 1 %> - <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%> - <% elsif poll.polls_status == 2%> -
  • 编辑
  • - <% end%> + +<% if @is_teacher%> + <% if poll.polls_status == 1 %> +
  • + <%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml15"%> +
  • + <% else%> +
  • + 编辑 +
  • <% end%> - - - - - - - - +<% end%> + +<% if @is_teacher%> + <% if poll.polls_status == 2 %> +
  • + 关闭 +
  • + <% else %> +
  • + 关闭 +
  • + <% end%> + +<% end %> + +
  • <%= format_time poll.created_at%>
  • \ No newline at end of file diff --git a/app/views/poll/close_poll.js.erb b/app/views/poll/close_poll.js.erb new file mode 100644 index 000000000..222ea7976 --- /dev/null +++ b/app/views/poll/close_poll.js.erb @@ -0,0 +1,2 @@ +$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>"); +alert("关闭成功"); \ No newline at end of file diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index 29a5ec51f..3db4d7caa 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -56,6 +56,30 @@ $('#ajax-modal').parent().addClass("popbox_polls"); } } + + function close_poll(poll_id) + { + $('#ajax-modal').html("
    " + + "
    " + + "
    " + + "

    问卷关闭后学生将不能继续提交问卷,
    是否确定关闭该问卷?

    " + + "
    " + + "确  定" + + "取  消" + + "
    " + + "
    " + + "
    " + + "
    " + + "
    "); + showModal('ajax-modal', '310px'); + $('#ajax-modal').css('height','120px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("" + + ""); + $('#ajax-modal').parent().removeClass("alert_praise"); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("popbox_polls"); + }
    diff --git a/config/routes.rb b/config/routes.rb index 65498e4ec..29dab3ccc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -67,6 +67,7 @@ RedmineApp::Application.routes.draw do get 'publish_poll' get 'republish_poll' get 'poll_result' + get 'close_poll' end collection do delete 'delete_poll_question' diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 370a3c515..f0d670a1d 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -31,7 +31,7 @@ a.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 300px;white-space: now 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;} -.polls_de{ color:#6883b6;} +.polls_de{ color:#6883b6;padding-left: 5px;} /****翻页***/ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } ul.wlist li{float: left;} @@ -143,5 +143,5 @@ a.btn_pu{ border:1px solid #3cb761; color:#3cb761; } a:hover.btn_pu{ background:#3cb761;} .pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; } .polls_title_w { width:330px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} -.polls_de_grey{ color:#b1b1b1;} +.polls_de_grey{ color:#b1b1b1;padding-left: 5px;} .ml5{ margin-left:5px;}