From fbb0f33135ebae2cb5d21a40033fa1355d39ed3a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 7 Feb 2020 19:37:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E4=BD=9C=E4=B8=9A=E6=8C=89=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 1f66555f9..6e6eb04fa 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -248,7 +248,7 @@ class SubjectsController < ApplicationController def send_to_course @course = Course.find_by!(id: params[:course_id]) stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id)) - + order_ids = params[:shixun_ids].size > 0 ? params[:shixun_ids].reverse.join(',') : -1 course_module = @course.course_modules.where(module_type: "shixun_homework").first homework_ids = [] @@ -259,7 +259,8 @@ class SubjectsController < ApplicationController CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework", course_module_id: course_module.id, position: course_module.course_second_categories.count + 1) - stage.shixuns.no_jupyter.where(id: params[:shixun_ids], status: 2).each do |shixun| + shixuns = stage.shixuns.no_jupyter.published.where(id: params[:shixun_ids]).order("field(id, #{order_ids})") + shixuns.each do |shixun| homework = HomeworksService.new.create_homework shixun, @course, category, current_user homework_ids << homework.id end From 3c8bcc347ba13b1ca299acd9f4d0a1474a975bad Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 7 Feb 2020 19:47:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E4=BD=9C=E4=B8=9A=E6=8C=89=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 6e6eb04fa..1dd1d73a2 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -259,7 +259,7 @@ class SubjectsController < ApplicationController CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework", course_module_id: course_module.id, position: course_module.course_second_categories.count + 1) - shixuns = stage.shixuns.no_jupyter.published.where(id: params[:shixun_ids]).order("field(id, #{order_ids})") + shixuns = stage.shixuns.no_jupyter.published.where(id: params[:shixun_ids]).order("field(shixuns.id, #{order_ids})") shixuns.each do |shixun| homework = HomeworksService.new.create_homework shixun, @course, category, current_user homework_ids << homework.id From 83f596248b38b189f91477d48a134925cfdfba44 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 7 Feb 2020 19:54:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E4=BD=9C=E4=B8=9A=E6=8C=89=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 1dd1d73a2..77d89c40c 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -259,7 +259,7 @@ class SubjectsController < ApplicationController CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework", course_module_id: course_module.id, position: course_module.course_second_categories.count + 1) - shixuns = stage.shixuns.no_jupyter.published.where(id: params[:shixun_ids]).order("field(shixuns.id, #{order_ids})") + shixuns = stage.shixuns.no_jupyter.published.where(id: params[:shixun_ids]).reorder("field(shixuns.id, #{order_ids})") shixuns.each do |shixun| homework = HomeworksService.new.create_homework shixun, @course, category, current_user homework_ids << homework.id