From 19ef46f0778775dd80ea25812209b4b8c056f20d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 14:21:53 +0800 Subject: [PATCH] fix bug --- app/controllers/graduation_tasks_controller.rb | 2 +- app/controllers/homework_commons_controller.rb | 2 +- app/controllers/zips_controller.rb | 11 ++++++++--- app/services/export_shixun_report_service.rb | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index aebd8b092..a89a81798 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -129,7 +129,7 @@ class GraduationTasksController < ApplicationController if @user_course_identity >= Course::STUDENT tip_exception(403, "无权限操作") elsif complete_works == 0 - normal_status(-1,"暂无提交的学生!") + normal_status(-1,"暂无用户提交!") else respond_to do |format| format.xlsx{ diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 2d52b6aa0..fe2adba45 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -200,7 +200,7 @@ class HomeworkCommonsController < ApplicationController if @user_course_identity >= Course::STUDENT tip_exception(403, "无权限操作") elsif complete_works == 0 - normal_status(-1,"暂无提交的学生!") + normal_status(-1,"暂无用户提交!") else respond_to do |format| format.xlsx{ diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 3b9fa7c02..8553cbb44 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -44,9 +44,12 @@ class ZipsController < ApplicationController ActiveRecord::Base.transaction do begin @exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id]) + @exercise_status = @exercise.get_exercise_status(current_user.id) group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") + elsif @exercise_status == 1 + normal_status(-1,"试卷未发布") else @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed @@ -66,7 +69,7 @@ class ZipsController < ApplicationController if params[:commit_status].present? && (params[:commit_status].to_i == 1) @exercise_users_list = @exercise_users_list.where(commit_status:params[:commit_status]) elsif params[:commit_status].present? && (params[:commit_status].to_i == 0) - normal_status(-1,"仅支持导出已提交的学生!") + normal_status(-1,"暂无用户提交!") end #可以分班选择 @@ -84,7 +87,7 @@ class ZipsController < ApplicationController default_ex_users_size = @ex_users&.size if default_ex_users_size.blank? || default_ex_users_size == 0 - normal_status(-1,"导出失败,暂时没有已提交的学生") + normal_status(-1,"暂无用户提交") elsif default_ex_users_size > 100 normal_status(-2,"100") end @@ -98,6 +101,8 @@ class ZipsController < ApplicationController def load_homework @homework = HomeworkCommon.find(params[:homework_common_id]) + + @course = @homework.course ##7。2 -hs新增 @member = @course.course_member(current_user.id) @@ -121,7 +126,7 @@ class ZipsController < ApplicationController student_work_sizes = @all_student_works&.size if student_work_sizes.blank? || student_work_sizes == 0 - normal_status(-1,"导出失败,暂时没有已提交的学生") + normal_status(-1,"暂无用户提交") elsif student_work_sizes > 100 normal_status(-2,"100") end diff --git a/app/services/export_shixun_report_service.rb b/app/services/export_shixun_report_service.rb index 8358d422e..4c8dab6aa 100644 --- a/app/services/export_shixun_report_service.rb +++ b/app/services/export_shixun_report_service.rb @@ -45,7 +45,8 @@ class ExportShixunReportService @games = @work.myshixun.games.includes(:challenge, :game_codes,:outputs) if @work.myshixun # 用户最大评测次数 - @user_evaluate_count = @games.inject(0){|sum, g| sum + g.outputs.pluck(:query_index).first } if @games + @user_evaluate_count = @games.pluck(:evaluate_count).sum if @games + # @user_evaluate_count = @games.inject(0){|sum, g| sum + g.outputs.pluck(:query_index)&.first } if @games # 图形效率图的数据 @echart_data = student_efficiency(homework, @work) @myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id }