Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course
This commit is contained in:
commit
c36ec99ff6
|
@ -269,11 +269,23 @@ class ExerciseController < ApplicationController
|
|||
def delete_exercise_question
|
||||
@exercise_question = ExerciseQuestion.find params[:exercise_question]
|
||||
@exercise = @exercise_question.exercise
|
||||
exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}")
|
||||
exercise_questions.each do |question|
|
||||
question.question_number -= 1
|
||||
question.save
|
||||
|
||||
if @exercise_question.question_type == 1
|
||||
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number - 1")
|
||||
#@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1")
|
||||
elsif @exercise_question.question_type == 2
|
||||
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1")
|
||||
else
|
||||
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1")
|
||||
end
|
||||
# @exercise_question_num = params[:quest_num].to_i
|
||||
# @exercise_questions.question_number = params[:quest_num].to_i - 1
|
||||
#
|
||||
# exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}")
|
||||
# exercise_questions.each do |question|
|
||||
# question.question_number -= 1
|
||||
# question.save
|
||||
# end
|
||||
if @exercise_question && @exercise_question.destroy
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -431,7 +443,8 @@ class ExerciseController < ApplicationController
|
|||
# REDO: 提示提交成功
|
||||
else
|
||||
# 更新提交状态
|
||||
@exercise.exercise_users.first.update_attributes(:status => true)
|
||||
cur_exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current, @exercise.id).first
|
||||
cur_exercise_user.update_attributes(:status => 1)
|
||||
# 答题过程中需要统计完成量
|
||||
@uncomplete_question = get_uncomplete_question(@exercise, User.current)
|
||||
# 获取改学生的考试得分
|
||||
|
@ -568,7 +581,9 @@ class ExerciseController < ApplicationController
|
|||
exercises = course.exercises.where("exercise_name=?","")
|
||||
unless exercises.empty?
|
||||
exercises.each do |exercise|
|
||||
exercise.destroy
|
||||
if exercise.exercise_questions.empty?
|
||||
exercise.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue