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