diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15e795bdb..ccf52049c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 8825 end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f64688deb..98be8c699 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -11,7 +11,7 @@ class HomeworkCommonsController < ApplicationController before_action :find_homework, only: [:edit, :show, :update, :group_list, :homework_code_repeat, :code_review_results, :code_review_detail, :show_comment, :settings, :works_list, :update_settings, :reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation, - :update_score, :update_student_score, :batch_comment] + :update_score, :update_student_score, :batch_comment, :get_next_work] before_action :user_course_identity before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score] @@ -287,6 +287,15 @@ class HomeworkCommonsController < ApplicationController end end + def get_next_work + member = @course.course_member(current_user.id) + student_works = @homework.teacher_works(member).where.not(id: @homework.student_works_scores.where(reviewer_role: [1, 2])) + if params[:work_id] + student_works = student_works.where.not(id: params[:work_id]) + end + @work = student_works.where("work_status > 0").take + end + def update_score tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now @homework.update_homework_work_score diff --git a/app/views/homework_commons/get_next_work.json.jbuilder b/app/views/homework_commons/get_next_work.json.jbuilder new file mode 100644 index 000000000..e03b18970 --- /dev/null +++ b/app/views/homework_commons/get_next_work.json.jbuilder @@ -0,0 +1,2 @@ +json.work_id @work&.id +json.user_name @work&.user&.real_name \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 047141ea8..da07c8d89 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -597,6 +597,7 @@ Rails.application.routes.draw do get :update_score get :update_student_score post :batch_comment + get :get_next_work end collection do