From 13af6e64b272d141729386877a15c19fe5bae4e5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 12:55:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=9F=A5=E7=9C=8B=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index c3e5d9a67..77302c5db 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -419,7 +419,7 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) - + @exercise.update_attributes(:show_result => params[:exercise][:show_result]) redirect_to exercise_url(@exercise) # REDO: 提示提交成功 else From 302dfaf93380ef24179f3ff0fd1b8522063e5b01 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 13:04:51 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=B8=87=E5=8D=B7?= =?UTF-8?q?=E5=88=9D=E5=A7=8Bshowresult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 54f8309ea..3d6b4794f 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -59,7 +59,8 @@ class ExerciseController < ApplicationController :end_time => "", :publish_time => "", :exercise_description => "", - :show_result => "" + :show_result => "", + :show_result => 1 } @exercise = Exercise.create option if @exercise From 07ee81937056274fd0a1b38c68408673bce1511d Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 13:39:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E7=AD=94=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 3d6b4794f..9efcfc19d 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -345,7 +345,7 @@ class ExerciseController < ApplicationController end elsif eq.question_type == 2 #多选题 - ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id],User.current.id) + ea = ExerciseAnswer.find_by_exercise_choice_id_and_user_id(params[:exercise_choice_id],User.current.id) if ea.nil? #尚未答该题,添加答案 ea = ExerciseAnswer.new @@ -360,7 +360,7 @@ class ExerciseController < ApplicationController end else #pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案 - if pv.delete + if ea.delete @percent = get_percent(@exercise, User.current) render :json => {:text => "false" ,:percent => format("%.2f" , @percent)} else From cb3f0d1c97844d2a7fb62053be688425be185aea Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 14:28:47 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=8C=89=E7=B1=BB=E5=9E=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=BA=8F=E5=8F=B7=E9=80=92=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 9efcfc19d..cf78cbc05 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -142,7 +142,9 @@ class ExerciseController < ApplicationController option = { :question_title => question_title, :question_type => params[:question_type] || 1, - :question_number => @exercise.exercise_questions.count + 1, + :question_number => params[:question_type] == "1"? @exercise.exercise_questions.where("question_type = 1").count + 1 : + (params[:question_type] == "2" ? (@exercise.exercise_questions.where("question_type = 2").count + 1) : + @exercise.exercise_questions.where("question_type = 3").count + 1), :question_score => params[:question_score] } @exercise_questions = @exercise.exercise_questions.new option @@ -160,7 +162,14 @@ class ExerciseController < ApplicationController # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 if params[:quest_id] @is_insert = true - @exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1") + if @exercise_questions.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_questions.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 end