提交后的问卷禁止查看与编辑

This commit is contained in:
z9hang 2015-01-16 10:19:38 +08:00
parent 933ad22cd2
commit dc2c96f59a
6 changed files with 196 additions and 178 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
@ -141,6 +147,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)
@ -188,15 +198,8 @@ class PollController < ApplicationController
render :text => "failure"
end
else
render :text => "failure"
end
#respond_to do |format|
# format.js
# format.json
#end
end
#提交问卷

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

@ -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

@ -77,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>
@ -130,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>
@ -171,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 %>
@ -203,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;}