Merge branch 'dev_course' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_course

dev_course
jasder 6 years ago
commit 002a414694

@ -25,51 +25,49 @@ class AttachmentsController < ApplicationController
# 2. 上传到云
upload_file = params["file"] || params["#{params[:file_param_name]}"] # 这里的file_param_name是为了方便其他插件名称
uid_logger("#########################file_params####{params["#{params[:file_param_name]}"]}")
if upload_file
folder = edu_setting('attachment_folder')
raise "存储目录未定义" unless folder.present?
raise "未上传文件" unless upload_file
month_folder = current_month_folder
save_path = File.join(folder, month_folder)
folder = edu_setting('attachment_folder')
raise "存储目录未定义" unless folder.present?
ext = file_ext(upload_file.original_filename)
month_folder = current_month_folder
save_path = File.join(folder, month_folder)
local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext)
ext = file_ext(upload_file.original_filename)
content_type = upload_file.content_type.presence || 'application/octet-stream'
local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext)
remote_path = file_save_to_ucloud(local_path[folder.size, local_path.size], local_path, content_type)
content_type = upload_file.content_type.presence || 'application/octet-stream'
logger.info "local_path: #{local_path}"
logger.info "remote_path: #{remote_path}"
remote_path = file_save_to_ucloud(local_path[folder.size, local_path.size], local_path, content_type)
logger.info "local_path: #{local_path}"
logger.info "remote_path: #{remote_path}"
disk_filename = local_path[save_path.size + 1, local_path.size]
#存数据库
#
@attachment = Attachment.where(disk_filename: disk_filename,
author_id: current_user.id,
cloud_url: remote_path).first
unless @attachment.present?
@attachment = Attachment.new
@attachment.filename = upload_file.original_filename
@attachment.disk_filename = local_path[save_path.size + 1, local_path.size]
@attachment.filesize = upload_file.tempfile.size
@attachment.content_type = content_type
@attachment.digest = digest
@attachment.author_id = current_user.id
@attachment.disk_directory = month_folder
@attachment.cloud_url = remote_path
@attachment.save!
else
logger.info "文件已存在id = #{@attachment.id}, filename = #{@attachment.filename}"
end
disk_filename = local_path[save_path.size + 1, local_path.size]
#存数据库
#
@attachment = Attachment.where(disk_filename: disk_filename,
author_id: current_user.id,
cloud_url: remote_path).first
render_json
if @attachment.blank?
@attachment = Attachment.new
@attachment.filename = upload_file.original_filename
@attachment.disk_filename = local_path[save_path.size + 1, local_path.size]
@attachment.filesize = upload_file.tempfile.size
@attachment.content_type = content_type
@attachment.digest = digest
@attachment.author_id = current_user.id
@attachment.disk_directory = month_folder
@attachment.cloud_url = remote_path
@attachment.save!
else
raise "未上传文件"
logger.info "文件已存在id = #{@attachment.id}, filename = #{@attachment.filename}"
end
render_json
end
def destroy

@ -9,46 +9,39 @@ class BoardsController < ApplicationController
end
def show
end
def new
end
def create
ActiveRecord::Base.transaction do
begin
board = @course.course_board
new_board = Board.new(board_params)
new_board.course_id = @course.id
new_board.project_id = -1
new_board.parent_id = board.try(:id)
new_board.position = board.children.count + 1
new_board.save!
normal_status(0, "添加成功")
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
board = @course.course_board
new_board = Board.new(board_params)
new_board.course_id = @course.id
new_board.project_id = -1
new_board.parent_id = board.try(:id)
new_board.position = board.children.count + 1
new_board.save!
end
normal_status(0, "添加成功")
end
# 子目录的拖动
def move_category
tip_exception("移动失败") if params[:position].blank?
unless params[:position].to_i == @board.position
course_board = @course.course_board
return normal_status(-1, "位置没有变化") if params[:position].to_i == @board.position
course_board = @course.course_board
ActiveRecord::Base.transaction do
if params[:position].to_i < @board.position
course_board.children.where("position < #{@board.position} and position >= ?", params[:position]).update_all("position = position + 1")
course_board.children.where("position < ? and position >= ?", @board.position, params[:position])
.update_all("position = position + 1")
else
course_board.children.where("position > #{@board.position} and position <= ?", params[:position]).update_all("position = position - 1")
course_board.children.where("position > ? and position <= ?", @board.position, params[:position])
.update_all("position = position - 1")
end
@board.update_attributes(position: params[:position])
normal_status(0, "移动成功")
else
normal_status(-1, "位置没有变化")
end
normal_status(0, "移动成功")
end
def destroy

@ -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

@ -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)

@ -682,16 +682,26 @@ module ExercisesHelper
def get_exercise_left_time(exercise,user)
ex_time = exercise.time
user_left_time = nil
time_now_i = Time.now.to_i
if ex_time > 0
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0
if (exercise_user_start + time_mill) > exercise_end_time
time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时
#用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill
user_left_time = time_mill
else
user_left_time = (exercise_end_time < time_now_i) ? nil : (exercise_end_time - time_now_i)
end
else
if (exercise_user_start + time_mill) > exercise_end_time
time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时
end
exercise_user_left_time = time_now_i - exercise_user_start #用户已回答的时间
user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间
end
exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间
user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间
end
user_left_time
end

@ -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

@ -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

@ -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

@ -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 != ""
@ -44,7 +44,7 @@ class ExercisePublishTask
end
# 分组设置发布时间的测验
exercise_group_settings = ExerciseGroupSetting.where("publish_time < ? and publish_time > ?", Time.now + 1800, Time.now - 1800)
exercise_group_settings = ExerciseGroupSetting.where("publish_time < ? and publish_time > ?", Time.now + 900, Time.now - 900)
exercise_group_settings.each do |exercise_group|
exercise = exercise_group.exercise
if exercise.present?
@ -70,12 +70,12 @@ class ExercisePublishTask
Rails.logger.info("log--------------------------------exercise_end start")
puts "--------------------------------exercise_end start"
# 1。统一设置的试卷
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now)
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900)
exercises.each do |exercise|
ex_type = exercise.exercise_questions.pluck(:question_type).uniq
exercise.update_column('exercise_status', 3)
exercise.exercise_users.each do |exercise_user|
if exercise_user.commit_status == 0 && exercise_user.start_at.present?
if exercise_user&.commit_status == 0 && exercise_user&.start_at.present?
s_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
if ex_type.include?(4) #是否包含主观题
subjective_score = exercise_user.subjective_score
@ -98,7 +98,7 @@ class ExercisePublishTask
end
# 2.非统一的试卷
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now)
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900)
exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")"
ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}")
ex_group_settings.each do |exercise_setting|

@ -241,7 +241,7 @@ p{
position: absolute;
display: inline-block;
bottom: 9px;
left: 1px;
left: 2px;
}
table{
width:100%;

@ -249,8 +249,8 @@
<tbody>
<% if @games.size > 0 %>
<% @games.each_with_index do |game, index| %>
<% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id:game.challenge.id,user_id: @ex_user_user.id) %>
<% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %>
<% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id: game_score&.first&.id,user_id: @ex_user_user.id) %>
<tr>
<td><%= index + 1 %></td>
<td style="text-align: left;">

@ -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

@ -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

@ -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

@ -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?

@ -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 #开启匿评状态才可关闭匿评

@ -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

@ -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|

@ -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
Loading…
Cancel
Save