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

@ -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, #默认为单选题
@ -141,11 +140,6 @@ class ExerciseQuestionsController < ApplicationController
@exercise_question.update!(:question_score => question_score, :shixun_name => shixun_name)
end
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 = {
@ -375,12 +362,6 @@ class ExerciseQuestionsController < ApplicationController
else
normal_status(0, "试卷更新成功!")
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
raise ActiveRecord::Rollback
end
end
end
@ -493,7 +474,6 @@ 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 #全部主观题得分
@ -668,11 +648,6 @@ class ExerciseQuestionsController < ApplicationController
end
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
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

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

@ -6,7 +6,6 @@ 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
@ -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

@ -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 = {
@ -169,11 +162,6 @@ class PollsController < ApplicationController
}
@poll.update!(poll_params)
normal_status(0, "问卷更新成功!")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("没有权限")
raise ActiveRecord::Rollback
end
end
end
@ -258,16 +246,14 @@ 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}
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
@ -725,8 +711,7 @@ 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
@ -761,8 +746,7 @@ class PollsController < ApplicationController
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

Loading…
Cancel
Save