Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_video
杨树明 5 years ago
commit 9e72cd1e59

@ -4,7 +4,7 @@ module ControllerRescueHandler
included do
rescue_from Exception do |e|
Util.logger_error e
render json: {status: -1, message: e.message}
render json: {status: -1, message: "接口异常"}
end
# rescue_from ActionView::MissingTemplate, with: :object_not_found
# rescue_from ActiveRecord::RecordNotFound, with: :object_not_found

@ -1,12 +1,12 @@
class ExerciseQuestionsController < ApplicationController
before_action :require_login, :check_auth #用户需登陆
before_action :get_exercise,only:[:new,:create] #获取试卷
before_action :get_exercise_question,except: [:new,:create] #获取试卷的问题及试卷
before_action :get_exercise, only: [:new, :create] #获取试卷
before_action :get_exercise_question, except: [:new, :create] #获取试卷的问题及试卷
before_action :is_course_teacher #是否为老师
before_action :validate_params,only: [:create,:update] #传入参数的验证
before_action :check_exercise_status,only: [:new,:create,:delete_answer,:destroy] #除未发布状态之外,其余状态不能进行增删操作
before_action :cannot_change_column,only: [:update] #更新时不能更改的内容
before_action :check_adjust_score,only: [:adjust_score]
before_action :validate_params, only: [:create, :update] #传入参数的验证
before_action :check_exercise_status, only: [:new, :create, :delete_answer, :destroy] #除未发布状态之外,其余状态不能进行增删操作
before_action :cannot_change_column, only: [:update] #更新时不能更改的内容
before_action :check_adjust_score, only: [:adjust_score]
include ExercisesHelper
def new
@ -24,7 +24,6 @@ class ExerciseQuestionsController < ApplicationController
#question_type 0为单选题1为多选题2为判断题3为填空题单空和多空4为简答题5为实训题
def create
ActiveRecord::Base.transaction do
begin
question_options = {
:question_title => params[:question_title],
:question_type => params[:question_type].present? ? params[:question_type].to_i : 0, #默认为单选题
@ -49,11 +48,11 @@ class ExerciseQuestionsController < ApplicationController
ques_type = @exercise_question.question_type
if ques_type <= Exercise::MULTIPLE
choices_array = params[:question_choices]
choices_count= choices_array.count
choices_count = choices_array.count
standard_answer = params[:standard_answers] #为数组格式,因为可能会有单选和多选,标准答案,已提前判断不能为空,
standard_answer = standard_answer.uniq.reject(&:blank?)
(1..choices_count).each do |c|
choice = choices_array[c-1] #每一个选项的内容
choice = choices_array[c - 1] #每一个选项的内容
choice_option = {
:choice_position => c,
:choice_text => choice.strip
@ -71,16 +70,16 @@ class ExerciseQuestionsController < ApplicationController
question_standard_answer = ExerciseStandardAnswer.new(standard_option)
question_standard_answer.save!
if standard_answer.count > 1 && ques_type == Exercise::SINGLE #当标准答案数大于1且不为多选时修改为多选
@exercise_question.update_attribute("question_type",Exercise::MULTIPLE)
@exercise_question.update_attribute("question_type", Exercise::MULTIPLE)
elsif standard_answer.count == 1 && ques_type == Exercise::MULTIPLE
@exercise_question.update_attribute("question_type",Exercise::SINGLE)
@exercise_question.update_attribute("question_type", Exercise::SINGLE)
end
end
elsif ques_type == Exercise::JUDGMENT #这个为判断题
choices_array = params[:question_choices] #判断的选项,对/错等等
choices_count= choices_array.count
choices_count = choices_array.count
(1..choices_count).each do |c|
choice = choices_array[c-1] #每一个选项的内容
choice = choices_array[c - 1] #每一个选项的内容
choice_option = {
:choice_position => c,
:choice_text => choice.strip
@ -127,7 +126,7 @@ class ExerciseQuestionsController < ApplicationController
shixun_scores = params[:question_scores] #试卷有多个的分值有多个分数表,所以为分数的数组
shixun_name = params[:shixun_name] || shixun.name
question_score = 0
shixun.challenges.try(:each_with_index) do |challenge,index|
shixun.challenges.try(:each_with_index) do |challenge, index|
shixun_option = {
:challenge_id => challenge.id,
:shixun_id => shixun.id,
@ -138,13 +137,8 @@ class ExerciseQuestionsController < ApplicationController
ex_shixun_challenge = ExerciseShixunChallenge.create!(shixun_option)
question_score += ex_shixun_challenge.question_score # 问题的分数,为各个关卡分数的总和
end
@exercise_question.update!(:question_score => question_score,:shixun_name=> shixun_name)
end
@exercise_question.update!(:question_score => question_score, :shixun_name => shixun_name)
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("试卷问题创建失败!")
raise ActiveRecord::Rollback
end
end
end
@ -164,20 +158,13 @@ class ExerciseQuestionsController < ApplicationController
def edit
ActiveRecord::Base.transaction do
begin
@exercise_choices = @exercise_question.exercise_choices
@exercise_question_shixun = @exercise_question.exercise_shixun_challenges
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
raise ActiveRecord::Rollback
end
end
end
def update
ActiveRecord::Base.transaction do
begin
standard_answer_change = false
# 更新试卷题目的内容
question_options = {
@ -198,24 +185,24 @@ class ExerciseQuestionsController < ApplicationController
choice_array_count_array = (1..choice_array_count).to_a
if ex_choice_count > choice_array_count #如果选项有减少的,那么只更新传入的,删除以前的
choice_array_count_array.each do |c|
choice = choices_array[c-1] #每一个选项的内容
exercise_choice = @exercise_question.exercise_choices.find_choice_custom("choice_position",(c))
exercise_choice.update(choice_text:choice)
choice = choices_array[c - 1] #每一个选项的内容
exercise_choice = @exercise_question.exercise_choices.find_choice_custom("choice_position", (c))
exercise_choice.update(choice_text: choice)
end
drop_ex_choice = @exercise_question.exercise_choices.left_choice_choose("choice_position",(choice_array_count))
drop_ex_choice = @exercise_question.exercise_choices.left_choice_choose("choice_position", (choice_array_count))
drop_ex_choice.destroy_all
else
ex_choice_count_array.each do |c|
choice = choices_array[c-1] #每一个选项的内容
exercise_choice = @exercise_question.exercise_choices.find_choice_custom("choice_position",(c))
exercise_choice.update(choice_text:choice)
choice = choices_array[c - 1] #每一个选项的内容
exercise_choice = @exercise_question.exercise_choices.find_choice_custom("choice_position", (c))
exercise_choice.update(choice_text: choice)
end
new_add_choice = choice_array_count_array - ex_choice_count_array #新传入的需新增
if new_add_choice.count > 0
new_add_choice.each do |i|
choice_option = {
:choice_position => i,
:choice_text => choices_array[i-1].strip
:choice_text => choices_array[i - 1].strip
}
question_choices = @exercise_question.exercise_choices.new(choice_option)
question_choices.save!
@ -248,9 +235,9 @@ class ExerciseQuestionsController < ApplicationController
end
if standard_answer.count > 1 && @exercise_question.question_type == Exercise::SINGLE #当标准答案数大于1且不为多选时修改为多选
@exercise_question.update_attribute("question_type",Exercise::MULTIPLE)
@exercise_question.update_attribute("question_type", Exercise::MULTIPLE)
elsif standard_answer.count == 1 && @exercise_question.question_type == Exercise::MULTIPLE
@exercise_question.update_attribute("question_type",Exercise::SINGLE)
@exercise_question.update_attribute("question_type", Exercise::SINGLE)
end
end
elsif @exercise_question.question_type == Exercise::COMPLETION #填空题
@ -286,14 +273,14 @@ class ExerciseQuestionsController < ApplicationController
:answer_text => null_choice_text[n - 1]
}
standard_option = @hash_symbol_null_
ex_answer_pre[n-1].update(standard_option)
ex_answer_pre[n - 1].update(standard_option)
end
if new_add_choice.count > 0 #表示有新增的
new_add_choice.each do |i|
standard_option = {
:exercise_question_id => @exercise_question.id,
:exercise_choice_id => null_choice_id,
:answer_text => null_choice_text[i-1]
:answer_text => null_choice_text[i - 1]
}
question_standard_answer = ExerciseStandardAnswer.new(standard_option)
question_standard_answer.save!
@ -301,7 +288,7 @@ class ExerciseQuestionsController < ApplicationController
end
else
new_delete_choice = ex_answer_pre_count_array - null_choice_text_count_array
null_choice_text.each_with_index do |n,index|
null_choice_text.each_with_index do |n, index|
standard_option = {
:exercise_question_id => @exercise_question.id,
:exercise_choice_id => null_choice_id,
@ -311,7 +298,7 @@ class ExerciseQuestionsController < ApplicationController
end
if new_delete_choice.count > 0 #表示填空题的答案有删减的
new_delete_choice.each do |d|
ex_answer_pre[d-1].destroy
ex_answer_pre[d - 1].destroy
end
end
end
@ -333,7 +320,7 @@ class ExerciseQuestionsController < ApplicationController
if @exercise_question.question_type == Exercise::SUBJECTIVE #主观题
main_standard_answer = standard_answer.present? ? standard_answer.first : nil
if @exercise_answers_array.present?
@exercise_answers_array.first.update_attribute("answer_text",main_standard_answer)
@exercise_answers_array.first.update_attribute("answer_text", main_standard_answer)
else
standard_option = {
:exercise_question_id => @exercise_question.id,
@ -371,15 +358,9 @@ class ExerciseQuestionsController < ApplicationController
# end
# end
# end
normal_status(3,"修改了标准答案\n是否重新计算学生答题的成绩?")
normal_status(3, "修改了标准答案\n是否重新计算学生答题的成绩?")
else
normal_status(0,"试卷更新成功!")
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
raise ActiveRecord::Rollback
normal_status(0, "试卷更新成功!")
end
end
end
@ -391,17 +372,17 @@ class ExerciseQuestionsController < ApplicationController
ex_users_committed = @exercise.exercise_users.exercise_user_committed
if ex_users_committed.size > 0
ex_users_committed.each do |ex_user|
update_objective_score = update_single_score(@exercise_question,ex_user.user_id,standard_answer)
update_objective_score = update_single_score(@exercise_question, ex_user.user_id, standard_answer)
if update_objective_score != 0
objective_score = ex_user.objective_score
new_objective_score = objective_score + update_objective_score
total_score = ex_user.score + update_objective_score
total_score = total_score < 0.0 ? 0.0 : total_score
ex_user.update!(objective_score:new_objective_score,score:total_score)
ex_user.update!(objective_score: new_objective_score, score: total_score)
end
end
end
normal_status(0,"学生成绩更新成功")
normal_status(0, "学生成绩更新成功")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("答案删除失败!")
@ -456,7 +437,7 @@ class ExerciseQuestionsController < ApplicationController
choice_d_id = params[:choice_no].to_i # 选项的当前位置
question_choices = @exercise_question.exercise_choices
delete_answer = question_choices.find_by(choice_position: choice_d_id)
left_choices = question_choices.where("choice_position > ? ",choice_d_id)
left_choices = question_choices.where("choice_position > ? ", choice_d_id)
left_choices.update_all("choice_position = choice_position - 1") if left_choices
if delete_answer.destroy
normal_status(0, "答案删除成功!")
@ -493,11 +474,10 @@ class ExerciseQuestionsController < ApplicationController
#老师调分窗口
def adjust_score
ActiveRecord::Base.transaction do
begin
ex_all_scores = @exercise.exercise_questions.pluck(:question_score).sum
ex_obj_score = @exercise_current_user.objective_score #全部客观题得分
ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分
ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id", @user_id) #当前用户答案的得分
if @exercise_question.question_type == Exercise::MULTIPLE
if ex_answers.present? #学生有回答时 取学生的答题得分否则0分
answer_choice_array = []
@ -580,7 +560,7 @@ class ExerciseQuestionsController < ApplicationController
if ex_answers.exists?
ex_answers_old_score = ex_answers.first.score > 0.0 ? ex_answers.first.score : 0.0 #原分数小于0取0
new_sub_score = ex_subj_score - ex_answers_old_score + @c_score #原全部主观题总分减去原该主观题得分再加调分后的分数,即为当前全部主观题得分
ex_answers.first.update_attribute("score",@c_score)
ex_answers.first.update_attribute("score", @c_score)
else #如果学生未答,则创建新的答题记录
answer_option = {
:user_id => @user_id,
@ -604,14 +584,14 @@ class ExerciseQuestionsController < ApplicationController
@exercise_current_user.update!(ex_scores)
elsif @exercise_question.question_type == Exercise::PRACTICAL
ex_answers = @exercise_question.exercise_shixun_answers.where(user_id:@user_id,exercise_shixun_challenge_id:@shixun_a_id)
ex_answers = @exercise_question.exercise_shixun_answers.where(user_id: @user_id, exercise_shixun_challenge_id: @shixun_a_id)
if ex_answers.present? #当为实训题时
ex_shixun_old_score = ex_answers.first.score > 0.0 ? ex_answers.first.score : 0.0
new_obj_score = ex_obj_score - ex_shixun_old_score + @c_score
ex_answers.first.update_attribute("score",@c_score)
ex_answers.first.update_attribute("score", @c_score)
else
ex_shixun_option ={
ex_shixun_option = {
:exercise_question_id => @exercise_question.id,
:user_id => @user_id,
:exercise_shixun_challenge_id => @shixun_a_id,
@ -668,30 +648,25 @@ class ExerciseQuestionsController < ApplicationController
end
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end
private
def questions_params
params.require(:exercise_question).permit(:question_title,:question_type,
:question_number,:exercise_id,
:question_score,:shixun_id,:is_ordered)
params.require(:exercise_question).permit(:question_title, :question_type,
:question_number, :exercise_id,
:question_score, :shixun_id, :is_ordered)
end
def get_exercise
@exercise = Exercise.find_by(id:params[:exercise_id])
@exercise = Exercise.find_by(id: params[:exercise_id])
if @exercise.blank?
tip_exception(404,"试卷不存在")
tip_exception(404, "试卷不存在")
else
@course = @exercise.course
if @course.blank?
tip_exception(404,"课堂不存在")
tip_exception(404, "课堂不存在")
end
end
end
@ -708,51 +683,51 @@ class ExerciseQuestionsController < ApplicationController
if @exercise_question.present?
@exercise = @exercise_question.exercise
if @exercise.blank?
tip_exception(404,"试卷不存在")
tip_exception(404, "试卷不存在")
else
@course = @exercise.course
if @course.blank?
tip_exception(404,"课堂不存在")
tip_exception(404, "课堂不存在")
end
end
else
tip_exception(404,"试卷问题不存在")
tip_exception(404, "试卷问题不存在")
end
end
def validate_params
normal_status(-1,"题目不允许为空!") if (params[:question_title].blank? && params[:question_type].to_i != Exercise::PRACTICAL ) #除了实训题,其余题目必需有题干
normal_status(-1,"问题类型不允许为空!" ) if params[:question_type].blank?
normal_status(-1,"分值不允许为空!" ) if params[:question_score].blank? && params[:question_scores].blank? #分值的数组或参数必需存在一个
normal_status(-1, "题目不允许为空!") if (params[:question_title].blank? && params[:question_type].to_i != Exercise::PRACTICAL) #除了实训题,其余题目必需有题干
normal_status(-1, "问题类型不允许为空!") if params[:question_type].blank?
normal_status(-1, "分值不允许为空!") if params[:question_score].blank? && params[:question_scores].blank? #分值的数组或参数必需存在一个
if params[:question_score].present? && params[:question_score].to_f <= 0.0 #问题类型存在,则分值不能为空,且必需大于0
normal_status(-1,"分值必需大于0")
elsif (params[:question_score].present? && params[:question_score].to_f.round(1) > 100.0) || (params[:question_scores].present? && (params[:question_scores].map{|a| a.to_f.round(1)}.max > 100.0))
normal_status(-1,"分值不能超过100分")
normal_status(-1, "分值必需大于0")
elsif (params[:question_score].present? && params[:question_score].to_f.round(1) > 100.0) || (params[:question_scores].present? && (params[:question_scores].map {|a| a.to_f.round(1)}.max > 100.0))
normal_status(-1, "分值不能超过100分")
elsif params[:question_scores].present? && params[:question_scores].include?(0.0) #如果有负数,则自动取绝对值,#多个分数值,针对实训题的
normal_status(-1,"分值必需大于0")
normal_status(-1, "分值必需大于0")
elsif params[:standard_answers].present? && params[:question_choices].present? && (params[:standard_answers].count > params[:question_choices].count)
normal_status(-1,"标准答案数不能大于选项数!")
elsif [0,1,2,3].include?(params[:question_type].to_i) && (params[:standard_answers].blank? || params[:standard_answers].include?("")) #选择题/判断题/填空题 问题选项/标准答案不能为空,也不能包含空的内容
normal_status(-1,"标准答案不能为空!")
normal_status(-1, "标准答案数不能大于选项数!")
elsif [0, 1, 2, 3].include?(params[:question_type].to_i) && (params[:standard_answers].blank? || params[:standard_answers].include?("")) #选择题/判断题/填空题 问题选项/标准答案不能为空,也不能包含空的内容
normal_status(-1, "标准答案不能为空!")
elsif params[:question_type].to_i == 2 && (params[:standard_answers].count > 1 || params[:question_choices].blank? || params[:question_choices].include?("")) #判断题的标准答案不能大于1个选项不能为空
normal_status(-1,"判断题选项不能为空/标准答案不能大于1个")
normal_status(-1, "判断题选项不能为空/标准答案不能大于1个")
elsif params[:question_type].to_i <= 1 && (params[:question_choices].blank? || params[:question_choices].include?("") || params[:question_choices].count < 2) #选择题选项不能为空,且不能小于2
normal_status(-1,"选择题选项内容不能为空且不能少于2个")
elsif params[:question_type].to_i == 3 && (params[:standard_answers].blank? || params[:standard_answers].count > 5 ) #填空题选项最多为5个,且如果为1个的话不允许修改is_ordered
normal_status(-1,"填空题标准答案不能为空/不能超过5个")
normal_status(-1, "选择题选项内容不能为空且不能少于2个")
elsif params[:question_type].to_i == 3 && (params[:standard_answers].blank? || params[:standard_answers].count > 5) #填空题选项最多为5个,且如果为1个的话不允许修改is_ordered
normal_status(-1, "填空题标准答案不能为空/不能超过5个")
elsif params[:question_type].to_i == 4 && params[:standard_answers].count > 2 #简单题参考答案最多为1个
normal_status(-1,"简答题的参考答案不能大于2个")
normal_status(-1, "简答题的参考答案不能大于2个")
elsif params[:question_type].to_i == 5
if params[:shixun_id].blank? #实训题的id不能为空
normal_status(-1,"实训题id不能为空")
normal_status(-1, "实训题id不能为空")
elsif params[:shixun_name].blank?
normal_status(-1,"实训题名称不能为空!")
normal_status(-1, "实训题名称不能为空!")
end
end
end
def check_exercise_status
normal_status(-1,"不能更改试卷问题!") if @exercise.exercise_status != Exercise::UNPUBLISHED
normal_status(-1, "不能更改试卷问题!") if @exercise.exercise_status != Exercise::UNPUBLISHED
end
#更新时不能修改的内容
@ -767,19 +742,19 @@ class ExerciseQuestionsController < ApplicationController
update_choices_count = params[:question_choices].present? ? params[:question_choices].count : choices_count #传入的选项个数
standard_answer = params[:standard_answers] #传参数是怎么传的?能不能传空值?
if update_question_score.present? && question_score != update_question_score #分数有更改
normal_status(-1,"已发布/已截止,分数不允许修改!")
normal_status(-1, "已发布/已截止,分数不允许修改!")
elsif update_choices_count != choices_count #选项个数有修改
normal_status(-1,"已发布/已截止,不允许增删答案!")
normal_status(-1, "已发布/已截止,不允许增删答案!")
elsif standard_answer.present?
if @exercise_question.question_type == Exercise::COMPLETION
# exercise_answers_text = standard_answer.map{|a| a[:answer_text]}.sum.uniq
# unless (standard_answer.count == exercise_choice_ids.count) && (standard_answers_text.count == exercise_answers_text.count)
unless standard_answer.count == exercise_choice_ids.count
normal_status(-1,"已发布/已截止,不允许增删标准答案!")
normal_status(-1, "已发布/已截止,不允许增删标准答案!")
end
elsif @exercise_question.question_type == Exercise::SUBJECTIVE
unless standard_answers_text.count == standard_answer.count
normal_status(-1,"已发布/已截止,不允许增删标准答案!")
normal_status(-1, "已发布/已截止,不允许增删标准答案!")
end
end
end
@ -791,13 +766,13 @@ class ExerciseQuestionsController < ApplicationController
@user_id = params[:user_id]
@exercise_current_user = @exercise.exercise_users.exercise_commit_users(@user_id).first #当前试卷用户的答案内容
if @exercise_current_user.blank?
normal_status(-1,"用户不存在!")
normal_status(-1, "用户不存在!")
elsif @c_score.blank?
normal_status(-1,"分数不能为空!")
normal_status(-1, "分数不能为空!")
elsif @exercise_question.question_type == Exercise::SINGLE || @exercise_question.question_type == Exercise::JUDGMENT
normal_status(-1,"单选题/判断题不能调分!")
normal_status(-1, "单选题/判断题不能调分!")
elsif params[:comment].present? && params[:comment].length > 100
normal_status(-1,"评语不能超过100个字符!")
normal_status(-1, "评语不能超过100个字符!")
else
@shixun_a_id = params[:shixun_challenge_id]
if @exercise_question.question_type == Exercise::PRACTICAL #当为实训题时,为关卡的分数
@ -806,13 +781,13 @@ class ExerciseQuestionsController < ApplicationController
@old_ques_score = @shixun_challenge.first.question_score
else
@old_ques_score = nil
normal_status(-1,"实训答案id不能为空!")
normal_status(-1, "实训答案id不能为空!")
end
else
@old_ques_score = @exercise_question.question_score #当不为实训题时,为各问题的分数
end
if @old_ques_score.present? && (@c_score > @old_ques_score)
normal_status(-1,"分数不能大于题目分数!")
normal_status(-1, "分数不能大于题目分数!")
end
end
end

@ -1168,7 +1168,7 @@ class ExercisesController < ApplicationController
#班级的选择
if params[:exercise_group_id].present?
group_id = params[:exercise_group_id]
exercise_students = @course_all_members.course_find_by_ids("course_group_id", group_id) #试卷所分班的全部人数
exercise_students = @course_all_members.course_find("course_group_id", group_id) #试卷所分班的全部人数
user_ids = exercise_students.pluck(:user_id).reject(&:blank?)
@exercise_users_list = @exercise_users_list.exercise_commit_users(user_ids)
end

@ -1,13 +1,13 @@
class PollQuestionsController < ApplicationController
before_action :require_login, :check_auth
before_action :get_poll,only:[:new,:create]
before_action :get_poll_question,except: [:new,:create]
before_action :get_poll, only: [:new, :create]
before_action :get_poll_question, except: [:new, :create]
before_action :is_course_teacher
before_action :get_poll_questions_count,only:[:create]
before_action :get_poll_question_answers,only:[:edit,:update]
before_action :check_poll_status,only: [:new,:create,:delete_answer,:destroy]
before_action :validates_params,only:[:create,:update]
before_action :validates_update_params,only: [:update]
before_action :get_poll_questions_count, only: [:create]
before_action :get_poll_question_answers, only: [:edit, :update]
before_action :check_poll_status, only: [:new, :create, :delete_answer, :destroy]
before_action :validates_params, only: [:create, :update]
before_action :validates_update_params, only: [:update]
def new
@ -25,7 +25,6 @@ class PollQuestionsController < ApplicationController
# 创建题目和选择的答案
def create
ActiveRecord::Base.transaction do
begin
poll_options = {
:question_title => params[:question_title],
:question_type => params[:question_type],
@ -50,7 +49,7 @@ class PollQuestionsController < ApplicationController
p_other_answer = params[:question_other_answer]
# 新增选择题答案选择的选项
(1..p_answer.count).each do |i|
answer = p_answer[i-1] # 传入的答案的内容
answer = p_answer[i - 1] # 传入的答案的内容
question_option = {
:answer_position => i,
:answer_text => answer
@ -69,11 +68,6 @@ class PollQuestionsController < ApplicationController
end
end
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("问卷的问题创建失败!")
raise ActiveRecord::Rollback
end
end
end
@ -103,7 +97,6 @@ class PollQuestionsController < ApplicationController
def update
ActiveRecord::Base.transaction do
begin
if @poll_question.question_type < 3 #当为单选题或多选题时
p_answer = params[:question_answers]
p_other_answer = params[:question_other_answer]
@ -114,21 +107,21 @@ class PollQuestionsController < ApplicationController
end
end
(1..p_answer_count).each do |i|
answer = @poll_question.poll_answers.find_answer_by_custom("answer_position",i).first
answer = @poll_question.poll_answers.find_answer_by_custom("answer_position", i).first
if answer # 判断该位置的answer是否存在存在则更新.不存在则跳到下一步
answer.answer_text = p_answer[i-1]
answer.answer_text = p_answer[i - 1]
answer.answer_position = i
answer.save!
else
answer_options = {
:answer_position => i,
:answer_text => p_answer[i-1]
:answer_text => p_answer[i - 1]
}
@poll_question.poll_answers.new answer_options
end
end
if p_other_answer #判断答案的其他选项是否存在
other_answer = @poll_question.poll_answers.find_answer_by_custom("answer_text","").first
other_answer = @poll_question.poll_answers.find_answer_by_custom("answer_text", "").first
if other_answer.blank?
question_option = {
:answer_position => p_answer_count + 1,
@ -143,11 +136,6 @@ class PollQuestionsController < ApplicationController
end
@poll_question.update!(poll_questions_params)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("更新失败")
raise ActiveRecord::Rollback
end
end
end
@ -157,7 +145,7 @@ class PollQuestionsController < ApplicationController
answer_d_id = params[:answer_no].to_i # 答案的当前位置
poll_answers = @poll_question.poll_answers
delete_answer = poll_answers.find_by(answer_position: answer_d_id)
left_answers = poll_answers.where("answer_position > ?",answer_d_id)
left_answers = poll_answers.where("answer_position > ?", answer_d_id)
left_answers.update_all("answer_position = answer_position - 1") if left_answers
if delete_answer.destroy
@ -196,7 +184,7 @@ class PollQuestionsController < ApplicationController
if @poll.polls_status.to_i == 1
if opr.present?
if opr.to_s == "up"
last_q_p = @poll.poll_questions.find_by(question_number: (current_q_p-1)) #当前问题的前一个问题
last_q_p = @poll.poll_questions.find_by(question_number: (current_q_p - 1)) #当前问题的前一个问题
if last_q_p.present?
@poll_question.update!(question_number: (current_q_p - 1))
last_q_p.update!(question_number: current_q_p) # 重新获取当前问题的位置
@ -205,7 +193,7 @@ class PollQuestionsController < ApplicationController
normal_status(-1, "移动失败,已经是第一个问题了!")
end
elsif opr.to_s == "down"
next_q_p = @poll.poll_questions.find_by(question_number: (current_q_p+1)) #当前问题的后一个问题
next_q_p = @poll.poll_questions.find_by(question_number: (current_q_p + 1)) #当前问题的后一个问题
if next_q_p.present?
@poll_question.update!(question_number: (current_q_p + 1))
next_q_p.update!(question_number: current_q_p)
@ -219,7 +207,7 @@ class PollQuestionsController < ApplicationController
normal_status(-1, "移动失败,请输入参数")
end
else
normal_status(-1,"已发布的不能移动问题")
normal_status(-1, "已发布的不能移动问题")
end
rescue Exception => e
uid_logger_error(e.message)
@ -231,7 +219,7 @@ class PollQuestionsController < ApplicationController
private
def poll_questions_params
params.require(:poll_question).permit(:question_title,:question_type,:is_necessary,:question_number,:max_choices,:min_choices)
params.require(:poll_question).permit(:question_title, :question_type, :is_necessary, :question_number, :max_choices, :min_choices)
end
def validates_params
@ -242,12 +230,12 @@ class PollQuestionsController < ApplicationController
normal_status(-1, "最小可选不能大于最大可选!")
elsif params[:question_answers].present? && (params[:max_choices].to_i > params[:question_answers].count)
normal_status(-1, "选择题的最大可选项不能大于答案数!")
elsif [1,3].include?(params[:question_type]) && (params[:max_choices].to_i > 0 || params[:min_choices].to_i > 0)
elsif [1, 3].include?(params[:question_type]) && (params[:max_choices].to_i > 0 || params[:min_choices].to_i > 0)
normal_status(-1, "单选题或主观题不能有最大或最小选择数!")
elsif params[:question_type] == 3 && (params[:question_answers] || params[:question_other_answer])
normal_status(-1, "主观问题不需要可选答案!")
elsif params[:question_type] != 3
if params[:question_answers].present? && params[:question_answers].select{|answer| answer.blank?}.count > 0
if params[:question_answers].present? && params[:question_answers].select {|answer| answer.blank?}.count > 0
normal_status(-1, "选项不能有空值!")
elsif params[:question_other_answer].present? && !params[:question_other_answer].blank?
normal_status(-1, "其他选项不能有值!")
@ -262,11 +250,11 @@ class PollQuestionsController < ApplicationController
def validates_update_params
question_a_count = params[:question_answers].present? ? params[:question_answers].count : 0
question_o_count = params[:question_other_answer].present? ? params[:question_other_answer].count : 0
normal_status(-1, "已发布的问卷不允许增删答案!") if (((question_a_count+question_o_count) != @poll_current_answers) && (@poll.polls_status.to_i != 1))
normal_status(-1, "已发布的问卷不允许增删答案!") if (((question_a_count + question_o_count) != @poll_current_answers) && (@poll.polls_status.to_i != 1))
end
def get_poll
@poll = Poll.find_by(id:params[:poll_id])
@poll = Poll.find_by(id: params[:poll_id])
if @poll.blank?
tip_exception(404)
end
@ -283,7 +271,7 @@ class PollQuestionsController < ApplicationController
def get_poll_question
@poll_question = PollQuestion.find_by(id: params[:id])
if @poll_question.present?
@poll = Poll.find_by(id:@poll_question.poll_id)
@poll = Poll.find_by(id: @poll_question.poll_id)
else
tip_exception(404)
end
@ -305,7 +293,7 @@ class PollQuestionsController < ApplicationController
tip_exception(404)
else
@identity = current_user.course_identity(@course)
normal_status(-1, "权限不够") unless(@course.present? && @identity < Course::STUDENT) #课堂存在,且当前用户为教师/管理员
normal_status(-1, "权限不够") unless (@course.present? && @identity < Course::STUDENT) #课堂存在,且当前用户为教师/管理员
end
end
end

@ -6,12 +6,11 @@ class PollVotesController < ApplicationController
def create #每一次答案的点击,请求一次
begin
question_votes = @poll_question.poll_votes
question_type = @poll_question.question_type
question_answer_id = params[:poll_answer_id] ? params[:poll_answer_id] : -1 #该答案的id
question_answer_text = params[:vote_text].present? ? params[:vote_text] : nil #其他选项的内容
user_votes = question_votes.find_current_vote("user_id",current_user.id) #当前用户的答案,可能有多个
user_votes = question_votes.find_current_vote("user_id", current_user.id) #当前用户的答案,可能有多个
# 当前用户的当前答案,如果已存在,当再次点击的时候,取消答案,即删除该答案
current_vote_text = nil
@ -58,7 +57,7 @@ class PollVotesController < ApplicationController
}
PollVote.create!(answer_option)
# 重新取一次poll_votes
user_votes = @poll_question.poll_votes.find_current_vote("user_id",current_user.id)
user_votes = @poll_question.poll_votes.find_current_vote("user_id", current_user.id)
end
# if current_vote_text.present? #已有其他输入文字的选项
# current_vote_text.update_attribute("vote_text", question_answer_text)
@ -84,7 +83,7 @@ class PollVotesController < ApplicationController
end
end
if old_ids.size > 0
ea_answer = user_votes.find_current_vote("poll_answer_id",old_ids)
ea_answer = user_votes.find_current_vote("poll_answer_id", old_ids)
ea_answer.destroy_all
end
else
@ -115,11 +114,6 @@ class PollVotesController < ApplicationController
@current_question_status = 1
end
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
raise ActiveRecord::Rollback
end
end
@ -128,14 +122,14 @@ class PollVotesController < ApplicationController
def get_poll_question
@poll_question = PollQuestion.find_by_id(params[:poll_question_id])
if @poll_question.blank?
normal_status(-1,"问卷试题不存在!")
normal_status(-1, "问卷试题不存在!")
else
@poll = @poll_question.poll
@course = @poll.course
if @poll.blank?
normal_status(-1,"问卷不存在!")
normal_status(-1, "问卷不存在!")
elsif @course.blank?
normal_status(-1,"课堂不存在!")
normal_status(-1, "课堂不存在!")
end
end
end
@ -146,7 +140,7 @@ class PollVotesController < ApplicationController
question_type = @poll_question&.question_type
if (question_type == 1) && params[:poll_answer_id].blank?
normal_status(-1,"答案ID错误!")
normal_status(-1, "答案ID错误!")
elsif question_type == 2
user_vote_count = params[:poll_answer_id].size
if @poll_question.max_choices.present?
@ -155,10 +149,10 @@ class PollVotesController < ApplicationController
question_max_choices = 0
end
if question_max_choices > 0 && (user_vote_count > question_max_choices)
normal_status(-1,"多选题答案超过最大限制!")
normal_status(-1, "多选题答案超过最大限制!")
end
elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3
normal_status(-1,"已提交/已结束的问卷不允许修改!")
normal_status(-1, "已提交/已结束的问卷不允许修改!")
end
end

@ -1,25 +1,25 @@
class PollsController < ApplicationController
# before_action :check_poll_status 问卷的发消息和定时任务没有做
before_action :require_login, :check_auth,except: [:index]
before_action :find_course, except: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer,:commit_poll,
:commit_result,:poll_lists,:cancel_publish,:cancel_publish_modal,:common_header,:publish_groups]
before_action :get_poll_and_course, only: [:show,:poll_setting,:commit_setting,:edit,:update,:start_answer,
:commit_poll,:commit_result,:poll_lists,:cancel_publish,
:cancel_publish_modal,:common_header, :publish_groups]
before_action :require_login, :check_auth, except: [:index]
before_action :find_course, except: [:show, :poll_setting, :commit_setting, :edit, :update, :start_answer, :commit_poll,
:commit_result, :poll_lists, :cancel_publish, :cancel_publish_modal, :common_header, :publish_groups]
before_action :get_poll_and_course, only: [:show, :poll_setting, :commit_setting, :edit, :update, :start_answer,
:commit_poll, :commit_result, :poll_lists, :cancel_publish,
:cancel_publish_modal, :common_header, :publish_groups]
before_action :user_course_identity
before_action :is_course_teacher, except: [:index,:start_answer,:poll_setting,:commit_poll,:commit_result,:poll_lists,:common_header] #判断是否为课堂老师
before_action :is_course_teacher, except: [:index, :start_answer, :poll_setting, :commit_poll, :commit_result, :poll_lists, :common_header] #判断是否为课堂老师
before_action :check_user_status
before_action :is_course_public, only: [:set_public]
before_action :check_user_on_answer, only: [:show,:start_answer,:commit_poll,:poll_lists] #判断当前用户在问卷的权限/老师是否属于分班的权限
before_action :validate_params, only: [:create,:update]
before_action :validates_multi_ids, only: [:publish,:end_poll,:destroys,:set_public,:join_poll_banks]
before_action :check_poll_setting_status,only: [:commit_setting]
before_action :get_questions_count ,only: [:start_answer,:show,:commit_result,:edit]
before_action :check_user_id_start_answer,only: [:start_answer]
before_action :check_poll_question_complete,only: [:commit_poll] #问卷提交前来判断问题是否完成
before_action :check_poll_commit_result,only: [:commit_result]
before_action :check_user_on_answer, only: [:show, :start_answer, :commit_poll, :poll_lists] #判断当前用户在问卷的权限/老师是否属于分班的权限
before_action :validate_params, only: [:create, :update]
before_action :validates_multi_ids, only: [:publish, :end_poll, :destroys, :set_public, :join_poll_banks]
before_action :check_poll_setting_status, only: [:commit_setting]
before_action :get_questions_count, only: [:start_answer, :show, :commit_result, :edit]
before_action :check_user_id_start_answer, only: [:start_answer]
before_action :check_poll_question_complete, only: [:commit_poll] #问卷提交前来判断问题是否完成
before_action :check_poll_commit_result, only: [:commit_result]
# before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户
before_action :get_left_banner_id, only:[:common_header,:start_answer,:new,:edit,:index]
before_action :get_left_banner_id, only: [:common_header, :start_answer, :new, :edit, :index]
include PollsHelper
def index
@ -66,7 +66,7 @@ class PollsController < ApplicationController
poll_setting_ids = @course.poll_group_settings.where("course_group_id = #{@member_group_id}").poll_group_not_published.pluck(:poll_id)
when 2
poll_setting_ids = @course.poll_group_settings.where("course_group_id = #{@member_group_id}")
.where("publish_time is not null and publish_time <= ? and end_time > ?",Time.now,Time.now).pluck(:poll_id)
.where("publish_time is not null and publish_time <= ? and end_time > ?", Time.now, Time.now).pluck(:poll_id)
when 3
poll_setting_ids = @course.poll_group_settings.where("course_group_id = #{@member_group_id}").poll_group_ended.pluck(:poll_id)
end
@ -83,7 +83,7 @@ class PollsController < ApplicationController
# 分页
@polls_select_count = @polls.size
@polls = @polls.order( "IF(ISNULL(publish_time),0,1), publish_time DESC,created_at DESC")
@polls = @polls.order("IF(ISNULL(publish_time),0,1), publish_time DESC,created_at DESC")
@page = params[:page] || 1
@limit = params[:limit] || 15
@ -126,7 +126,6 @@ class PollsController < ApplicationController
# un_anonymous 是否实名默认为false即不公开
def create
ActiveRecord::Base.transaction do
begin
poll_name = params[:polls_name]
poll_desc = params[:polls_description]
poll_options = {
@ -138,11 +137,6 @@ class PollsController < ApplicationController
:polls_type => "Course",
}
@poll = Poll.create!(poll_options)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("问卷创建失败!")
raise ActiveRecord::Rollback
end
end
end
@ -160,7 +154,6 @@ class PollsController < ApplicationController
def update
ActiveRecord::Base.transaction do
begin
poll_name = params[:polls_name]
poll_des = params[:polls_description]
poll_params = {
@ -168,12 +161,7 @@ class PollsController < ApplicationController
:polls_description => poll_des
}
@poll.update!(poll_params)
normal_status(0,"问卷更新成功!")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("没有权限")
raise ActiveRecord::Rollback
end
normal_status(0, "问卷更新成功!")
end
end
@ -207,8 +195,8 @@ class PollsController < ApplicationController
@user_poll_answer = 3 #教师页面
end
poll_id_array = [@poll.id]
@poll_publish_count = get_user_permission_course(poll_id_array,2).count #是否存在已发布的
@poll_unpublish_count = get_user_permission_course(poll_id_array,1).count #是否存在未发布的
@poll_publish_count = get_user_permission_course(poll_id_array, 2).count #是否存在已发布的
@poll_unpublish_count = get_user_permission_course(poll_id_array, 1).count #是否存在未发布的
if (@poll_publish_count == 0) && (@poll_unpublish_count == 0) #即表示没有分班
if @poll_status == 1
@ -231,7 +219,7 @@ class PollsController < ApplicationController
begin
poll_ids = params[:check_ids]
if poll_ids.count > 0
@course_groups = get_user_permission_course(poll_ids,1)
@course_groups = get_user_permission_course(poll_ids, 1)
else
@course_groups = []
end
@ -258,23 +246,21 @@ class PollsController < ApplicationController
if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_end_times = params[:group_end_times].reject(&:blank?).map {|time| time.to_time}
tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time|
tip_exception("分班截止时间不能早于当前时间") if time <= Time.now
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && time > @course.end_date.end_of_day
tip_exception("分班截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if @course.end_date.present? && time > @course.end_date.end_of_day
end
end
ActiveRecord::Base.transaction do
begin
check_ids = Poll.where(id: params[:check_ids])
ex_end_time = params[:end_time].blank? ? Time.at(((1.month.since.to_i)/3600.0).ceil * 3600) : params[:end_time].to_time
ex_end_time = params[:end_time].blank? ? Time.at(((1.month.since.to_i) / 3600.0).ceil * 3600) : params[:end_time].to_time
check_ids.each do |poll|
if poll.unified_setting
pl_status = poll.polls_status #则为试卷的状态
@ -294,7 +280,7 @@ class PollsController < ApplicationController
else
poll_unified = false
g_course.each_with_index do |i, index|
poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id寻找问卷所在的班级
poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id", i).first #根据课堂分班的id寻找问卷所在的班级
group_end_time = params[:detail] ? group_end_times[index] : ex_end_time
if poll_group_setting.present? #如果该问卷分组存在,则更新,否则新建
poll_group_setting.update!(publish_time: Time.now, end_time: group_end_time)
@ -318,7 +304,7 @@ class PollsController < ApplicationController
poll_unified = true
e_time = ex_end_time
end
poll_status = set_poll_status(Time.now,e_time)
poll_status = set_poll_status(Time.now, e_time)
poll_params = {
:publish_time => Time.now,
@ -328,7 +314,7 @@ class PollsController < ApplicationController
}
poll.update!(poll_params)
if poll.course_acts.size == 0
poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id)
poll.course_acts << CourseActivity.new(:user_id => poll.user_id, :course_id => poll.course_id)
end
PollPublishNotifyJob.perform_later(poll.id, g_course)
end
@ -350,7 +336,7 @@ class PollsController < ApplicationController
begin
poll_ids = params[:check_ids]
if poll_ids.count > 0
@course_groups = get_user_permission_course(poll_ids,3)
@course_groups = get_user_permission_course(poll_ids, 3)
else
@course_groups = []
end
@ -385,12 +371,12 @@ class PollsController < ApplicationController
poll_users = poll_unified ? poll.poll_users :
poll.poll_users.joins("join course_members on poll_users.user_id = course_members.user_id").where(course_members: {course_group_id: g_course, role: 4})
poll_group_setting = poll.poll_group_settings
old_poll_groups = poll_group_setting.find_in_poll_group("course_group_id",g_course) #问卷分组的截止时间更改
old_poll_groups = poll_group_setting.find_in_poll_group("course_group_id", g_course) #问卷分组的截止时间更改
old_poll_groups.update_all(:end_time => Time.now)
new_end_time = poll_group_setting.end_time_present.map(&:end_time) # 问卷结束时间不为空的
new_end_time_s = new_end_time.size > 0 ? new_end_time.max : Time.now
new_poll_status = set_poll_status(poll.publish_time,new_end_time_s)
poll.update!(:end_time => new_end_time_s,:polls_status => new_poll_status,:unified_setting => poll_unified)
new_poll_status = set_poll_status(poll.publish_time, new_end_time_s)
poll.update!(:end_time => new_end_time_s, :polls_status => new_poll_status, :unified_setting => poll_unified)
elsif poll.unified_setting
poll_users = poll.poll_users
poll.update!(:polls_status => 3, :end_time => Time.now)
@ -414,7 +400,7 @@ class PollsController < ApplicationController
begin
poll_ids = [@poll.id]
if poll_ids.count > 0
@course_groups = get_user_permission_course(poll_ids,2)
@course_groups = get_user_permission_course(poll_ids, 2)
else
@course_groups = []
end
@ -433,12 +419,12 @@ class PollsController < ApplicationController
g_course = params[:group_ids]
if !@poll.unified_setting #如果问卷为分班设置且传入的班级id存在
if g_course.present?
course_group_ids = @course.course_members.course_find_by_ids("course_group_id",g_course).pluck(:user_id).uniq #传入班级的全部学生人数
all_poll_settings = @poll.poll_group_settings.find_in_poll_group("course_group_id",g_course) #根据传入的班级id来获取问卷的分组设置
course_group_ids = @course.course_members.course_find_by_ids("course_group_id", g_course).pluck(:user_id).uniq #传入班级的全部学生人数
all_poll_settings = @poll.poll_group_settings.find_in_poll_group("course_group_id", g_course) #根据传入的班级id来获取问卷的分组设置
all_poll_settings.destroy_all #问卷的设置文件全部删除
# @poll.poll_users.find_by_group_ids(course_group_ids).destroy_all #问卷的提交信息
poll_question_ids = @poll.poll_questions.pluck(:id) #问卷的全部问卷
PollVote.find_current_vote("user_id",course_group_ids).find_current_vote("poll_question_id",poll_question_ids).destroy_all
PollVote.find_current_vote("user_id", course_group_ids).find_current_vote("poll_question_id", poll_question_ids).destroy_all
poll_user_options = {
:commit_status => 0,
:start_at => nil,
@ -456,7 +442,7 @@ class PollsController < ApplicationController
if p_time.nil? #发布时间为空,则表示问卷未发布
poll_status = 1
elsif p_time.present? && e_time.present?
poll_status = set_poll_status(p_time,e_time)
poll_status = set_poll_status(p_time, e_time)
end
else
unified_setting = true
@ -471,9 +457,9 @@ class PollsController < ApplicationController
:end_time => e_time
}
@poll.update!(poll_options)
normal_status(0,"分班问卷撤销发布成功!")
normal_status(0, "分班问卷撤销发布成功!")
else
normal_status(-1,"请选择撤销发布班级!")
normal_status(-1, "请选择撤销发布班级!")
end
else
poll_user_options = {
@ -483,7 +469,7 @@ class PollsController < ApplicationController
}
@poll.poll_users.update_all(poll_user_options)
poll_question_ids = @poll.poll_questions.pluck(:id)
PollVote.find_current_vote("poll_question_id",poll_question_ids).destroy_all
PollVote.find_current_vote("poll_question_id", poll_question_ids).destroy_all
poll_new_params = {
:polls_status => 1,
:publish_time => nil,
@ -492,7 +478,7 @@ class PollsController < ApplicationController
}
@poll.update!(poll_new_params)
@poll.poll_group_settings.destroy_all
normal_status(0,"问卷撤销发布成功!")
normal_status(0, "问卷撤销发布成功!")
## @poll.tidings.destroy_all 用户的发送消息全部删除,因接口未定,所以先注释
@ -510,7 +496,7 @@ class PollsController < ApplicationController
def destroys
ActiveRecord::Base.transaction do
begin
check_ids = Poll.where(id:params[:check_ids])
check_ids = Poll.where(id: params[:check_ids])
check_ids.each do |poll|
if poll.present?
poll.destroy
@ -529,7 +515,7 @@ class PollsController < ApplicationController
def set_public
ActiveRecord::Base.transaction do
begin
check_ids = Poll.where(id:params[:check_ids])
check_ids = Poll.where(id: params[:check_ids])
check_ids.each do |poll|
poll.update!(is_public: true)
end
@ -548,7 +534,7 @@ class PollsController < ApplicationController
begin
check_ids = Poll.where(id: params[:check_ids])
check_ids.each do |poll|
current_ex_bank = current_user.exercise_banks.find_by_container(poll.id,"Poll").first
current_ex_bank = current_user.exercise_banks.find_by_container(poll.id, "Poll").first
if current_ex_bank.present? #当前用户的选择问卷是否已加入习题库,存在则更新习题库和问题库,否则新建习题库和问题库
ex_params = {
:name => poll.polls_name,
@ -556,7 +542,7 @@ class PollsController < ApplicationController
:course_list_id => poll.course.try(:course_list_id)
}
current_ex_bank.update!(ex_params)
question_bank = QuestionBank.ques_by_container(current_ex_bank.id,current_ex_bank.container_type) #该习题库是否存在于问题库里
question_bank = QuestionBank.ques_by_container(current_ex_bank.id, current_ex_bank.container_type) #该习题库是否存在于问题库里
ques_params = {
:name => current_ex_bank.name,
:course_list_id => current_ex_bank.course_list_id
@ -574,7 +560,7 @@ class PollsController < ApplicationController
:container_type => "Poll",
:quotes => 1
}
current_ex_bank= ExerciseBank.new ex_params
current_ex_bank = ExerciseBank.new ex_params
if current_ex_bank.save! #如果习题库保存成功则会创建问题库question_bank
ques_params = {
:name => current_ex_bank.name,
@ -692,9 +678,9 @@ class PollsController < ApplicationController
@user_permission = 2
@user_course_groups = @course.teacher_group(current_user.id) #当前老师的分班
@being_setting_course_ids = @poll.poll_published_ids(current_user.id) #当前用户已发布的班级的id
@user_published_setting = @poll.poll_group_settings.find_in_poll_group("course_group_id",@being_setting_course_ids)
@user_published_setting = @poll.poll_group_settings.find_in_poll_group("course_group_id", @being_setting_course_ids)
poll_ids = [@poll.id]
@poll_publish_count = get_user_permission_course(poll_ids,2).count
@poll_publish_count = get_user_permission_course(poll_ids, 2).count
rescue Exception => e
uid_logger_error(e.message)
@ -725,19 +711,18 @@ class PollsController < ApplicationController
tip_exception("发布时间不能为空") if params[:publish_time].blank?
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if @course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day
params_publish_time = params[:publish_time].to_time
params_end_time = params[:end_time].to_time
if poll_status != 1 && @poll.publish_time != params_publish_time
normal_status(-1,"不允许修改发布时间")
normal_status(-1, "不允许修改发布时间")
elsif params_publish_time.present? && params_end_time.present? && params_end_time < params_publish_time
normal_status(-1,"截止时间不能小于发布时间")
normal_status(-1, "截止时间不能小于发布时间")
else
#发布时间小于当前时间则poll显示为未发布,当截止时间大于当前时间,则显示为已截止
poll_status_n = set_poll_status(params_publish_time,params_end_time)
poll_status_n = set_poll_status(params_publish_time, params_end_time)
poll_params = {
:unified_setting => unified_setting,
:show_result => show_result,
@ -752,23 +737,22 @@ class PollsController < ApplicationController
end
else
params_times = params[:publish_time_groups] #分班返回的json数组{"publish_time_groups":[{"course_group_id":["1","2"],"publish_time":"xx","end_time":"xxx"}]}
poll_groups = @poll.poll_group_settings.find_in_poll_group("course_id",@course.id) #当前课堂问卷的班级全部分班信息
poll_groups = @poll.poll_group_settings.find_in_poll_group("course_id", @course.id) #当前课堂问卷的班级全部分班信息
poll_groups_ids = poll_groups.pluck(:course_group_id) #问卷的全部分班id
total_common = params_times.map{|k| k[:course_group_id]}.sum #传入的所有分组的分班id
total_common = params_times.map {|k| k[:course_group_id]}.sum #传入的所有分组的分班id
total_common_group = poll_groups_ids & total_common #传入的分班与问卷已存在的分班的交集
old_poll_groups = poll_groups_ids - total_common_group #后来传入的分班里,没有了的班级,即需要删除
params_times.each do |t|
tip_exception("发布时间不能为空") if t[:publish_time].blank?
tip_exception("截止时间不能为空") if t[:end_time].blank?
tip_exception("截止时间不能早于发布时间") if t[:publish_time].to_time > t[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && t[:end_time].to_time > @course.end_date.end_of_day
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if @course.end_date.present? && t[:end_time].to_time > @course.end_date.end_of_day
course_id = t[:course_group_id]
poll_publish_time = t[:publish_time].to_time
poll_end_time = t[:end_time].to_time
poll_group = poll_groups.find_in_poll_group("course_group_id",course_id) #判断该分班是否存在
poll_group = poll_groups.find_in_poll_group("course_group_id", course_id) #判断该分班是否存在
if poll_group.present? && (poll_group.first.publish_time < Time.now) && (poll_publish_time != poll_group.first.publish_time)
error_count += 1
@ -781,14 +765,14 @@ class PollsController < ApplicationController
common_group = poll_groups_ids & course_id #传入的班级与问卷已存在的班级的交集,即表示已有分班的
new_group_ids = course_id - common_group #新传入的班级id
if common_group.size > 0 #传入的参数存在已发布的分班
poll_group = poll_groups.find_in_poll_group("course_group_id",common_group)
poll_group = poll_groups.find_in_poll_group("course_group_id", common_group)
poll_group.each do |the_group_setting|
poll_group_params = {
:publish_time => poll_publish_time,
:end_time => poll_end_time
}
the_group_setting_status = set_poll_status(the_group_setting.publish_time,the_group_setting.end_time)
the_group_setting_status = set_poll_status(the_group_setting.publish_time, the_group_setting.end_time)
if the_group_setting_status == 2
poll_group_params = {
:publish_time => the_group_setting.publish_time,
@ -821,11 +805,11 @@ class PollsController < ApplicationController
if error_count > 0
error_count == 0
normal_status(-1,"已发布/已截止的问卷不允许修改时间")
normal_status(-1, "已发布/已截止的问卷不允许修改时间")
else
# 未发布的分班设置才能删除
if old_poll_groups.size > 0
old_all_poll_groups = poll_groups.find_in_poll_group("course_group_id",old_poll_groups).poll_group_not_published
old_all_poll_groups = poll_groups.find_in_poll_group("course_group_id", old_poll_groups).poll_group_not_published
old_all_poll_groups.destroy_all
end
#问卷更新为poll_group_setting的发布时间最小截止时间最大
@ -837,7 +821,7 @@ class PollsController < ApplicationController
if p_time.nil? #发布时间为空,则表示问卷未发布
poll_status = 1
elsif p_time.present? && e_time.present?
poll_status = set_poll_status(p_time,e_time)
poll_status = set_poll_status(p_time, e_time)
end
poll_params = {
@ -851,7 +835,7 @@ class PollsController < ApplicationController
@poll.update!(poll_params)
if @poll.polls_status == 2
if @poll.course_acts.size == 0
@poll.course_acts << CourseActivity.new(:user_id => @poll.user_id,:course_id => @poll.course_id)
@poll.course_acts << CourseActivity.new(:user_id => @poll.user_id, :course_id => @poll.course_id)
end
end
normal_status(0, "问卷设置成功!")
@ -870,7 +854,7 @@ class PollsController < ApplicationController
def start_answer
ActiveRecord::Base.transaction do
begin
poll_user_current = PollUser.where(user_id:@poll_current_user_id,poll_id:@poll.id)&.first #查找当前用户是否有过答题
poll_user_current = PollUser.where(user_id: @poll_current_user_id, poll_id: @poll.id)&.first #查找当前用户是否有过答题
@poll_status = @poll.get_poll_status(current_user)
if poll_user_current.blank?
if @user_course_identity > Course::ASSISTANT_PROFESSOR #当为老师的时候不创建poll_user表理论上老师是不能进入答题的
@ -897,7 +881,7 @@ class PollsController < ApplicationController
# 判断是否已经回答还是新建的回答
@poll_questions.each do |q|
ques_vote = q.poll_votes.find_current_vote("user_id",@poll_current_user_id)
ques_vote = q.poll_votes.find_current_vote("user_id", @poll_current_user_id)
ques_type = q.question_type
if ques_type != 3 #非简答题时
@ -941,13 +925,13 @@ class PollsController < ApplicationController
def commit_poll
ActiveRecord::Base.transaction do
begin
@poll_multi_questions = @poll.poll_questions.where(question_type:2).select(:id,:max_choices,:min_choices,:question_number)
@poll_multi_questions = @poll.poll_questions.where(question_type: 2).select(:id, :max_choices, :min_choices, :question_number)
error_question = []
@poll_multi_questions.each do |q|
poll_user_votes = current_user.poll_votes.where(poll_question_id:q.id)&.size
poll_user_votes = current_user.poll_votes.where(poll_question_id: q.id)&.size
if q.max_choices.present? && (q.max_choices > 0) && (poll_user_votes > q.max_choices)
error_messages = "#{q.question_number}题:超过最大选项限制"
elsif q.min_choices.present? && (q.min_choices > 0)&& (poll_user_votes < q.min_choices)
elsif q.min_choices.present? && (q.min_choices > 0) && (poll_user_votes < q.min_choices)
error_messages = "#{q.question_number}题:不得少于最小选项限制"
else
error_messages = nil
@ -980,7 +964,7 @@ class PollsController < ApplicationController
def commit_result
ActiveRecord::Base.transaction do
begin
@poll_users = @poll.all_poll_users(current_user.id).where(commit_status:1) # 问卷已提交的用户
@poll_users = @poll.all_poll_users(current_user.id).where(commit_status: 1) # 问卷已提交的用户
@poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1
@limit = params[:limit] || 10
@ -988,18 +972,18 @@ class PollsController < ApplicationController
@poll_questions = @poll_questions.page(@page).per(@limit)
if params[:format] == "xlsx"
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
tip_exception(403, "无权限操作")
elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0)
normal_status(-1,"暂无用户提交")
normal_status(-1, "暂无用户提交")
elsif params[:export].present? && params[:export]
normal_status(0,"正在下载中")
normal_status(0, "正在下载中")
else
respond_to do |format|
format.xlsx{
format.xlsx {
set_export_cookies
polls_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
polls_user_commit = poll_commit_result(@poll,@poll_export_questions,@poll_users,@poll_commit_ids)
render xlsx: "#{polls_export_name_.strip}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit}
polls_user_commit = poll_commit_result(@poll, @poll_export_questions, @poll_users, @poll_commit_ids)
render xlsx: "#{polls_export_name_.strip}", template: "polls/commit_result.xlsx.axlsx", locals: {polls_user_commit: polls_user_commit}
}
end
end
@ -1018,8 +1002,8 @@ class PollsController < ApplicationController
begin
poll_ids = [@poll.id]
@poll_list_status = @poll.get_poll_status(current_user)
@poll_publish_count = get_user_permission_course(poll_ids,2).count
@poll_unpublish_count = get_user_permission_course(poll_ids,1).count
@poll_publish_count = get_user_permission_course(poll_ids, 2).count
@poll_unpublish_count = get_user_permission_course(poll_ids, 1).count
@course_all_members = @course.students
@poll_group_counts = @course.course_groups_count
@ -1028,7 +1012,7 @@ class PollsController < ApplicationController
@poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生
get_poll_answers(@poll_users_list, @poll_list_status)
if @poll_list_status == 1
@poll_course_groups =[]
@poll_course_groups = []
else
poll_common_ids = @poll.poll_published_ids(current_user.id)
@poll_course_groups = @course.get_ex_published_course(poll_common_ids)
@ -1080,7 +1064,7 @@ class PollsController < ApplicationController
#班级的选择
if group_id.present?
poll_students = @course_all_members.course_find_by_ids("course_group_id",group_id) # 问卷所分班的全部人数
poll_students = @course_all_members.course_find_by_ids("course_group_id", group_id) # 问卷所分班的全部人数
user_ids = poll_students.pluck(:user_id).reject(&:blank?)
@poll_users_list = @poll_users_list.find_by_group_ids(user_ids)
end
@ -1134,8 +1118,8 @@ class PollsController < ApplicationController
end
def poll_params
params.require(:poll).permit(:polls_name,:polls_status,:publish_time,:end_time,:polls_description,
:show_result,:exercise_bank_id,:is_public,:unified_setting,:un_anonymous)
params.require(:poll).permit(:polls_name, :polls_status, :publish_time, :end_time, :polls_description,
:show_result, :exercise_bank_id, :is_public, :unified_setting, :un_anonymous)
end
# 获得问卷及课堂
@ -1176,7 +1160,7 @@ class PollsController < ApplicationController
def check_unified_setting?(poll) #问卷是否统一设置,如为分班设置,当前用户是否在班级内
if !poll.unified_setting #如果为分班设置,则需判断用户是否在班级内
poll_group_settings = poll.poll_group_settings.pluck(:course_group_id)
member = @course.course_members.course_find_by_ids("user_id",current_user.id)
member = @course.course_members.course_find_by_ids("user_id", current_user.id)
member_group_id = member.pluck(:course_group_id).uniq
if (member_group_id & poll_group_settings).size > 0 || @user_course_identity < Course::STUDENT
true
@ -1196,7 +1180,7 @@ class PollsController < ApplicationController
end
end
def set_poll_status(publish_time,end_time)
def set_poll_status(publish_time, end_time)
time_now_i = Time.now
if publish_time.present? && end_time.present? && publish_time <= time_now_i && end_time > time_now_i
2
@ -1217,20 +1201,20 @@ class PollsController < ApplicationController
@poll_question_singles = @poll_questions.ques_count(1).size # 单选题
@poll_question_doubles = @poll_questions.ques_count(2).size # 多选题
@poll_question_mains = @poll_questions.ques_count(3).size #主观题
@poll_questions = @poll_questions&.includes(:poll_answers,:poll_votes).distinct
@poll_questions = @poll_questions&.includes(:poll_answers, :poll_votes).distinct
end
def check_poll_question_complete #commit_poll 的权限
poll_user_current = @poll.poll_users.find_by_group_ids(current_user.id).first
poll_status = @poll.get_poll_status(current_user)
if @user_course_identity < Course::STUDENT || (poll_status == 3) || (poll_user_current.present? && poll_user_current.commit_status == 1)
normal_status(-1,"用户没有权限!") #老师/管理员在提交时没有权限
normal_status(-1, "用户没有权限!") #老师/管理员在提交时没有权限
else
necessary_answer = 0
poll_questions = @poll.poll_questions
necessary_question = poll_questions.ques_necessary # 问卷必答的问题
necessary_question.each do |q|
user_vote = q.poll_votes.find_current_vote("user_id",current_user.id)
user_vote = q.poll_votes.find_current_vote("user_id", current_user.id)
vote_answer_id = user_vote.pluck(:poll_answer_id).reject(&:blank?).size
vote_text_count = user_vote.pluck(:vote_text).reject(&:blank?).size
if vote_answer_id == 0 && vote_text_count == 0
@ -1238,7 +1222,7 @@ class PollsController < ApplicationController
end
end
if necessary_answer > 0
normal_status(-1,"问卷提交失败,有#{necessary_answer}个未答的必答题!")
normal_status(-1, "问卷提交失败,有#{necessary_answer}个未答的必答题!")
end
end
end
@ -1247,7 +1231,7 @@ class PollsController < ApplicationController
poll_status = @poll.get_poll_status(current_user)
commit_poll_user = @poll.poll_users.find_by_group_ids(current_user.id).commit_by_status(1) #当前用户已提交问卷的
unless (@user_course_identity < Course::STUDENT) || ((@poll.show_result == 1) && (poll_status == 3) && commit_poll_user.present?)
normal_status(-1,"没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的
normal_status(-1, "没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的
end
end
@ -1255,11 +1239,11 @@ class PollsController < ApplicationController
user_login = params[:login]
# @poll_current_user_id = params[:user_id]
if user_login.blank? && @user_course_identity < Course::STUDENT #id不存在且当前为老师/管理员等
normal_status(-1,"请输入学生登陆名!")
normal_status(-1, "请输入学生登陆名!")
else
@answer_user = User.find_by(login:user_login)
@answer_user = User.find_by(login: user_login)
if @answer_user.blank?
normal_status(404,"答题用户不存在")
normal_status(404, "答题用户不存在")
else
@poll_current_user_id = @answer_user.id || current_user.id
end
@ -1273,11 +1257,11 @@ class PollsController < ApplicationController
@poll_questions_count = @poll_questions.size
end
def get_user_permission_course(poll_ids,status) #获取用户权限范围内的已发布/未发布
def get_user_permission_course(poll_ids, status) #获取用户权限范围内的已发布/未发布
poll_status = status.to_i
unpublish_group = []
user_groups_id = @course.charge_group_ids(current_user)
all_polls = Poll.where(id:poll_ids)
all_polls = Poll.where(id: poll_ids)
all_polls.each do |poll|
if poll.present?
if poll.unified_setting
@ -1317,28 +1301,28 @@ class PollsController < ApplicationController
publish_course = params[:publish_time_groups]
unified_setting = params[:unified_setting]
if @course.is_end
normal_status(-1,"课堂已结束不能再修改!")
normal_status(-1, "课堂已结束不能再修改!")
elsif unified_setting
poll_group_settings = @poll.poll_group_settings
if poll_group_settings.present?
p_time_present = poll_group_settings.publish_time_present.map(&:publish_time).min
if p_time_present < Time.now
normal_status(-1,"设置失败,存在已发布的分班!")
normal_status(-1, "设置失败,存在已发布的分班!")
end
elsif params[:publish_time].blank?
normal_status(-1,"发布时间不允许为空")
normal_status(-1, "发布时间不允许为空")
end
elsif unified_setting.present? && !unified_setting #非统一设置,分班不能为空
if publish_course.present?
course_ids = publish_course.map{|a| a[:course_group_id]}.sum
publish_t = publish_course.map{|a| a[:publish_time]}
course_ids = publish_course.map {|a| a[:course_group_id]}.sum
publish_t = publish_course.map {|a| a[:publish_time]}
if course_ids.include?(nil) || course_ids.count == 0
normal_status(-1,"请选择分班!")
normal_status(-1, "请选择分班!")
elsif publish_t.include?(nil) || publish_t.count == 0
normal_status(-1,"发布时间不允许为空")
normal_status(-1, "发布时间不允许为空")
end
else
normal_status(-1,"请选择分班!")
normal_status(-1, "请选择分班!")
end
end
end
@ -1354,7 +1338,7 @@ class PollsController < ApplicationController
end
#问卷的统计结果的导出
def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids)
def poll_commit_result(poll, poll_questions, poll_users, poll_commit_ids)
sub_commit = []
user_commit = []
poll_users_info = %w(序号)
@ -1368,50 +1352,50 @@ class PollsController < ApplicationController
poll_users_info = poll_users_info + user_info + poll_ques_titles
poll_questions.each do |q|
if q.question_type != 3 #问题不为主观题
question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids)&.size #该问题的有效填写量
question_vote_user = q.poll_votes.find_current_vote("user_id", poll_commit_ids)&.size #该问题的有效填写量
sheet_row = ["#{q.question_number}"] #选择题答案选项的数组
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
sheet_answer_percent = ["比例"]
sheet_answer_useful = ["本题有效填写人次",question_vote_user]
sheet_answer_useful = ["本题有效填写人次", question_vote_user]
q.poll_answers.each do |a| #问卷的答案选项
answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids)&.size
answer_percent = (question_vote_user == 0) ? "0.0%" : "#{((answer_users_count / question_vote_user.to_f)*100).round(1).to_s}%"
answer_users_count = a.poll_votes.find_current_vote("user_id", poll_commit_ids)&.size
answer_percent = (question_vote_user == 0) ? "0.0%" : "#{((answer_users_count / question_vote_user.to_f) * 100).round(1).to_s}%"
sheet_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count)
sheet_answer_percent.push(answer_percent)
end
sheet_sub_commit = {
sub_title: sheet_row,
sub_user_votes:[sheet_answer_row,sheet_answer_percent,sheet_answer_useful]
sub_user_votes: [sheet_answer_row, sheet_answer_percent, sheet_answer_useful]
}
sub_commit.push(sheet_sub_commit)
else #主观题答案
user_votes= []
main_show_row = ["#{q.question_number}", q.question_title ]
q.poll_votes.each_with_index do |v,index| #主观题的答案
q_poll_vote = [(index+1), v.vote_text.present? ? v.vote_text : "--"]
user_votes = []
main_show_row = ["#{q.question_number}", q.question_title]
q.poll_votes.each_with_index do |v, index| #主观题的答案
q_poll_vote = [(index + 1), v.vote_text.present? ? v.vote_text : "--"]
user_votes.push(q_poll_vote)
end
sheet_sub_commit = {
sub_title: main_show_row,
sub_user_votes:user_votes
sub_user_votes: user_votes
}
sub_commit.push(sheet_sub_commit)
end
end #each_with_index
poll_users.includes(user: [:user_extension,:poll_votes]).each_with_index do |u,index|
poll_users.includes(user: [:user_extension, :poll_votes]).each_with_index do |u, index|
u_user = u.user
user_answer_array = []
poll_questions.each do |q|
user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id)
user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id", q.id)
if user_poll_votes.present?
if q.question_type < 3
user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?)
if user_poll_answer_ids.count > 0
answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids)
if user_poll_answer_ids.count >1
answer_content = q.poll_answers.find_answer_by_custom("id", user_poll_answer_ids)
if user_poll_answer_ids.count > 1
u_answer = answer_content.pluck(:answer_text).join(";")
else
u_answer = answer_content.first&.answer_text
@ -1436,23 +1420,23 @@ class PollsController < ApplicationController
end
user_answer_array.push(u_answer)
end
user_cell = [index+1]
user_cell = [index + 1]
if poll_un_anony
user_login = u_user.login
user_name = u_user.real_name.present? ? u_user.real_name : "--"
user_class = poll.course.user_group_name(u_user.id)
user_student_id = u_user.student_id.present? ? u_user.student_id : "--"
user_school_name = u_user.school_name.present? ? u_user.school_name : "--"
user_cell += [user_login,user_name, user_class, u_user.mail, user_student_id, user_school_name]
user_cell += [user_login, user_name, user_class, u_user.mail, user_student_id, user_school_name]
end
all_user_cell = user_cell + user_answer_array
user_commit.push(all_user_cell)
end
{
poll_users_info:poll_users_info,
sub_commit:sub_commit,
user_commit:user_commit
poll_users_info: poll_users_info,
sub_commit: sub_commit,
user_commit: user_commit
}
end

Loading…
Cancel
Save