删除某个题目后顺序排列

This commit is contained in:
huang 2015-11-20 20:55:37 +08:00
parent fc041d5e99
commit 550d056630
1 changed files with 3 additions and 3 deletions

View File

@ -275,12 +275,12 @@ class ExerciseController < ApplicationController
@exercise = @exercise_question.exercise @exercise = @exercise_question.exercise
if @exercise_question.question_type == 1 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") 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") #@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 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") ExerciseQuestion.where("question_number<? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1")
else else
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1") ExerciseQuestion.where("question_number<? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1")
end end
# @exercise_question_num = params[:quest_num].to_i # @exercise_question_num = params[:quest_num].to_i
# @exercise_questions.question_number = params[:quest_num].to_i - 1 # @exercise_questions.question_number = params[:quest_num].to_i - 1