|
|
|
@ -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,12 +19,18 @@ class PollController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
@poll = Poll.find params[:id]
|
|
|
|
|
#已提交问卷的用户不能再访问该界面
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
|
if @course
|
|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
#提交问卷
|
|
|
|
|