增加关闭问卷功能
This commit is contained in:
parent
d135274281
commit
97c7ccac16
|
@ -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]
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<% end %>
|
||||
|
||||
<%if @is_teacher%>
|
||||
<% if poll.polls_status == 1 %>
|
||||
<% if poll.polls_status == 1 || poll.polls_status == 3 %>
|
||||
<li class="pollsbtn fl ml10 pollsbtn_grey">统计结果</li>
|
||||
<% elsif poll.polls_status == 2%>
|
||||
<li>
|
||||
|
@ -31,38 +31,61 @@
|
|||
<% end%>
|
||||
<% end%>
|
||||
|
||||
<li>
|
||||
<%if @is_teacher %>
|
||||
|
||||
<%if @is_teacher %>
|
||||
<% if poll.polls_status == 1 %>
|
||||
<a href="#" class="pollsbtn btn_pu fl ml5" onclick="poll_submit(<%= poll.id%>,<%= poll.polls_name.length %>);">发布问卷</a>
|
||||
<li>
|
||||
<a href="#" class="pollsbtn btn_pu fl ml5" onclick="poll_submit(<%= poll.id%>,<%= poll.polls_name.length %>);">
|
||||
发布问卷
|
||||
</a>
|
||||
</li>
|
||||
<% elsif poll.polls_status == 2%>
|
||||
<a href="#" class="pollsbtn btn_de fl ml5" onclick="republish_poll(<%= poll.id%>);">取消发布</a>
|
||||
<li>
|
||||
<a href="#" class="pollsbtn btn_de fl ml5" onclick="republish_poll(<%= poll.id%>);">
|
||||
取消发布
|
||||
</a>
|
||||
</li>
|
||||
<% else%>
|
||||
<li class="pollsbtn fl ml10 pollsbtn_grey">
|
||||
发布问卷
|
||||
</li>
|
||||
<% end%>
|
||||
<% end%>
|
||||
</li>
|
||||
<% end%>
|
||||
|
||||
<li>
|
||||
<% 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%>
|
||||
</li>
|
||||
<li>
|
||||
<% if @is_teacher%>
|
||||
|
||||
<% 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%>
|
||||
<li class="polls_de_grey fr ml20">编辑</li>
|
||||
<li>
|
||||
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml15"%>
|
||||
</li>
|
||||
<% else%>
|
||||
<li class="polls_de_grey fr ml15">
|
||||
编辑
|
||||
</li>
|
||||
<% end%>
|
||||
<% end%>
|
||||
|
||||
<% if @is_teacher%>
|
||||
<% if poll.polls_status == 2 %>
|
||||
<li>
|
||||
<a class="polls_de fr ml15" onclick="close_poll(<%= poll.id%>);">关闭</a>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="polls_de_grey fr ml15">
|
||||
关闭
|
||||
</li>
|
||||
<% end%>
|
||||
</li>
|
||||
<!--<li>-->
|
||||
<!--<% if @is_teacher && poll.polls_status == 2%>-->
|
||||
<!--<a class="polls_de fr ml20" onclick="republish_poll(<%= poll.id%>);">-->
|
||||
<!--取消发布-->
|
||||
<!--</a>-->
|
||||
<!--<% end %>-->
|
||||
<!--</li>-->
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
<li class="polls_date fr mr10">
|
||||
<%= format_time poll.created_at%>
|
||||
</li>
|
|
@ -0,0 +1,2 @@
|
|||
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
|
||||
alert("关闭成功");
|
|
@ -56,6 +56,30 @@
|
|||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
}
|
||||
|
||||
function close_poll(poll_id)
|
||||
{
|
||||
$('#ajax-modal').html("<div id='popbox02'>" +
|
||||
"<div class='upload_con'>" +
|
||||
"<div class='upload_box'>" +
|
||||
"<p class='polls_box_p'>问卷关闭后学生将不能继续提交问卷,<br />是否确定关闭该问卷?</p>" +
|
||||
"<div class='polls_btn_box'>" +
|
||||
"<a href='/poll/"+ poll_id +"/close_poll' class='upload_btn' onclick='clickCanel();' data-remote='true'>确 定</a>" +
|
||||
"<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取 消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>");
|
||||
showModal('ajax-modal', '310px');
|
||||
$('#ajax-modal').css('height','120px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='#' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
</script>
|
||||
<div class="polls_content" id="polls" style="width:677px;">
|
||||
<div class="polls_head">
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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;}
|
||||
|
|
Loading…
Reference in New Issue