This commit is contained in:
sw 2015-01-16 10:49:00 +08:00
commit 40d6ebfd88
8 changed files with 231 additions and 187 deletions

View File

@ -1,5 +1,5 @@
class PollController < ApplicationController
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll]
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer]
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]
@ -19,10 +19,16 @@ class PollController < ApplicationController
def show
@poll = Poll.find params[:id]
poll_questions = @poll.poll_questions
@poll_questions = paginateHelper poll_questions,3 #分页
respond_to do |format|
format.html {render :layout => 'base_courses'}
#已提交问卷的用户不能再访问该界面
if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
render_403
else
@can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin?
poll_questions = @poll.poll_questions
@poll_questions = paginateHelper poll_questions,3 #分页
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
end
end
@ -165,6 +171,10 @@ class PollController < ApplicationController
#提交答案
def commit_answer
pq = PollQuestion.find(params[:poll_question_id])
if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
render :text => 'failure'
return
end
if pq.question_type == 1
#单选题
pv = PollVote.find_by_poll_question_id_and_user_id(params[:poll_question_id],User.current.id)
@ -212,15 +222,8 @@ class PollController < ApplicationController
render :text => "failure"
end
else
render :text => "failure"
end
#respond_to do |format|
# format.js
# format.json
#end
end
#提交问卷
@ -232,9 +235,12 @@ class PollController < ApplicationController
pu.poll_id = @poll.id
if pu.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
@status = 0 #提交成功
else
@status = 2 #未知错误
end
else
@status = 1 #有未做得必答题
end
respond_to do |format|
format.js

View File

@ -37,4 +37,14 @@ module PollHelper
pv.vote_text
end
end
#判断用户是否已经提交了问卷
def has_commit_poll?(poll_id,user_id)
pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id)
if pu.nil?
false
else
true
end
end
end

View File

@ -1,3 +1,12 @@
<div id="popbox">
shaksdkfdks
<div id="popbox" style="text-align: center;margin-top: 25px">
<% if status == 0 %>
<h3 style="font-weight: normal;color: green">提交成功!</h3>
<%= link_to "确定", poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course'),:class => 'commit'%>
<% elsif status == 1 %>
<h3 style="font-weight: normal;color: red">您还有尚未作答的题目请完成后在提交!</h3>
<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
<% else %>
<h3 style="font-weight: normal;color: red">发生未知错误,请检查您的网络。</h3>
<%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%>
<% end %>
</div>

View File

@ -1,10 +1,9 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert') %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').css('height','200px');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>');
showModal('ajax-modal', '400px');
$('#ajax-modal').css('height','100px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='#' onclick='hidden_atert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","50%").css("left","20%");
$('#ajax-modal').parent().css("position","absolute");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("alert_box");

View File

@ -13,7 +13,11 @@
<% @polls.each do |poll|%>
<ul id="polls_<%= poll.id %>">
<li>
<%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %>
<% 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 %>
</li>
<li>
<%if @is_teacher%>

View File

@ -4,6 +4,21 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>问卷调查_问卷页面</title>
<%= stylesheet_link_tag 'polls', :media => 'all' %>
<style type="text/css">
.alert_box{width:480px;height:180px;position:fixed;z-index:100;left:55%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.commit{
height: 28px;
display: block;
width: 80px;
color: #fff !important;
background: #15bccf;
text-align: center;
padding-top: 4px;
margin-left: 130px;
margin-top: 4px;
margin-right: 10px;
}
</style>
<script type="text/javascript">
function hidden_atert_form(cur_page,cur_type)
{
@ -62,7 +77,7 @@
});
}
</script>
<%= radio_button "poll_vote","poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;",:checked => answer_be_selected?(pa,User.current) %>
<%= radio_button "poll_vote","poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;",:checked => answer_be_selected?(pa,User.current),:disabled => !@can_edit_poll %>
<%= pa.answer_text %>
</label>
</td>
@ -115,7 +130,7 @@
});
}
</script>
<input class="ur_checkbox" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %>>
<input class="ur_checkbox" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %> <%= @can_edit_poll?"":"disabled=disabled" %> >
<%= pa.answer_text %>
</label>
</td>
@ -156,7 +171,7 @@
}
</script>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" value="<%= get_anwser_vote_text(pq.id,User.current.id) %>" onblur="onblur_<%= pq.id %>(this);">
<input class="ur_text ur_textbox" type="text" size="" maxlength="" value="<%= get_anwser_vote_text(pq.id,User.current.id) %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
</div>
</li><!--单行输入 end-->
<% elsif pq.question_type == 4 %>
@ -188,7 +203,7 @@
});
}
</script>
<div contenteditable='true' class="ur_textbox" style="min-height: 150px;width: 100%" onblur="onblur_<%= pq.id %>(this);"><%= get_anwser_vote_text(pq.id,User.current.id) %></div>
<div contenteditable='<%= @can_edit_poll %>' class="ur_textbox" style="min-height: 150px;width: 100%;<%= @can_edit_poll?"":"background-color:#DCDCDC;" %>" onblur="onblur_<%= pq.id %>(this);"><%= get_anwser_vote_text(pq.id,User.current.id) %></div>
</div>
</div>
</li><!--多行输入 end-->

View File

@ -1,160 +1,160 @@
.overlay_mac_os_x_dialog {
background-color: #FF7224;
filter:alpha(opacity=60);
-moz-opacity: 0.6;
opacity: 0.6;
}
.mac_os_x_dialog_nw {
background: transparent url(mac_os_x_dialog/L.png) repeat-y top left;
width:16px;
height:16px;
}
.mac_os_x_dialog_n {
background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0;
height:18px;
}
.mac_os_x_dialog_ne {
background: transparent url(mac_os_x_dialog/R.png) repeat-y top left;
width:16px;
height:16px;
}
.mac_os_x_dialog_w {
background: transparent url(mac_os_x_dialog/L.png) repeat-y top left;
width:16px;
}
.mac_os_x_dialog_e {
background: transparent url(mac_os_x_dialog/R.png) repeat-y top right;
width:16px;
}
.mac_os_x_dialog_sw {
background: transparent url(mac_os_x_dialog/BL.png) no-repeat 0 0;
width:31px;
height:40px;
}
.mac_os_x_dialog_s {
background: transparent url(mac_os_x_dialog/B.png) repeat-x 0 0;
height:40px;
}
.mac_os_x_dialog_se, .mac_os_x_dialog_sizer {
background: transparent url(mac_os_x_dialog/BR.png) no-repeat 0 0;
width:31px;
height:40px;
}
.mac_os_x_dialog_sizer {
cursor:se-resize;
}
.mac_os_x_dialog_close {
width: 19px;
height: 19px;
background: transparent url(mac_os_x_dialog/close.gif) no-repeat 0 0;
position:absolute;
top:12px;
left:25px;
cursor:pointer;
z-index:1000;
}
.mac_os_x_dialog_minimize {
width: 19px;
height: 19px;
background: transparent url(mac_os_x_dialog/minimize.gif) no-repeat 0 0;
position:absolute;
top:12px;
left:45px;
cursor:pointer;
z-index:1000;
}
.mac_os_x_dialog_maximize {
width: 19px;
height: 19px;
background: transparent url(mac_os_x_dialog/maximize.gif) no-repeat 0 0;
position:absolute;
top:12px;
left:65px;
cursor:pointer;
z-index:1000;
}
.mac_os_x_dialog_title {
float:left;
height:14px;
font-family: Tahoma, Arial, sans-serif;
font-size:12px;
text-align:center;
margin-top:6px;
width:100%;
color:#000;
}
.mac_os_x_dialog_content {
overflow:auto;
color: #222;
font-family: Tahoma, Arial, sans-serif;
font-size: 10px;
background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0;
}
.mac_os_x_dialog_buttons {
text-align: center;
}
/* FOR IE */
* html .mac_os_x_dialog_nw {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_ne {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_w {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_e {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_sw {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BL.png", sizingMethod="crop");
}
* html .mac_os_x_dialog_s {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/B.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_se {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop");
}
* html .mac_os_x_dialog_sizer {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop");
}
.overlay_mac_os_x_dialog {
background-color: #FF7224;
filter:alpha(opacity=60);
-moz-opacity: 0.6;
opacity: 0.6;
}
.mac_os_x_dialog_nw {
background: transparent url(mac_os_x_dialog/L.png) repeat-y top left;
width:16px;
height:16px;
}
.mac_os_x_dialog_n {
background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0;
height:18px;
}
.mac_os_x_dialog_ne {
background: transparent url(mac_os_x_dialog/R.png) repeat-y top left;
width:16px;
height:16px;
}
.mac_os_x_dialog_w {
background: transparent url(mac_os_x_dialog/L.png) repeat-y top left;
width:16px;
}
.mac_os_x_dialog_e {
background: transparent url(mac_os_x_dialog/R.png) repeat-y top right;
width:16px;
}
.mac_os_x_dialog_sw {
background: transparent url(mac_os_x_dialog/BL.png) no-repeat 0 0;
width:31px;
height:40px;
}
.mac_os_x_dialog_s {
background: transparent url(mac_os_x_dialog/B.png) repeat-x 0 0;
height:40px;
}
.mac_os_x_dialog_se, .mac_os_x_dialog_sizer {
background: transparent url(mac_os_x_dialog/BR.png) no-repeat 0 0;
width:31px;
height:40px;
}
.mac_os_x_dialog_sizer {
cursor:se-resize;
}
.mac_os_x_dialog_close {
width: 19px;
height: 19px;
background: transparent url(mac_os_x_dialog/close.gif) no-repeat 0 0;
position:absolute;
top:12px;
left:25px;
cursor:pointer;
z-index:1000;
}
.mac_os_x_dialog_minimize {
width: 19px;
height: 19px;
background: transparent url(mac_os_x_dialog/minimize.gif) no-repeat 0 0;
position:absolute;
top:12px;
left:45px;
cursor:pointer;
z-index:1000;
}
.mac_os_x_dialog_maximize {
width: 19px;
height: 19px;
background: transparent url(mac_os_x_dialog/maximize.gif) no-repeat 0 0;
position:absolute;
top:12px;
left:65px;
cursor:pointer;
z-index:1000;
}
.mac_os_x_dialog_title {
float:left;
height:14px;
font-family: Tahoma, Arial, sans-serif;
font-size:12px;
text-align:center;
margin-top:6px;
width:100%;
color:#000;
}
.mac_os_x_dialog_content {
overflow:auto;
color: #222;
font-family: Tahoma, Arial, sans-serif;
font-size: 10px;
background: transparent url(mac_os_x_dialog/bg.gif) repeat 0 0;
}
.mac_os_x_dialog_buttons {
text-align: center;
}
/* FOR IE */
* html .mac_os_x_dialog_nw {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_ne {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_w {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/L.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_e {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/R.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_sw {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BL.png", sizingMethod="crop");
}
* html .mac_os_x_dialog_s {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/B.png", sizingMethod="scale");
}
* html .mac_os_x_dialog_se {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop");
}
* html .mac_os_x_dialog_sizer {
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/mac_os_x_dialog/BR.png", sizingMethod="crop");
}

View File

@ -27,6 +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;}
.polls_title{ font-weight:bold; color:#3e6d8e;}
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;}