dev_course
SylorHuang 6 years ago
parent dcec641b5b
commit 203ccd383c

@ -127,7 +127,7 @@ class ExerciseQuestionsController < ApplicationController
shixun_scores = params[:question_scores] #试卷有多个的分值有多个分数表,所以为分数的数组 shixun_scores = params[:question_scores] #试卷有多个的分值有多个分数表,所以为分数的数组
shixun_name = params[:shixun_name] || shixun.name shixun_name = params[:shixun_name] || shixun.name
question_score = 0 question_score = 0
shixun.challenges.each_with_index do |challenge,index| shixun.challenges.try(:each_with_index) do |challenge,index|
shixun_option = { shixun_option = {
:challenge_id => challenge.id, :challenge_id => challenge.id,
:shixun_id => shixun.id, :shixun_id => shixun.id,

@ -181,31 +181,50 @@ class QuestionBanksController < ApplicationController
:shixun_id => q.shixun_id :shixun_id => q.shixun_id
} }
exercise_question = new_exercise.exercise_questions.new option exercise_question = new_exercise.exercise_questions.new option
# question_type5实训题其他是非实训题 if exercise_question.save
if q.question_type != 5 if q.question_type != 5
# 复制选择题题目选项 # 复制选择题题目选项
q.exercise_bank_choices.try(:each_with_index) do |choice, index| q.exercise_bank_choices.try(:each_with_index) do |choice, index|
exercise_question.exercise_choices.new({choice_position: index+1, choice_text: choice.choice_text}) exercise_question.exercise_choices.create({choice_position: index+1, choice_text: choice.choice_text})
end end
# 复制标准答案(填空题和问答题) 多空填空题的话应该是原标准答案的exercise_choice_id即为题空的位置。 # 复制标准答案(填空题和问答题) 多空填空题的话应该是原标准答案的exercise_choice_id即为题空的位置。
q.exercise_bank_standard_answers.try(:each) do |answer| q.exercise_bank_standard_answers.try(:each) do |answer|
exercise_question.exercise_standard_answers.new({exercise_choice_id: answer.exercise_bank_choice_id, answer_text: answer.answer_text}) exercise_question.exercise_standard_answers.create({exercise_choice_id: answer.exercise_bank_choice_id, answer_text: answer.answer_text})
end end
else else
# 复制实训题 # 复制实训题
q.exercise_bank_shixun_challenges.try(:each_with_index) do |sc, index| q.exercise_bank_shixun_challenges.try(:each_with_index) do |sc, index|
exercise_question.exercise_shixun_challenges.new({position: index+1, challenge_id: sc.challenge_id, exercise_question.exercise_shixun_challenges.create({position: index+1, challenge_id: sc.challenge_id,
shixun_id: sc.shixun_id, question_score: sc.question_score}) shixun_id: sc.shixun_id, question_score: sc.question_score})
end end
end end
end end
# question_type5实训题其他是非实训题
# if q.question_type != 5
# # 复制选择题题目选项
# q.exercise_bank_choices.try(:each_with_index) do |choice, index|
# exercise_question.exercise_choices.new({choice_position: index+1, choice_text: choice.choice_text})
# end
#
# # 复制标准答案(填空题和问答题) 多空填空题的话应该是原标准答案的exercise_choice_id即为题空的位置。
# q.exercise_bank_standard_answers.try(:each) do |answer|
# exercise_question.exercise_standard_answers.new({exercise_choice_id: answer.exercise_bank_choice_id, answer_text: answer.answer_text})
# end
# else
# # 复制实训题
# q.exercise_bank_shixun_challenges.try(:each_with_index) do |sc, index|
# exercise_question.exercise_shixun_challenges.new({position: index+1, challenge_id: sc.challenge_id,
# shixun_id: sc.shixun_id, question_score: sc.question_score})
# end
# end
end
# 添加学生 # 添加学生
# if new_exercise.save # if new_exercise.save
# new_exercise.create_exercise_list # new_exercise.create_exercise_list
# exercise.update_column(:quotes, exercise.quotes+1) # exercise.update_column(:quotes, exercise.quotes+1)
# end # end
new_exercise if new_exercise.save! # new_exercise if new_exercise.save!
end end
end end

@ -451,7 +451,7 @@ module ExercisesHelper
end end
end end
user_scores = answers_content.present? ? answers_content.score_reviewed.pluck(:score).sum : 0.0 user_scores = answers_content.present? ? answers_content.score_reviewed.pluck(:score).sum : 0.0
if user_scores > 0 if user_scores > 0.0
stand_answer = 1 stand_answer = 1
else else
stand_answer = 0 stand_answer = 0

@ -70,7 +70,7 @@ class ExercisePublishTask
Rails.logger.info("log--------------------------------exercise_end start") Rails.logger.info("log--------------------------------exercise_end start")
puts "--------------------------------exercise_end start" puts "--------------------------------exercise_end start"
# 1。统一设置的试卷 # 1。统一设置的试卷
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900) exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now)
exercises.each do |exercise| exercises.each do |exercise|
ex_type = exercise.exercise_questions.pluck(:question_type).uniq ex_type = exercise.exercise_questions.pluck(:question_type).uniq
exercise.update_column('exercise_status', 3) exercise.update_column('exercise_status', 3)
@ -98,7 +98,7 @@ class ExercisePublishTask
end end
# 2.非统一的试卷 # 2.非统一的试卷
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900) all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now)
exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")" exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")"
ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}") ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}")
ex_group_settings.each do |exercise_setting| ex_group_settings.each do |exercise_setting|

Loading…
Cancel
Save