Merge branch 'szzh' of http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git into szzh
This commit is contained in:
commit
64c0fc7413
|
@ -1,8 +1,8 @@
|
||||||
class PollController < ApplicationController
|
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 :find_container, :only => [:new,:create, :index]
|
||||||
before_filter :is_member_of_course, :only => [:index,:show]
|
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
|
include PollHelper
|
||||||
def index
|
def index
|
||||||
if @course
|
if @course
|
||||||
|
@ -311,6 +311,19 @@ class PollController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
private
|
||||||
def find_poll_and_course
|
def find_poll_and_course
|
||||||
@poll = Poll.find params[:id]
|
@poll = Poll.find params[:id]
|
||||||
|
@ -337,7 +350,8 @@ class PollController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_course_teacher
|
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
|
end
|
||||||
|
|
||||||
#获取未完成的题目
|
#获取未完成的题目
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<li title="<%= poll.polls_name %>">
|
||||||
|
<% if @is_teacher %>
|
||||||
|
<% if has_commit_poll?(poll.id ,User.current) %>
|
||||||
|
<sapn class="polls_title fl"> <%= poll.polls_name %></sapn>
|
||||||
|
<% 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 %>
|
||||||
|
<sapn class="polls_title fl" >
|
||||||
|
<%= poll.polls_name %>
|
||||||
|
</sapn>
|
||||||
|
<% 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 %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%if @is_teacher && poll.polls_status == 2%>
|
||||||
|
<%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
|
||||||
|
<% end%>
|
||||||
|
</li>
|
||||||
|
<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") %>
|
||||||
|
<% end%>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<% if @is_teacher && poll.polls_status == 1%>
|
||||||
|
<!--新建状态的问卷可编辑-->
|
||||||
|
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%>
|
||||||
|
<% end%>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<% if @is_teacher && poll.polls_status == 2%>
|
||||||
|
<a class="polls_de fr ml20" onclick="republish_poll(<%= poll.id%>);">
|
||||||
|
取消发布
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<li class="polls_date fr">
|
||||||
|
<%= format_time poll.created_at%>
|
||||||
|
</li>
|
|
@ -0,0 +1,44 @@
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
function clickPublishPoll()
|
||||||
|
{
|
||||||
|
hideModal("#popbox02");
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "<%= publish_poll_poll_path(poll.id)%>",
|
||||||
|
data: 'text',
|
||||||
|
success: function (data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function clickCanel(){hideModal("#popbox02");}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="popbox02">
|
||||||
|
<div class="upload_con">
|
||||||
|
<div class="upload_box">
|
||||||
|
<p class="polls_box_p">
|
||||||
|
问卷取消发布后学生提交的问卷答案将会被清空,
|
||||||
|
<br />
|
||||||
|
是否确定取消发布该问卷?
|
||||||
|
</p>
|
||||||
|
<div class="polls_btn_box">
|
||||||
|
<%= link_to "确 定",republish_poll_poll_path(poll.id), :class => "upload_btn", :onclick => "clickCanel();" %>
|
||||||
|
<a class="upload_btn upload_btn_grey" onclick="clickCanel();">
|
||||||
|
取 消
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
@ -1,4 +1,31 @@
|
||||||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function republish_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 +"/republish_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','110px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||||
|
"<a 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
function clickCanel(){hideModal("#popbox02");}
|
||||||
|
</script>
|
||||||
<div class="polls_content" id="polls" style="width:677px;">
|
<div class="polls_content" id="polls" style="width:677px;">
|
||||||
<div class="polls_head">
|
<div class="polls_head">
|
||||||
<h2>所有问卷
|
<h2>所有问卷
|
||||||
|
@ -12,44 +39,7 @@
|
||||||
<div class="polls_list">
|
<div class="polls_list">
|
||||||
<% @polls.each do |poll|%>
|
<% @polls.each do |poll|%>
|
||||||
<ul id="polls_<%= poll.id %>">
|
<ul id="polls_<%= poll.id %>">
|
||||||
<li title="<%= poll.polls_name %>">
|
<%= render :partial => 'poll', :locals => {:poll => poll} %>
|
||||||
<% if @is_teacher %>
|
|
||||||
<% if has_commit_poll?(poll.id ,User.current) %>
|
|
||||||
<sapn class="polls_title fl"> <%= poll.polls_name %></sapn>
|
|
||||||
<% 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 %>
|
|
||||||
<sapn class="polls_title fl" >
|
|
||||||
<%= poll.polls_name %>
|
|
||||||
</sapn>
|
|
||||||
<% 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 %>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<%if @is_teacher && poll.polls_status == 2%>
|
|
||||||
<%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
|
|
||||||
<% end%>
|
|
||||||
</li>
|
|
||||||
<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") %>
|
|
||||||
<% end%>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<% if @is_teacher && poll.polls_status == 1%>
|
|
||||||
<!--新建状态的问卷可编辑-->
|
|
||||||
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%>
|
|
||||||
<% end%>
|
|
||||||
</li>
|
|
||||||
<li class="polls_date fr">
|
|
||||||
<%= format_time poll.created_at%>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
|
|
@ -122,6 +122,7 @@
|
||||||
else
|
else
|
||||||
course_term = "春季学期"
|
course_term = "春季学期"
|
||||||
end%>
|
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)%>
|
<% all_new_hot_course += find_all_new_hot_course(course_count-all_new_hot_course.count, @school_id, year_now, course_term)%>
|
||||||
<% end%>
|
<% end%>
|
||||||
<%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %>
|
<%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %>
|
||||||
|
@ -152,6 +153,7 @@
|
||||||
else
|
else
|
||||||
course_term = "春季学期"
|
course_term = "春季学期"
|
||||||
end%>
|
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)%>
|
<% 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%>
|
<% end%>
|
||||||
<%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %>
|
<%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %>
|
||||||
|
|
|
@ -65,6 +65,7 @@ RedmineApp::Application.routes.draw do
|
||||||
post 'create_poll_question'
|
post 'create_poll_question'
|
||||||
post 'commit_poll'
|
post 'commit_poll'
|
||||||
get 'publish_poll'
|
get 'publish_poll'
|
||||||
|
get 'republish_poll'
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
delete 'delete_poll_question'
|
delete 'delete_poll_question'
|
||||||
|
|
|
@ -27,7 +27,7 @@ a.newbtn{ float:right; display:block; width:80px; height:30px; background:#64bdd
|
||||||
a:hover.newbtn{ background:#55a1b9; text-decoration:none;}
|
a:hover.newbtn{ background:#55a1b9; text-decoration:none;}
|
||||||
.polls_list ul{ padding-left:10px; border-bottom:1px dashed #c9c9c9; height:32px; padding-top:8px;}
|
.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;}
|
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.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;}
|
a:hover.pollsbtn{ background:#64bdd9; color:#fff; text-decoration:none;}
|
||||||
.polls_date{ color:#666666;}
|
.polls_date{ color:#666666;}
|
||||||
|
|
Loading…
Reference in New Issue