From 4d1ff1f0e8521b04587775ecfa91065de47b31fb Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 18:32:21 +0800 Subject: [PATCH 1/3] fix bug --- app/controllers/exercise_questions_controller.rb | 16 ---------------- app/controllers/poll_questions_controller.rb | 8 -------- 2 files changed, 24 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 8c4eb0a89..dd0247f70 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -427,15 +427,6 @@ class ExerciseQuestionsController < ApplicationController delete_answer = question_choices.find_by(choice_position: choice_d_id) left_choices = question_choices.where("choice_position > ? ",choice_d_id) left_choices.update_all("choice_position = choice_position - 1") if left_choices - # delete_answer = question_choices.find_choice_custom("choice_position",choice_d_id).first - # - # left_choice = question_choices.left_choice_choose("choice_position",choice_d_id) - # if left_choice.present? - # left_choice.each do |p| - # p.choice_position -= 1 - # p.save - # end - # end if delete_answer.destroy normal_status(0, "答案删除成功!") else @@ -456,13 +447,6 @@ class ExerciseQuestionsController < ApplicationController exercise_questions = @exercise.exercise_questions left_questions = exercise_questions.where("question_number > ?", question_d_id) left_questions.update_all("question_number = question_number - 1") if left_questions - # left_question = exercise_questions.left_question_choose("question_number",question_d_id) - # if left_question.present? - # left_question.each do |q| - # q.question_number -= 1 - # q.save - # end - # end if @exercise_question.destroy normal_status(0, "问题删除成功!") else diff --git a/app/controllers/poll_questions_controller.rb b/app/controllers/poll_questions_controller.rb index c7407c129..84e21c4e8 100644 --- a/app/controllers/poll_questions_controller.rb +++ b/app/controllers/poll_questions_controller.rb @@ -160,14 +160,6 @@ class PollQuestionsController < ApplicationController left_answers = poll_answers.where("answer_position > ?",answer_d_id) left_answers.update_all("answer_position = answer_position - 1") if left_answers - # delete_answer = poll_answers.find_answer_by_custom("answer_position",answer_d_id).first - # left_answer = poll_answers.left_answer_choose("answer_position",answer_d_id) - # if left_answer.present? - # left_answer.each do |p| - # p.answer_position -= 1 - # p.save - # end - # end if delete_answer.destroy normal_status(0, "答案删除成功!") else From 0946b44fadf3db54e62b5f3458ebe5c3b0b3cca6 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 08:42:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=BC=80=E5=90=AF=E6=8C=91=E6=88=98?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=85=B3=E5=8D=A1=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index a319dc58a..d9588cb5b 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -557,7 +557,7 @@ class ShixunsController < ApplicationController # HomeworksService.new.update_myshixun_work_status myshixun UpdateMyshixunWorkStatusJob.perform_later(myshixun.id) - @current_task = myshixun.current_task + @current_task = myshixun.current_task(myshixun.games) uid_logger("## shixun exec: myshixun id is #{myshixun.id}") rescue Exception => e uid_logger_error(e.message) From 6f97f3e6c94891c72bb8e813f410f9427c114478 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 09:01:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index f2a964c8d..e315ab596 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -5,8 +5,8 @@ class ChallengesController < ApplicationController before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up, :edit_choose_question, :show_choose_question, :destroy_challenge_choose, :update_choose_question, :destroy, :crud_answer, :answer] - # before_action :allowed, except: [:index, :show, :edit_choose_question, :edit] - + # 权限控制 + before_action :allowed, except: [:index] include ShixunsHelper include ChallengesHelper @@ -296,8 +296,7 @@ class ChallengesController < ApplicationController end def allowed - # 实训为发布前,除实训的管理者外,其他人都不人都不允许访问 - if !current_user.manager_of_shixun?(@shixun) && (@shixun.status < 1 || @shixun.hidden == 1) + unless current_user.manager_of_shixun?(@shixun) raise Educoder::TipException.new(403, "..") end end