|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
class PollController < ApplicationController
|
|
|
|
|
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result]
|
|
|
|
|
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question]
|
|
|
|
|
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]
|
|
|
|
@ -85,7 +85,28 @@ class PollController < ApplicationController
|
|
|
|
|
|
|
|
|
|
#添加单选题
|
|
|
|
|
def create_poll_question
|
|
|
|
|
a = 1
|
|
|
|
|
question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
|
|
|
|
option = {
|
|
|
|
|
:is_necessary => params[:is_necessary] || true,
|
|
|
|
|
:question_title => question_title,
|
|
|
|
|
:question_type => params[:question_type] || 1
|
|
|
|
|
}
|
|
|
|
|
@poll_questions = @poll.poll_questions.new option
|
|
|
|
|
if params[:question_answer]
|
|
|
|
|
for i in 1..params[:question_answer].count
|
|
|
|
|
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
|
|
|
|
|
question_option = {
|
|
|
|
|
:answer_position => i,
|
|
|
|
|
:answer_text => params[:question_answer].values[i-1]
|
|
|
|
|
}
|
|
|
|
|
@poll_questions.poll_answers.new question_option
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if @poll_questions.save
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|