diff --git a/app/controllers/managements/schools_controller.rb b/app/controllers/managements/schools_controller.rb index a5c789ff..4e9b41ed 100644 --- a/app/controllers/managements/schools_controller.rb +++ b/app/controllers/managements/schools_controller.rb @@ -78,5 +78,7 @@ class Managements::SchoolsController < Managements::BaseController @active_course_total = Course.where(is_end: false).count @shixun_homework_total = HomeworkCommon.where(homework_type: 4).count @other_homework_total = HomeworkCommon.where(homework_type: [1, 3]).count + @shixun_total = Shixun.count + @shixun_evaluate_total = Game.sum(:evaluate_count) end end diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 937e4ecd..08f4516e 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -528,11 +528,12 @@ class GamesService # 三类实训只取基础部分数据 game = Game.select([:myshixun_id, :status, :challenge_id, :id, :evaluate_count]).find_by_identifier(params[:identifier]) myshixun = Myshixun.select([:updated_at, :gpid, :id, :shixun_id]).find(game.myshixun_id) - shixun = Shixun.select([:id, :evaluate_script, :webssh, :exec_time, :sigle_training, :identifier, :status]).find(myshixun.shixun_id) + shixun = Shixun.select([:id, :evaluate_script, :webssh, :exec_time, :sigle_training, :identifier, :status, :evaluate_count]).find(myshixun.shixun_id) game_challenge = Challenge.select([:id, :position, :picture_path]).find(game.challenge_id) # 更新评测次数 game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) + shixun.increment!(:evaluate_count) # 清空代码评测信息 msg = game.run_code_message msg.update_attributes(:status => 0, :message => nil) if msg.present? @@ -693,6 +694,7 @@ class GamesService :evaluate_count]).find_by_identifier(params[:identifier]) # 更新评测次数 game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) + game.challenge.shixun.increment!(:evaluate_count) # 选择题如果通关了,则不让再评测 if game.status == 2 diff --git a/app/services/management/school_report_service.rb b/app/services/management/school_report_service.rb index 2b18950d..b102c01a 100644 --- a/app/services/management/school_report_service.rb +++ b/app/services/management/school_report_service.rb @@ -4,7 +4,7 @@ class Management::SchoolReportService attr_reader :params sort_columns :student_count, :teacher_count, :homework_count, :other_homework_count, - :course_count, :active_course_count, :nearly_course_time, + :course_count, :active_course_count, :nearly_course_time, :shixun_count, :shixun_evaluate_count, default_by: :teacher_count, default_direction: :desc def initialize(params) @@ -47,6 +47,11 @@ class Management::SchoolReportService nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at') active_course_map = courses.where(is_end: false).count + shixun_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids }) + .group('school_id').count + evaluate_count_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids }) + .group('school_id').sum(:evaluate_count) + schools.map do |school| { id: school.id, @@ -58,6 +63,8 @@ class Management::SchoolReportService course_count: course_map[school.id], nearly_course_time: nearly_course_time_map[school.id], active_course_count: active_course_map[school.id], + shixun_count: shixun_map.fetch(school.id, 0), + shixun_evaluate_count: evaluate_count_map.fetch(school.id, 0) } end end @@ -78,6 +85,12 @@ class Management::SchoolReportService when 'course_count' then schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0') .select("#{base_query_column}, COUNT(*) course_count") + when 'shixun_count' then + schools.joins(teacher_extensions: :user).joins('INNER JOIN shixuns sx ON sx.user_id = users.id') + .select("#{base_query_column}, COUNT(*) shixun_count") + when 'shixun_evaluate_count' then + schools.joins(teacher_extensions: :user).joins('INNER JOIN shixuns sx ON sx.user_id = users.id') + .select("#{base_query_column}, SUM(sx.evaluate_count) shixun_evaluate_count") when 'nearly_course_time' then schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0') .joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id') diff --git a/app/views/managements/schools/_contrast_search_form.html.erb b/app/views/managements/schools/_contrast_search_form.html.erb index 9597a9c7..b77f2dbb 100644 --- a/app/views/managements/schools/_contrast_search_form.html.erb +++ b/app/views/managements/schools/_contrast_search_form.html.erb @@ -12,7 +12,7 @@