diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index bd9f2e184..5fe230d32 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -64,17 +64,15 @@ class GamesController < ApplicationController myshixun_manager: myshixun_manager} if @shixun.vnc begin - shixun_tomcat = edu_setting('shixun_tomcat') + shixun_tomcat = edu_setting('cloud_bridge') service_host = edu_setting('vnc_url') uri = "#{shixun_tomcat}/bridge/vnc/getvnc" params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(@shixun.mirror_repositories))}"} - logger.info("#######_------uri:#{uri}, params: #{params}") res = uri_post uri, params if res && res['code'].to_i != 0 raise("实训云平台繁忙(繁忙等级:99)") end - @url = "http://#{service_host}:#{res['port']}}/vnc_lite.html?password=headless" - Rails.logger.info("66666666sssssss#{url}") + @vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless" rescue Exception => e Rails.logger.error(e.message) end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 13e58f21d..58e68dfce 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -459,9 +459,9 @@ class HomeworkCommonsController < ApplicationController tip_exception("发布时间不能为空") if setting[:publish_time].blank? tip_exception("截止时间不能为空") if setting[:end_time].blank? # 如果该发布规则 没有已发布的分班则需判断发布时间 - tip_exception("发布时间不能早于当前时间") if setting[:publish_time] <= strf_time(Time.now) && group_settings.group_published.count == 0 + tip_exception("发布时间不能早于等于当前时间") if setting[:publish_time] <= strf_time(Time.now) && group_settings.group_published.count == 0 - tip_exception("截止时间不能早于当前时间") if setting[:end_time] <= strf_time(Time.now) + tip_exception("截止时间不能早于等于当前时间") if setting[:end_time] <= strf_time(Time.now) tip_exception("截止时间不能早于发布时间") if setting[:publish_time] > setting[:end_time] tip_exception("截止时间不能早于课堂结束时间") if setting[:end_time] > strf_time(@course.end_date.end_of_day) @@ -586,9 +586,9 @@ class HomeworkCommonsController < ApplicationController # anonymous_comment :true 是启用,false 是不启用 if params[:anonymous_comment] tip_exception("匿评开启时间不能为空") if params[:evaluation_start].blank? - tip_exception("匿评开启时间不能早于截止时间") if params[:evaluation_start] <= strf_time(@homework.end_time) + tip_exception("匿评开启时间不能早于截止时间") if params[:evaluation_start] < strf_time(@homework.end_time) tip_exception("匿评结束时间不能为空") if params[:evaluation_end].blank? - tip_exception("匿评截止时间不能早于匿评开启时间") if params[:evaluation_end] <= params[:evaluation_start] + tip_exception("匿评截止时间必须晚于匿评开启时间") if params[:evaluation_end] <= params[:evaluation_start] tip_exception("匿评截止时间不能晚于课堂结束时间") if @course.end_date.present? && params[:evaluation_end] > strf_time(@course.end_date.end_of_day) tip_exception("匿评数必须为正整数") if params[:evaluation_num].blank? || params[:evaluation_num].to_i < 1 @@ -615,7 +615,7 @@ class HomeworkCommonsController < ApplicationController # 匿评未截止时可以更新匿评结束时间 if @homework_detail_manual.comment_status < 4 tip_exception("匿评结束时间不能为空") if @homework.anonymous_comment && params[:evaluation_end].blank? - tip_exception("匿评截止时间不能早于匿评开启时间") if @homework.anonymous_comment && + tip_exception("匿评截止时间必须晚于匿评开启时间") if @homework.anonymous_comment && params[:evaluation_end] <= params[:evaluation_start] tip_exception("匿评截止时间不能晚于课堂结束时间") if @homework.anonymous_comment && @course.end_date.present? && params[:evaluation_end] > strf_time(@course.end_date.end_of_day) diff --git a/app/helpers/graduation_works_helper.rb b/app/helpers/graduation_works_helper.rb index 177720d24..577efa797 100644 --- a/app/helpers/graduation_works_helper.rb +++ b/app/helpers/graduation_works_helper.rb @@ -15,7 +15,6 @@ module GraduationWorksHelper end end # work_score 最终成绩; late_penalty 迟交扣分; final_score 最终评分 - {username: work.user.full_name, login: work.user.login, work_score: work_score, final_score: work.final_score, - late_penalty:work.late_penalty } + {username: work.user.full_name, login: work.user.login, work_score: work_score, final_score: work.final_score} end end diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb index a99a18b2a..49cab19ee 100644 --- a/app/models/graduation_work.rb +++ b/app/models/graduation_work.rb @@ -100,8 +100,7 @@ class GraduationWork < ApplicationRecord "未批阅" else if self.check_score_power?(current_user, course_identity) - "#{format("%.1f", self.cross_score.round(1))}(#{self.graduation_work_scores - .where(reviewer_role: 2).group_by(&:user_id).count})" + "#{format("%.1f", self.cross_score.round(1))}" else "**" end @@ -109,6 +108,10 @@ class GraduationWork < ApplicationRecord end end + def cross_comment_num + graduation_work_scores.where(reviewer_role: 2).group_by(&:user_id).count + end + def scored? graduation_work_scores.where.not(reviewer_role: 3).exists? end diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb index 2affec0ba..2d6f50b5c 100644 --- a/app/services/homeworks_service.rb +++ b/app/services/homeworks_service.rb @@ -81,7 +81,7 @@ class HomeworksService pass_consume_time += (game.cost_time / 60.0).to_f user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i adjust_score = student_work.challenge_work_scores.where(challenge_id: setting.challenge_id).last - final_score += adjust_score.present? ? adjust_score.score : (answer_open_evaluation ? setting.score : (game.final_score >= 0 ? setting.score : 0)) + final_score += adjust_score.present? ? adjust_score.score : (answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0)) max_endtime = max_endtime == "" ? game.end_time : (game.end_time > max_endtime ? game.end_time : max_endtime) else compelete = false @@ -177,7 +177,7 @@ class HomeworksService pass_consume_time += (game.cost_time / 60.0).to_f user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last - final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score >= 0 ? setting.score : 0)) + final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0)) end end if work.work_status == 0 diff --git a/app/tasks/exercise_publish_task.rb b/app/tasks/exercise_publish_task.rb index 932fe00fb..387a834f1 100644 --- a/app/tasks/exercise_publish_task.rb +++ b/app/tasks/exercise_publish_task.rb @@ -15,9 +15,9 @@ class ExercisePublishTask tid_str += "(#{member.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end if exercise.unified_setting - course.student.find_each do |student| + course.students.find_each do |student| tid_str += "," if tid_str != "" - tid_str += "(#{student.student_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" + tid_str += "(#{student.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end end if tid_str != "" @@ -25,7 +25,7 @@ class ExercisePublishTask ActiveRecord::Base.connection.execute tid_sql end - if exercise.exercise_users.count == 0 + if exercise.exercise_users.size == 0 str = "" course.students.find_each do |student| str += "," if str != "" diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index a0cffc41b..62c95901f 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -42,6 +42,7 @@ if @task.published? || @user_course_identity < Course::STUDENT json.name work.user.real_name json.student_id work.user.student_id json.class_grouping_name work.class_grouping_name + json.ultimate_score work.ultimate_score if @task.have_grouping? json.grouping_name work.grouping_name if @task.base_on_project @@ -51,7 +52,11 @@ if @task.published? || @user_course_identity < Course::STUDENT json.status work.work_status json.update_time format_time work.update_time json.teacher_comment_score work.teacher_comment_score(@current_user, @user_course_identity) - json.cross_comment_score work.cross_comment_score(@current_user, @user_course_identity) + if @task.cross_comment + json.cross_comment_score work.cross_comment_score(@current_user, @user_course_identity) + json.cross_comment_num work.cross_comment_num + end + json.late_penalty work.late_penalty if @task.allow_late json.final_score work_final_score work, @current_user, @user_course_identity json.assign work.assign_power?(@user_course_identity) end diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake index 598755db0..0212e138c 100644 --- a/lib/tasks/exercise_close_to_deadline_warn.rake +++ b/lib/tasks/exercise_close_to_deadline_warn.rake @@ -5,37 +5,41 @@ namespace :exercise_deadline_warn do task :deadline_warn => :environment do puts "--------------------------------exercise_nearly_end start" # 统一设置发布时间的测验 - exercises = Exercise.where("exercise_status = 2 and unified_setting = 1 and end_time <=? and end_time > ?", Time.now + 86400, Time.now + 82800) + exercises = Exercise.where("exercise_status = 2 and unified_setting = 1 and end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) exercises.each do |exercise| - if exercise.tidings.where(:parent_container_type => "NearlyEnd").count == 0 + if exercise.tidings.where(parent_container_type: "NearlyEnd").count == 0 course = exercise.course tid_str = "" - exercise.exercise_users.where(:commit_status => 0).find_each do |student| + exercise.exercise_users.where(commit_status: 0).find_each do |student| tid_str += "," if tid_str != "" - tid_str += "(#{student.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'NearlyEnd', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" + tid_str += "(#{student.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'NearlyEnd', + #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str + tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, + parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str ActiveRecord::Base.connection.execute tid_sql end end end # 分组设置发布时间的测验 - exercise_group_settings = ExerciseGroupSetting.where("end_time <=? and end_time > ?", Time.now + 86400, Time.now + 82800) + exercise_group_settings = ExerciseGroupSetting.where("end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) exercise_group_settings.each do |exercise_group| exercise = exercise_group.exercise if exercise.present? course = exercise.course - members = course.course_members.where(:course_group_id => exercise_group.course_group_id) - if exercise.tidings.where(:parent_container_type => "NearlyEnd", :user_id => members.map(&:user_id)).count == 0 + members = course.students.where(course_group_id: exercise_group.course_group_id) + if exercise.tidings.where(parent_container_type: "NearlyEnd", user_id: members.pluck(:user_id)).count == 0 tid_str = "" - exercise.exercise_users.where(:commit_status => 0, :user_id => members.map(&:user_id)).find_each do |member| + exercise.exercise_users.where(commit_status: 0, user_id: members.pluck(:user_id)).find_each do |member| tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id},#{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'NearlyEnd', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" + tid_str += "(#{member.user_id},#{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'NearlyEnd', + #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str + tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, + parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str ActiveRecord::Base.connection.execute tid_sql end end diff --git a/lib/tasks/graduation_task.rake b/lib/tasks/graduation_task.rake index dada0303d..aad84491f 100644 --- a/lib/tasks/graduation_task.rake +++ b/lib/tasks/graduation_task.rake @@ -30,7 +30,7 @@ namespace :graduation_task do end task :nearly_end => :environment do - tasks = GraduationTask.where("end_time <=? and end_time > ?", Time.now + 86400, Time.now + 82800) + tasks = GraduationTask.where("end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) tasks.each do |task| if task.tidings.where(parent_container_type: "NearlyEnd").count == 0 course = task.course diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake index feba02670..555903980 100644 --- a/lib/tasks/homework_endtime.rake +++ b/lib/tasks/homework_endtime.rake @@ -4,7 +4,7 @@ namespace :homework_endtime do desc "send a message for Job deadline" task :message => :environment do # 统一设置发布时间的作业 - homeworks = HomeworkCommon.where("unified_setting = 1 and end_time <=? and end_time > ?", Time.now + 86400, Time.now + 82800) + homeworks = HomeworkCommon.includes(:course).where("unified_setting = 1 and end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) homeworks.each do |homework| if homework.tidings.where(:parent_container_type => "NearlyEnd").count == 0 course = homework.course @@ -25,7 +25,7 @@ namespace :homework_endtime do end # 分组设置发布时间的作业 - homework_group_settings = HomeworkGroupSetting.where("end_time <=? and end_time > ?", Time.now + 86400, Time.now + 82800) + homework_group_settings = HomeworkGroupSetting.includes(:homework_common).where("end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) homework_group_settings.each do |homework_group| homework = homework_group.homework_common if homework.present? @@ -52,8 +52,8 @@ namespace :homework_endtime do # 匿评截止时间快到了 task :evaluation_nearly_end => :environment do - homework_detail_manuals = HomeworkDetailManual.where("homework_detail_manuals.comment_status = 3 and evaluation_end <=? - and evaluation_end > ? ", Time.now + 86400, Time.now + 82800) + homework_detail_manuals = HomeworkDetailManual.includes(:homework_common).where("homework_detail_manuals.comment_status = 3 and evaluation_end <=? + and evaluation_end > ? ", Time.now + 86400, Time.now + 84600) homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common if homework_common.present? @@ -85,7 +85,7 @@ namespace :homework_endtime do # 匿评申诉截止时间快到了 task :appeal_nearly_end => :environment do homework_detail_manuals = HomeworkDetailManual.where("homework_detail_manuals.comment_status = 4 and appeal_time <=? - and appeal_time > ?", Time.now + 86400, Time.now + 82800) + and appeal_time > ?", Time.now + 86400, Time.now + 84600) homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common if homework_common.present? diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 84c7c888f..cb7b51fae 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -12,7 +12,7 @@ namespace :homework_evaluation do task :start_evaluation => :environment do Rails.logger.info("log--------------------------------start_evaluation start") puts "--------------------------------start_evaluation start" - homework_detail_manuals = HomeworkDetailManual.where("evaluation_start <= '#{Time.now}' and + homework_detail_manuals = HomeworkDetailManual.includes(homework_common: :course).where("evaluation_start <= '#{Time.now}' and (homework_detail_manuals.comment_status < 3)") homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common @@ -110,7 +110,7 @@ namespace :homework_evaluation do #自动关闭匿评的任务 task :end_evaluation => :environment do - homework_detail_manuals = HomeworkDetailManual.where("evaluation_end <= '#{Time.now}' and homework_detail_manuals.comment_status = 3") + homework_detail_manuals = HomeworkDetailManual.includes(:homework_common).where("evaluation_end <= '#{Time.now}' and homework_detail_manuals.comment_status = 3") homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common if homework_common.anonymous_comment #开启匿评状态才可关闭匿评 diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index f6a4325cd..0e45b0224 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -6,8 +6,8 @@ namespace :homework_publishtime do # 作业的分班设置时间 def homework_group_setting homework, group_id setting = nil - if homework.homework_group_settings.where(:course_group_id => group_id).first - setting = homework.homework_group_settings.where(:course_group_id => group_id).first + if homework.homework_group_settings.where(course_group_id: group_id).first + setting = homework.homework_group_settings.where(course_group_id: group_id).first else setting = homework end diff --git a/lib/tasks/poll_publish.rake b/lib/tasks/poll_publish.rake index 48c289050..6ced88908 100644 --- a/lib/tasks/poll_publish.rake +++ b/lib/tasks/poll_publish.rake @@ -116,11 +116,7 @@ namespace :poll_publish do polls = Poll.includes(:poll_users).where("polls_status = 2 AND unified_setting = true AND end_time <=?",Time.now + 900) polls.each do |poll| poll.update_column('polls_status', 3) - poll.poll_users.each do |poll_user| - if poll_user.commit_status == 0 && poll_user.start_at.present? - poll_user.update_attributes(:commit_status => 1, :end_at => Time.now) - end - end + poll.poll_users.where("commit_status = 0 and start_at is not null").update_all(commit_status: 1, end_at: Time.now) end #2.分班设置的截止 @@ -132,13 +128,13 @@ namespace :poll_publish do if poll&.end_time <= Time.now poll.update_column('polls_status', 3) end - users = poll.course.course_members.where(:course_group_id => poll_setting.course_group_id) - poll_users = poll.poll_users.where(:user_id => users.map(&:user_id)) - poll_users.each do |poll_user| - if poll_user.commit_status == 0 && !poll_user.start_at.nil? - poll_user.update_attributes(:commit_status => 1, :end_at => Time.now) - end - end + users = poll.course.course_members.where(course_group_id: poll_setting.course_group_id) + poll.poll_users.where(user_id: users.pluck(:user_id)).where("commit_status = 0 and start_at is not null").update_all(commit_status: 1, end_at: Time.now) + # poll_users.each do |poll_user| + # if poll_user.commit_status == 0 && !poll_user.start_at.nil? + # poll_user.update_attributes(:commit_status => 1, :end_at => Time.now) + # end + # end end # PollGroupSetting.where("end_time < ? and end_time > ?", Time.now + 1800, Time.now - 1800).each do |poll_setting| diff --git a/lib/tasks/resource_publish.rake b/lib/tasks/resource_publish.rake index 7872a6ce4..f90718cfb 100644 --- a/lib/tasks/resource_publish.rake +++ b/lib/tasks/resource_publish.rake @@ -5,9 +5,7 @@ namespace :resource_publish do task :publish => :environment do Rails.logger.info("log--------------------------------resource_publish start") attachments = Attachment.where("publish_time < '#{Time.now}' and is_publish = 0") - attachments.each do |attachment| - attachment.update_attributes(:is_publish => 1) - end + attachments.update_all(is_publish: 1) Rails.logger.info("log--------------------------------resource_publish end") end end \ No newline at end of file