Merge branch 'dev_cxt2' into dev_aliyun

dev_newshixunModel
cxt 6 years ago
commit aba592314e

@ -307,8 +307,8 @@ class CoursesController < ApplicationController
def destroy def destroy
if @course.is_delete == 0 if @course.is_delete == 0
@course.delete! @course.delete!
Tiding.create!(user_id: @course.tea_id, trigger_user_id: 0, container_id: @course.id, Tiding.create!(user_id: current_user.id, trigger_user_id: current_user.id, container_id: @course.id,
container_type: 'Course', tiding_type: 'Delete', extra: @course.name) container_type: 'DeleteCourse', tiding_type: 'System', belong_container: @course, extra: @course.name)
normal_status(0, "成功") normal_status(0, "成功")
else else
normal_status(-1, "课堂已删除,无需重复操作") normal_status(-1, "课堂已删除,无需重复操作")
@ -572,6 +572,10 @@ class CoursesController < ApplicationController
tip_exception("删除失败") if course_member.CREATOR? or course_member.STUDENT? tip_exception("删除失败") if course_member.CREATOR? or course_member.STUDENT?
course_student = CourseMember.find_by(user_id: course_member.user_id, course_id: @course.id, role: %i[STUDENT]) course_student = CourseMember.find_by(user_id: course_member.user_id, course_id: @course.id, role: %i[STUDENT])
# Tiding.create!(user_id: course_member.user_id, trigger_user_id: current_user.id, container_id: @course.id,
# container_type: 'DeleteCourseMember', tiding_type: 'System', belong_container: @course, extra: @course.name)
CourseDeleteStudentNotifyJob.perform_later(@course.id, [course_member.user_id], current_user.id)
course_member.destroy! course_member.destroy!
course_student.update_attributes(is_active: 1) if course_student.present? && !course_student.is_active course_student.update_attributes(is_active: 1) if course_student.present? && !course_student.is_active
normal_status(0, "删除成功") normal_status(0, "删除成功")
@ -802,6 +806,7 @@ class CoursesController < ApplicationController
end end
end end
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, student_ids) if student_ids.present? CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, student_ids) if student_ids.present?
CourseDeleteStudentNotifyJob.perform_later(@course.id, student_ids, current_user.id) if student_ids.present?
normal_status(0, "操作成功") normal_status(0, "操作成功")
rescue => e rescue => e
uid_logger(e.message) uid_logger(e.message)

@ -656,7 +656,17 @@ class ExerciseQuestionsController < ApplicationController
:exercise_answer_id => ex_answer_comment_id :exercise_answer_id => ex_answer_comment_id
} }
@exercise_comments = ExerciseAnswerComment.new(comment_option) @exercise_comments = ExerciseAnswerComment.new(comment_option)
@exercise_comments.save @exercise_comments.save!
# 给被评阅人发送消息,同一个教师评阅无需重复发消息
unless Tiding.where(user_id: @user_id, trigger_user_id: current_user.id, parent_container_id: @exercise.id, parent_container_type: "ExerciseScore").exists?
Tiding.create!(user_id: @user_id, trigger_user_id: current_user.id, container_id: @exercise.id,
container_type: "Exercise", parent_container_id: @exercise.id,
parent_container_type: "ExerciseScore", belong_container_id: @course.id,
belong_container_type: 'Course', tiding_type: "Exercise")
end
end end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)

@ -1,18 +1,18 @@
class GraduationWorksController < ApplicationController class GraduationWorksController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :find_task, only: [:new, :create, :search_member_list, :check_project, :relate_project, before_action :find_task, only: [:new, :create, :search_member_list, :check_project, :relate_project,
:cancel_relate_project] :cancel_relate_project, :delete_work]
before_action :find_work, only: [:show, :edit, :update, :revise_attachment, :supply_attachments, :comment_list, before_action :find_work, only: [:show, :edit, :update, :revise_attachment, :supply_attachments, :comment_list,
:add_score, :delete_score, :adjust_score, :assign_teacher] :add_score, :delete_score, :adjust_score, :assign_teacher]
before_action :user_course_identity before_action :user_course_identity
before_action :task_public before_action :task_public
before_action :teacher_allowed, only: [:add_score, :adjust_score, :assign_teacher] before_action :teacher_allowed, only: [:add_score, :adjust_score, :assign_teacher]
before_action :course_student, only: [:new, :create, :edit, :update, :search_member_list, :relate_project, before_action :course_student, only: [:new, :create, :edit, :update, :search_member_list, :relate_project,
:cancel_relate_project] :cancel_relate_project, :delete_work]
before_action :my_work, only: [:edit, :update, :revise_attachment] before_action :my_work, only: [:edit, :update, :revise_attachment]
before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project, before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project,
:cancel_relate_project, :revise_attachment] :cancel_relate_project, :revise_attachment]
before_action :edit_duration, only: [:edit, :update] before_action :edit_duration, only: [:edit, :update, :delete_work]
before_action :open_work, only: [:show, :supply_attachments, :comment_list] before_action :open_work, only: [:show, :supply_attachments, :comment_list]
def new def new
@ -47,6 +47,24 @@ class GraduationWorksController < ApplicationController
@members = @members.page(page).per(limit).includes(:course_group, user: :user_extension) @members = @members.page(page).per(limit).includes(:course_group, user: :user_extension)
end end
def delete_work
ActiveRecord::Base.transaction do
begin
work = @task.graduation_works.find_by!(user_id: params[:user_id])
tip_exception("只有组长才能删除组员") if work.commit_user_id != current_user.id
work.update_attributes(description: nil, project_id: 0, late_penalty: 0, work_status: 0, commit_time: nil,
update_time: nil, group_id: 0, commit_user_id: nil, final_score: nil, work_score: nil,
teacher_score: nil, teaching_asistant_score: nil, update_user_id: nil)
work.attachments.destroy_all
work.tidings.destroy_all
normal_status("删除成功")
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
end
end
end
# 判断项目是否已有其他作品关联上了 # 判断项目是否已有其他作品关联上了
def check_project def check_project
tip_exception("项目id不能为空") if params[:project_id].blank? tip_exception("项目id不能为空") if params[:project_id].blank?
@ -371,6 +389,11 @@ class GraduationWorksController < ApplicationController
new_score.save! new_score.save!
@work.update_attributes(ultimate_score: 1, work_score: params[:score].to_f) @work.update_attributes(ultimate_score: 1, work_score: params[:score].to_f)
Tiding.create!(user_id: @work.user_id, trigger_user_id: current_user.id, container_id: new_score.id,
container_type: "AdjustScore", parent_container_id: @task.id,
parent_container_type: "GraduationTask", belong_container_id: @course.id,
belong_container_type: 'Course', tiding_type: "GraduationTask")
normal_status("调分成功") normal_status("调分成功")
rescue Exception => e rescue Exception => e
uid_logger(e.message) uid_logger(e.message)

@ -224,7 +224,7 @@ class StudentWorksController < ApplicationController
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
SubmitStudentWorkNotifyJob.perform_later(@homework.id, student_ids) if student_ids.present? ResubmitStudentWorkNotifyJob.perform_later(@homework.id, student_ids) if student_ids.present?
end end
end end
@ -333,6 +333,11 @@ class StudentWorksController < ApplicationController
@work.update_attributes(update_time: Time.now) @work.update_attributes(update_time: Time.now)
# 补交附件时给评阅过作品的教师、助教发消息
unless @work.student_works_scores.where.not(score: nil).where(reviewer_role: [1, 2]).pluck(user_id).uniq.blank?
ResubmitStudentWorkNotifyJob.perform_later(@homework.id, [current_user.id])
end
normal_status(0, "提交成功") normal_status(0, "提交成功")
rescue Exception => e rescue Exception => e
uid_logger(e.message) uid_logger(e.message)
@ -551,6 +556,11 @@ class StudentWorksController < ApplicationController
@work.work_score = params[:score].to_f @work.work_score = params[:score].to_f
@work.save! @work.save!
Tiding.create!(user_id: @work.user_id, trigger_user_id: current_user.id, container_id: new_score.id,
container_type: "AdjustScore", parent_container_id: @homework.id,
parent_container_type: "HomeworkCommon", belong_container_id: @course.id,
belong_container_type: 'Course', tiding_type: "HomeworkCommon")
normal_status(0,"调分成功") normal_status(0,"调分成功")
rescue Exception => e rescue Exception => e
uid_logger(e.message) uid_logger(e.message)

@ -134,6 +134,15 @@ module TidingDecorator
end end
end end
def delete_course_content
I18n.t(locale_format) % container.name
end
def delete_course_member_content
name = Course.find_by(id: container_id)&.name
I18n.t(locale_format) % [trigger_user&.show_real_name, name]
end
def shixun_content def shixun_content
I18n.t(locale_format) % container.name I18n.t(locale_format) % container.name
end end
@ -331,13 +340,21 @@ module TidingDecorator
end end
def student_work_content def student_work_content
I18n.t(locale_format(extra.nil?)) % container&.homework_common.try(:name) I18n.t(locale_format) % container&.homework_common.try(:name)
end
def resubmit_student_work_content
I18n.t(locale_format) % container&.homework_common.try(:name)
end end
def student_works_score_content def student_works_score_content
I18n.t(locale_format(extra)) % container&.student_work&.homework_common.try(:name) I18n.t(locale_format(extra)) % container&.student_work&.homework_common.try(:name)
end end
def adjust_score_content
I18n.t(locale_format) % parent_container.try(:name)
end
def challenge_work_score_content def challenge_work_score_content
I18n.t(locale_format) % container&.comment I18n.t(locale_format) % container&.comment
end end

@ -0,0 +1,22 @@
# 删除课堂用户
class CourseDeleteStudentNotifyJob < ApplicationJob
queue_as :notify
def perform(course_id, student_ids, trigger_user_id)
course = Course.find_by(id: course_id)
return if course.blank?
attrs = %i[user_id trigger_user_id container_id container_type belong_container_id
belong_container_type tiding_type created_at updated_at]
same_attrs = {
trigger_user_id: trigger_user_id, container_id: course.id, container_type: 'DeleteCourseMember',
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'System'
}
Tiding.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end

@ -0,0 +1,33 @@
class ResubmitStudentWorkNotifyJob < ApplicationJob
queue_as :notify
def perform(homework_id, student_ids)
homework = HomeworkCommon.find_by(id: homework_id)
return if homework.blank? || student_ids.blank?
course = homework.course
attrs = %i[user_id trigger_user_id container_id container_type parent_container_id parent_container_type
belong_container_id belong_container_type tiding_type viewed created_at updated_at]
same_attrs = {
container_type: 'ResubmitStudentWork', parent_container_id: homework.id, parent_container_type: 'HomeworkCommon',
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'HomeworkCommon', viewed: 0
}
Tiding.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
next unless User.exists?(id: user_id)
work = homework.student_works.find_by(user_id: user_id)
next if work.blank?
score_user_ids = work.student_works_scores.where.not(score: nil).where(reviewer_role: [1, 2]).pluck(user_id).uniq
next if score_user_ids.blank?
attrs = same_attrs.merge(trigger_user_id: user_id, container_id: work.id)
score_user_ids.each do |user_id|
worker.add attrs.merge(user_id: user_id)
end
end
end
end
end

@ -58,8 +58,8 @@
"2_end": "你提交的试用授权申请,审核未通过<br/><span>原因:%{reason}</span>" "2_end": "你提交的试用授权申请,审核未通过<br/><span>原因:%{reason}</span>"
Apply_end: "提交了试用授权申请" Apply_end: "提交了试用授权申请"
Course_end: "你创建了课堂:%s" Course_end: "你创建了课堂:%s"
Course: DeleteCourse_end: "你删除了课堂:%s"
Delete_end: "你删除了课堂%s" DeleteCourseMember_end: "%s 将从课堂中删除了:%s"
Shixun_end: "你创建了实训:%s" Shixun_end: "你创建了实训:%s"
Subject_end: "你创建了实践课程:%s" Subject_end: "你创建了实践课程:%s"
ArchiveCourse_end: "你的课堂已经归档:%s" ArchiveCourse_end: "你的课堂已经归档:%s"
@ -185,13 +185,13 @@
NearlyEnd_end: "作业的提交截止时间快到啦:%{name}" NearlyEnd_end: "作业的提交截止时间快到啦:%{name}"
AppealNearlyEnd_end: "作品的匿评申诉时间快到啦:%{name}" AppealNearlyEnd_end: "作品的匿评申诉时间快到啦:%{name}"
EvaluationNearlyEnd_end: "作业的匿评截止时间快到啦:%{name}" EvaluationNearlyEnd_end: "作业的匿评截止时间快到啦:%{name}"
StudentWork: StudentWork_end: "提交了作品:%s"
true_end: "提交了作品:%s" ResubmitStudentWork_end: "重新提交了作品,建议您重新评阅作品:%s"
false_end: "重新提交了作品,建议您重新评阅:%s"
StudentWorksScore: StudentWorksScore:
1_end: "评阅了你的作品:%s" 1_end: "评阅了你的作品:%s"
2_end: "评阅了你的作品:%s" 2_end: "评阅了你的作品:%s"
3_end: "有人匿评了你的作品:%s" 3_end: "有人匿评了你的作品:%s"
AdjustScore_end: "调整了你的作品得分:%s"
ChallengeWorkScore_end: "调整了你的作品分数:%s" ChallengeWorkScore_end: "调整了你的作品分数:%s"
StudentWorksScoresAppeal: StudentWorksScoresAppeal:
UserAppealResult: UserAppealResult:

@ -540,6 +540,7 @@ Rails.application.routes.draw do
post 'relate_project' post 'relate_project'
get 'cancel_relate_project' get 'cancel_relate_project'
post 'revise_attachment' post 'revise_attachment'
delete 'delete_work'
end end
member do member do

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CourseDeleteStudentNotifyJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ResubmitStudentWorkNotifyJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save