From ec1826c469f37364e549863c7c3d3079cedacf4e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 2 Sep 2019 14:17:17 +0800
Subject: [PATCH 001/394] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../graduation_tasks_controller.rb | 41 +++++++++++--------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 727bdb77e..138be4960 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -452,22 +452,27 @@ class GraduationTasksController < ApplicationController
tip_exception("评阅时间应当大于截止时间") if @task.cross_comment && params[:comment_time] <= @task.end_time
@task.comment_time = @task.cross_comment ? params[:comment_time] : nil
- @task.comment_num = @task.cross_comment ? params[:comment_num].to_i : 3
- @task.comment_status = @task.cross_comment ? params[:comment_status] : 0
- if @task.cross_comment && params[:comment_status].to_i == 4
- tip_exception("评阅数不能为空") if params[:comment_num].blank?
- tip_exception("评阅数应大于0") if params[:comment_num].to_i < 1
-
- @course.graduation_groups.each_with_index do |group, index|
- ass_group = @task.graduation_task_group_assignations.find_by(graduation_group_id: group.id)
- if ass_group.present? && params[:comment_group][index].present? && params[:comment_group][index] != "0"
- ass_group.update_attributes(assign_graduation_group_id: params[:comment_group][index])
- else
- @task.graduation_task_group_assignations << GraduationTaskGroupAssignation.new(graduation_group_id: group.id,
- assign_graduation_group_id: params[:comment_group][index])
- end
- end
- end
+
+ # unless @task.cross_comment
+ # @task.graduation_work_comment_assignations.destroy_all
+ # end
+ # 去掉评阅设置
+ # @task.comment_num = @task.cross_comment ? params[:comment_num].to_i : 3
+ # @task.comment_status = @task.cross_comment ? params[:comment_status] : 0
+ # if @task.cross_comment && params[:comment_status].to_i == 4
+ # tip_exception("评阅数不能为空") if params[:comment_num].blank?
+ # tip_exception("评阅数应大于0") if params[:comment_num].to_i < 1
+ #
+ # @course.graduation_groups.each_with_index do |group, index|
+ # ass_group = @task.graduation_task_group_assignations.find_by(graduation_group_id: group.id)
+ # if ass_group.present? && params[:comment_group][index].present? && params[:comment_group][index] != "0"
+ # ass_group.update_attributes(assign_graduation_group_id: params[:comment_group][index])
+ # else
+ # @task.graduation_task_group_assignations << GraduationTaskGroupAssignation.new(graduation_group_id: group.id,
+ # assign_graduation_group_id: params[:comment_group][index])
+ # end
+ # end
+ # end
end
# 公开设置
@@ -492,6 +497,10 @@ class GraduationTasksController < ApplicationController
end
end
+ def cross_comment_setting
+
+ end
+
private
def find_task
begin
From 7e1054aaf38ae28bbc21d995946a9a95e4558b11 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 2 Sep 2019 16:14:40 +0800
Subject: [PATCH 002/394] com
---
app/controllers/graduation_tasks_controller.rb | 6 +++---
config/routes.rb | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 138be4960..ac6cb7eae 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -1,11 +1,11 @@
class GraduationTasksController < ApplicationController
before_action :require_login, :check_auth, except: [:index]
before_action :find_course, except: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment]
- before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment]
+ before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment, :cross_comment_setting]
before_action :user_course_identity
before_action :task_publish, only: [:show, :show_comment, :tasks_list, :settings]
before_action :teacher_allowed, only: [:new, :create, :edit, :update, :set_public,:multi_destroy, :publish_task, :end_task,
- :update_settings, :add_to_bank]
+ :update_settings, :add_to_bank, :cross_comment_setting]
before_action :require_id_params, only: [:set_public ,:multi_destroy, :publish_task, :end_task, :add_to_bank]
before_action :valid_params, only: [:update_settings]
include ExportHelper
@@ -498,7 +498,7 @@ class GraduationTasksController < ApplicationController
end
def cross_comment_setting
-
+ @comment_status
end
private
diff --git a/config/routes.rb b/config/routes.rb
index c2da5fc63..34e9947aa 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -536,6 +536,7 @@ Rails.application.routes.draw do
post 'update_settings'
get 'tasks_list'
get :show_comment
+ get :cross_comment_setting
end
collection do
From bc8c77fc76e90f916aacf6872bb6da6360545bfe Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 2 Sep 2019 17:48:49 +0800
Subject: [PATCH 003/394] tiaoz
---
app/controllers/graduation_tasks_controller.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 076965899..836ece3e9 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -499,7 +499,9 @@ class GraduationTasksController < ApplicationController
end
def cross_comment_setting
- @comment_status
+ @comment_status = @task.cross_comment ? @task.comment_status : (params[:comment_status] || 2)
+ user_ids = @course.teacher_group_user_ids(current_user.id)
+ @work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
end
private
From 0692caf4273dec1cfe1ef8e96a5497978962998e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 3 Sep 2019 17:23:53 +0800
Subject: [PATCH 004/394] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E7=9A=84=E8=AF=84=E9=98=85=E8=AE=BE=E7=BD=AE=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/application_controller.rb | 4 +-
.../graduation_tasks_controller.rb | 109 ++++++++++++++++--
.../graduation_works_controller.rb | 2 +-
app/helpers/graduation_tasks_helper.rb | 2 +-
app/jobs/graduation_task_cross_comment_job.rb | 31 +----
app/models/graduation_task.rb | 9 +-
.../graduation_task_group_assignation.rb | 8 +-
app/models/graduation_work.rb | 19 ++-
.../graduation_work_comment_assignation.rb | 7 +-
app/models/graduation_work_score.rb | 1 +
app/models/student_work.rb | 4 +-
.../cross_comment_setting.json.jbuilder | 26 +++++
config/routes.rb | 2 +
...raduation_work_id_to_group_assignations.rb | 7 ++
...90903025159_add_temporary_to_graduation.rb | 6 +
lib/tasks/graduation_task.rake | 7 +-
16 files changed, 198 insertions(+), 46 deletions(-)
create mode 100644 app/views/graduation_tasks/cross_comment_setting.json.jbuilder
create mode 100644 db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb
create mode 100644 db/migrate/20190903025159_add_temporary_to_graduation.rb
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6046be5af..9f2813940 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -496,8 +496,8 @@ class ApplicationController < ActionController::Base
# 只看我的交叉评阅
if option[:cross_comment]
- graduation_work_id = task.graduation_work_comment_assignations.where(:user_id => current_user.id)
- .pluck(:graduation_work_id).uniq if task.graduation_work_comment_assignations
+ graduation_work_id = task.formal_graduation_work_comment_assignations.where(:user_id => current_user.id)
+ .pluck(:graduation_work_id).uniq if task.formal_graduation_work_comment_assignations
work_list = work_list.where(id: graduation_work_id)
end
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 836ece3e9..49a4ead78 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -1,13 +1,16 @@
class GraduationTasksController < ApplicationController
before_action :require_login, :check_auth, except: [:index]
- before_action :find_course, except: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment]
- before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment, :cross_comment_setting]
+ before_action :find_course, except: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment,
+ :cross_comment_setting, :assign_works, :commit_comment_setting]
+ before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment,
+ :cross_comment_setting, :assign_works, :commit_comment_setting]
before_action :user_course_identity
before_action :task_publish, only: [:show, :show_comment, :tasks_list, :settings]
before_action :teacher_allowed, only: [:new, :create, :edit, :update, :set_public,:multi_destroy, :publish_task, :end_task,
- :update_settings, :add_to_bank, :cross_comment_setting]
+ :update_settings, :add_to_bank, :cross_comment_setting, :assign_works, :commit_comment_setting]
before_action :require_id_params, only: [:set_public ,:multi_destroy, :publish_task, :end_task, :add_to_bank]
before_action :valid_params, only: [:update_settings]
+ before_action :allow_cross_comment, only: [:cross_comment_setting, :assign_works, :commit_comment_setting]
include ExportHelper
def index
@@ -99,8 +102,8 @@ class GraduationTasksController < ApplicationController
# 只看我的交叉评阅
unless params[:cross_comment].blank?
- graduation_work_id = @task.graduation_work_comment_assignations.where(:user_id =>current_user.id)
- .pluck(:graduation_work_id).uniq if @task.graduation_work_comment_assignations
+ graduation_work_id = @task.formal_graduation_work_comment_assignations.where(:user_id =>current_user.id)
+ .pluck(:graduation_work_id).uniq if @task.formal_graduation_work_comment_assignations
@work_list = @task.graduation_works.where(id: graduation_work_id)
end
@@ -499,9 +502,94 @@ class GraduationTasksController < ApplicationController
end
def cross_comment_setting
- @comment_status = @task.cross_comment ? @task.comment_status : (params[:comment_status] || 2)
- user_ids = @course.teacher_group_user_ids(current_user.id)
- @work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
+ @comment_status = params[:comment_status] || (@task.cross_comment ? @task.comment_status : 2)
+ group_ids = @course.charge_group_ids(current_user)
+ @course_groups = @course.course_groups.where(id: group_ids)
+
+ # 如果传了分班id则取合集
+ group_ids = group_ids & params[:group_ids] unless params[:group_ids].blank?
+ page = params[:page] ? params[:page].to_i : 1
+ limit = params[:limit] ? params[:limit].to_i : 10
+ @work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
+ where(course_members: {course_group_id: group_ids}).page(page).per(limit).includes(user: [:user_extension])
+ @students = @course.students.where(user_id: @work_list.pluck(:user_id))
+ end
+
+ def assign_works
+ tip_exception("请先选择作品") if params[:work_ids].blank?
+ tip_exception("请指定要分配的老师或答辩组") if params[:user_ids].blank? && params[:graduation_group_ids].blank?
+
+ ActiveRecord::Base.transaction do
+ begin
+ works = @task.graduation_works.where(id: params[:work_ids])
+ # 手动分配:分配给老师
+ if !params[:user_ids].blank?
+ works.each do |work|
+ # 之前分配的老师但现在未分配时,置为删除位,点取消时需要还原,点确认时再删除
+ work.graduation_work_comment_assignations.where.not(user_id: params[:user_ids]).update_all(temporary: 2)
+ @course.teachers.where(user_id: params[:user_ids]).pluck(:user_id).uniq.each do |user_id|
+ unless work.graduation_work_comment_assignations.exists?(user_id: user_id)
+ GraduationWorkCommentAssignation.create!(graduation_task_id: @task.id, graduation_work_id: work.id,
+ user_id: user_id, temporary: 1)
+ end
+ end
+ end
+
+ # 答辩组分配:分配答辩组
+ elsif !params[:graduation_group_ids].blank?
+ works.each do |work|
+ work.graduation_task_group_assignations.where.not(graduation_group_id: params[:graduation_group_ids]).update_all(temporary: 2)
+ @course.graduation_groups.where(id: params[:graduation_group_ids]).pluck(:id).uniq.each do |graduation_group_id|
+ unless work.graduation_task_group_assignations.exists?(graduation_group_id: graduation_group_id)
+ GraduationTaskGroupAssignation.create!(graduation_task_id: @task.id, graduation_work_id: work.id,
+ graduation_group_id: graduation_group_id, temporary: 1)
+ end
+ end
+ end
+ end
+ normal_status("分配成功")
+ rescue Exception => e
+ uid_logger(e.message)
+ tip_exception(e.message)
+ raise ActiveRecord::Rollback
+ end
+ end
+ end
+
+ def commit_comment_setting
+ tip_exception("type参数有误") if params[:type].blank? || !["commit", "cancel"].include?(params[:type])
+ ActiveRecord::Base.transaction do
+ begin
+ # 提交弹框
+ if params[:type] == "commit"
+ tip_exception("comment_status参数有误") if params[:comment_status].blank? || ![2, 4].include?(params[:comment_status].to_i)
+ @task.update_attributes(comment_status: params[:comment_status])
+ if params[:comment_status].to_i == 2
+ @task.temporary_graduation_work_comment_assignations.update_all(temporary: 0) # 临时数据转正
+ @task.delete_graduation_work_comment_assignations.destroy_all # 删除置了删除位的数据
+ @task.graduation_task_group_assignations.destroy_all # 删除答辩组分配数据
+ else
+ @task.temporary_graduation_task_group_assignations.update_all(temporary: 0)
+ @task.delete_graduation_task_group_assignations.destroy_all
+ @task.graduation_work_comment_assignations.destroy_all
+
+ GraduationTaskCrossCommentJob.perform_later(@task.id)
+ end
+ else
+ # 取消时删除临时数据,恢复删除位数据
+ @task.temporary_graduation_work_comment_assignations.destroy_all # 删除临时数据
+ @task.delete_graduation_work_comment_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
+
+ @task.temporary_graduation_task_group_assignations.destroy_all # 删除临时数据
+ @task.delete_graduation_task_group_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
+ end
+ normal_status("操作成功")
+ rescue Exception => e
+ uid_logger(e.message)
+ tip_exception(e.message)
+ raise ActiveRecord::Rollback
+ end
+ end
end
private
@@ -544,6 +632,11 @@ class GraduationTasksController < ApplicationController
tip_exception("最大人数不能小于最小人数要求") if params[:min_num].to_i > params[:max_num].to_i
end
end
+
+ def allow_cross_comment
+ tip_exception("请先开启交叉评阅再设置") unless @task.cross_comment
+ end
+
#
# def graduation_work_to_xls items
# xls_report = StringIO.new
diff --git a/app/controllers/graduation_works_controller.rb b/app/controllers/graduation_works_controller.rb
index 204e0e5d4..c22ab7706 100644
--- a/app/controllers/graduation_works_controller.rb
+++ b/app/controllers/graduation_works_controller.rb
@@ -308,7 +308,7 @@ class GraduationWorksController < ApplicationController
end
end
- if @task.status == 3 && @task.graduation_work_comment_assignations.where(graduation_work_id: @work.id, user_id: current_user.id).count > 0
+ if @task.status == 3 && @task.formal_graduation_work_comment_assignations.where(graduation_work_id: @work.id, user_id: current_user.id).count > 0
new_score.reviewer_role = 2
else
new_score.reviewer_role = 1
diff --git a/app/helpers/graduation_tasks_helper.rb b/app/helpers/graduation_tasks_helper.rb
index 2bc059a55..48926ce8f 100644
--- a/app/helpers/graduation_tasks_helper.rb
+++ b/app/helpers/graduation_tasks_helper.rb
@@ -15,7 +15,7 @@ module GraduationTasksHelper
# 交叉评阅
def cross_comment task, user_id
if task.cross_comment && task.status >= 3
- [{id: 1, name: "只看我的交叉评阅", count: task.graduation_work_comment_assignations.myself(user_id).count}]
+ [{id: 1, name: "只看我的交叉评阅", count: task.formal_graduation_work_comment_assignations.myself(user_id).count}]
else
[]
end
diff --git a/app/jobs/graduation_task_cross_comment_job.rb b/app/jobs/graduation_task_cross_comment_job.rb
index cf2cb613e..38cc56178 100644
--- a/app/jobs/graduation_task_cross_comment_job.rb
+++ b/app/jobs/graduation_task_cross_comment_job.rb
@@ -6,32 +6,13 @@ class GraduationTaskCrossCommentJob < ApplicationJob
task = GraduationTask.find_by(id: graduation_task_id)
return if task.blank?
- course = task.course
- task.graduation_task_group_assignations.each do |assignation|
+ task.graduation_task_group_assignations.includes(:graduation_group, :graduation_work).each do |assignation|
graduation_group = assignation.graduation_group
- assign_group = assignation.assign_group
- if graduation_group.present? && assign_group.present?
- course_group_ids = course.teacher_course_groups.where(course_member_id: graduation_group.course_members.pluck(:id)).pluck(:course_group_id)
- graduation_works = task.graduation_works.where(user_id: course.course_members.where(:course_group_id => course_group_ids).map(&:user_id),
- work_status: [1, 2])
- if assign_group.course_members.count <= task.comment_num
- graduation_works.each do |work|
- assign_group.course_members.each do |member|
- work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(
- graduation_group_id: assign_group.id, user_id: member.user_id, graduation_task_id: task.id)
- end
- end
- else
- member_user_ids = assign_group.course_members.pluck(:user_id)
- count = 0
- graduation_works.each do |work|
- for i in 1 .. task.comment_num
- assign_user_id = member_user_ids[count % member_user_ids.size]
- work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(
- graduation_group_id: assign_group.id, user_id: assign_user_id, graduation_task_id: task.id)
- count += 1
- end
- end
+ work = assignation.graduation_work
+ if graduation_group.present? && work.present?
+ member_ids = graduation_group.course_members.pluck(:user_id).uniq
+ member_ids.each do |user_id|
+ work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(user_id: user_id, graduation_task_id: task.id)
end
end
end
diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb
index e247f2b6e..4150c52bc 100644
--- a/app/models/graduation_task.rb
+++ b/app/models/graduation_task.rb
@@ -13,8 +13,15 @@ class GraduationTask < ApplicationRecord
has_many :attachments, as: :container, dependent: :destroy
- has_many :graduation_task_group_assignations, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
+ has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
+ has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
+ has_many :delete_graduation_work_comment_assignations, -> { temporary_delete }, class_name: "GraduationWorkCommentAssignation"
+
+ has_many :graduation_task_group_assignations, dependent: :destroy
+ has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
+ has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
+ has_many :delete_graduation_task_group_assignations, -> { temporary_delete }, class_name: "GraduationTaskGroupAssignation"
has_many :graduation_works, -> { where("is_delete = 0") }
has_many :score_graduation_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "GraduationWork"
diff --git a/app/models/graduation_task_group_assignation.rb b/app/models/graduation_task_group_assignation.rb
index 52da65191..b7e857c35 100644
--- a/app/models/graduation_task_group_assignation.rb
+++ b/app/models/graduation_task_group_assignation.rb
@@ -1,6 +1,12 @@
class GraduationTaskGroupAssignation < ApplicationRecord
+ # temporary 0: 正式分配 1:临时分配(交叉评阅设置中临时分配的作品,点取消时会删除) 2: 删除标志
belongs_to :graduation_task
belongs_to :graduation_group
- belongs_to :assign_group, class_name: 'GraduationGroup', foreign_key: :assign_graduation_group_id # 分配的互评组
+ belongs_to :assign_group, class_name: 'GraduationGroup', foreign_key: :assign_graduation_group_id, optional: true # 分配的互评组
+ belongs_to :graduation_work, optional: true
+ scope :temporary, -> {where(temporary: 1)}
+ scope :formal, -> {where(temporary: 0)}
+ scope :temporary_delete, -> {where(temporary: 2)}
+ scope :temporary_formal, -> {where(temporary: [0, 1])}
end
diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb
index 235bfcac6..aa95e8ca4 100644
--- a/app/models/graduation_work.rb
+++ b/app/models/graduation_work.rb
@@ -9,7 +9,14 @@ class GraduationWork < ApplicationRecord
has_many :attachments, as: :container, dependent: :destroy
has_many :tidings, as: :container, dependent: :destroy
has_many :graduation_work_scores, dependent: :destroy
+
has_many :graduation_work_comment_assignations, dependent: :destroy
+ has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
+ has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
+
+ has_many :graduation_task_group_assignations, dependent: :destroy
+ has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
+ has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
validates :description, length: { maximum: 5000 }
@@ -108,11 +115,21 @@ 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?
+ graduation_work_scores.where.not(core: nil).exists?
+ end
+
+ def work_cross_teachers
+ User.where(id: graduation_work_comment_assignations.temporary_formal.pluck(:user_id)).map(&:real_name).join("、")
+ end
+
+ def work_cross_groups
+ course.graduation_groups.where(id: graduation_task_group_assignations.temporary_formal.pluck(:graduation_group_id)).pluck(:name).join("、")
end
end
diff --git a/app/models/graduation_work_comment_assignation.rb b/app/models/graduation_work_comment_assignation.rb
index 33f30d2a0..7225dbcbf 100644
--- a/app/models/graduation_work_comment_assignation.rb
+++ b/app/models/graduation_work_comment_assignation.rb
@@ -1,8 +1,13 @@
class GraduationWorkCommentAssignation < ApplicationRecord
+ # temporary 0: 正式分配 1:临时分配(交叉评阅设置中临时分配的作品,点取消时会删除) 2: 删除标志
belongs_to :graduation_work
belongs_to :graduation_task
belongs_to :user
- belongs_to :graduation_group
+ belongs_to :graduation_group, optional: true
+ scope :temporary, -> {where(temporary: 1)}
+ scope :formal, -> {where(temporary: 0)}
+ scope :temporary_delete, -> {where(temporary: 2)}
+ scope :temporary_formal, -> {where(temporary: [0, 1])}
scope :myself, ->(user_id) {where(user_id: user_id)}
end
diff --git a/app/models/graduation_work_score.rb b/app/models/graduation_work_score.rb
index fa978b68f..eaf59ffbd 100644
--- a/app/models/graduation_work_score.rb
+++ b/app/models/graduation_work_score.rb
@@ -1,4 +1,5 @@
class GraduationWorkScore < ApplicationRecord
+ # reviewer_role: 1 老师评分 2 交叉评分
belongs_to :graduation_work
belongs_to :user
belongs_to :graduation_task
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index 168cfeb68..26409da59 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -192,7 +192,7 @@ class StudentWork < ApplicationRecord
end
def scored?
- student_works_scores.where.not(reviewer_role: 3).exists?
+ student_works_scores.where.not(reviewer_role: 3, score: nil).exists?
end
def work_challenge_score game, score
@@ -201,7 +201,7 @@ class StudentWork < ApplicationRecord
if adjust_score.present?
game_score = adjust_score.score
else
- setting = homework_common.homework_group_setting user_id
+ setting = homework_common.homework_group_setting game.user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time))
answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation
game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0)
diff --git a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
new file mode 100644
index 000000000..58ceb16a2
--- /dev/null
+++ b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
@@ -0,0 +1,26 @@
+json.work_users @work_list do |work|
+ json.work_id work.id
+ json.user_name work.user&.real_name
+ json.student_id work.user&.student_id
+ json.course_group_name @students.select{|member| member.user_id == work.user_id}.first.try(:course_group_name)
+ if @comment_status.to_i == 2
+ json.cross_teachers work.work_cross_teachers
+ elsif @comment_status.to_i == 4
+ json.cross_groups work.work_cross_groups
+ end
+end
+
+json.course_groups @course_groups do |group|
+ json.(group, :id, :name)
+end
+
+if @comment_status.to_i == 2
+ json.teachers @course.teachers.includes(:user) do |teacher|
+ json.user_id teacher.user_id
+ json.user_name teacher.user&.real_name
+ end
+elsif @comment_status.to_i == 4
+ json.graduation_groups @course.graduation_groups do |group|
+ json.(group, :id, :name)
+ end
+end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 34e9947aa..6e5727dfd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -537,6 +537,8 @@ Rails.application.routes.draw do
get 'tasks_list'
get :show_comment
get :cross_comment_setting
+ post :assign_works
+ post :commit_comment_setting
end
collection do
diff --git a/db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb b/db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb
new file mode 100644
index 000000000..e1db275fb
--- /dev/null
+++ b/db/migrate/20190903022313_add_graduation_work_id_to_group_assignations.rb
@@ -0,0 +1,7 @@
+class AddGraduationWorkIdToGroupAssignations < ActiveRecord::Migration[5.2]
+ def change
+ add_column :graduation_task_group_assignations, :graduation_work_id, :integer, default: 0
+
+ add_index :graduation_task_group_assignations, :graduation_work_id
+ end
+end
diff --git a/db/migrate/20190903025159_add_temporary_to_graduation.rb b/db/migrate/20190903025159_add_temporary_to_graduation.rb
new file mode 100644
index 000000000..adf7e1aa3
--- /dev/null
+++ b/db/migrate/20190903025159_add_temporary_to_graduation.rb
@@ -0,0 +1,6 @@
+class AddTemporaryToGraduation < ActiveRecord::Migration[5.2]
+ def change
+ add_column :graduation_task_group_assignations, :temporary, :integer, default: 0
+ add_column :graduation_work_comment_assignations, :temporary, :integer, default: 0
+ end
+end
diff --git a/lib/tasks/graduation_task.rake b/lib/tasks/graduation_task.rake
index 58f7764d0..92a1900d2 100644
--- a/lib/tasks/graduation_task.rake
+++ b/lib/tasks/graduation_task.rake
@@ -43,9 +43,10 @@ namespace :graduation_task do
task :cross_comment_start => :environment do
tasks = GraduationTask.where("cross_comment = 1 and comment_time is not null and comment_time <= '#{Time.now}' and status = 2")
tasks.each do |task|
- if task.comment_status == 4
- GraduationTaskCrossCommentJob.perform_later(task.id)
- end
+ # 改成设置时都实时分配
+ # if task.comment_status == 4
+ # GraduationTaskCrossCommentJob.perform_later(task.id)
+ # end
task.update_attributes(status: 3)
# 给老师发消息
From 06a4a5a4d6b69fb01ce447f04b4244d6751ad159 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 11 Sep 2019 16:55:41 +0800
Subject: [PATCH 005/394] =?UTF-8?q?=E4=BA=A4=E5=8F=89=E8=AF=84=E9=98=85?=
=?UTF-8?q?=E7=9A=84=E8=AF=84=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/graduation_works_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/graduation_works_controller.rb b/app/controllers/graduation_works_controller.rb
index c22ab7706..bc10c0a91 100644
--- a/app/controllers/graduation_works_controller.rb
+++ b/app/controllers/graduation_works_controller.rb
@@ -308,7 +308,7 @@ class GraduationWorksController < ApplicationController
end
end
- if @task.status == 3 && @task.formal_graduation_work_comment_assignations.where(graduation_work_id: @work.id, user_id: current_user.id).count > 0
+ if @work.formal_graduation_work_comment_assignations.where(user_id: current_user.id).count > 0
new_score.reviewer_role = 2
else
new_score.reviewer_role = 1
From 856942dbb0ff982c0885a301ebab2a36dbaa40b7 Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Wed, 11 Sep 2019 19:14:20 +0800
Subject: [PATCH 006/394] =?UTF-8?q?=E4=BA=A4=E5=8F=89=E8=AF=84=E9=98=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modules/courses/graduation/tasks/GraduationAcrossCheck.js | 0
.../modules/courses/graduation/tasks/GraduationTaskDetail.js | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
create mode 100644 public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js b/public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskDetail.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskDetail.js
index 0aff1a1bd..e228d4146 100644
--- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskDetail.js
+++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskDetail.js
@@ -436,7 +436,7 @@ class GraduationTaskDetail extends Component{
{/*项目在线质量检测*/}
{ this.props.isAdmin() ? questionslist.status===1 ? { this.end()} }>立即截止 : "" : "" }
{ this.props.isAdmin() ? questionslist.status===0 ? { this.publish()} }>立即发布 : "" : "" }
-
+ { this.props.isAdmin() ? 交叉评阅设置 : "" }
{ this.props.isAdmin() ? 编辑任务 : "" }
From 04722f0a8cf4719bc00f4c5cce72831dc60a0832 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 17 Sep 2019 10:10:09 +0800
Subject: [PATCH 007/394] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E8=AF=84=E9=98=85?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/graduation_tasks/cross_comment_setting.json.jbuilder | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
index 58ceb16a2..72cae6eba 100644
--- a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
+++ b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
@@ -10,6 +10,8 @@ json.work_users @work_list do |work|
end
end
+json.user_count @work_list.size
+
json.course_groups @course_groups do |group|
json.(group, :id, :name)
end
From cfb610a787cd541b0530c7c28d52a2400f8650d6 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 17 Sep 2019 10:56:14 +0800
Subject: [PATCH 008/394] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/graduation_tasks_controller.rb | 2 ++
.../20190917024120_migrate_graduation_task_comment_status.rb | 5 +++++
2 files changed, 7 insertions(+)
create mode 100644 db/migrate/20190917024120_migrate_graduation_task_comment_status.rb
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index fe8bd660c..da3c680ce 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -457,6 +457,8 @@ class GraduationTasksController < ApplicationController
@task.comment_time = @task.cross_comment ? params[:comment_time] : nil
+ @task.comment_status = 2 if @task.cross_comment && @task.comment_status == 0
+
# unless @task.cross_comment
# @task.graduation_work_comment_assignations.destroy_all
# end
diff --git a/db/migrate/20190917024120_migrate_graduation_task_comment_status.rb b/db/migrate/20190917024120_migrate_graduation_task_comment_status.rb
new file mode 100644
index 000000000..3b3a3fccc
--- /dev/null
+++ b/db/migrate/20190917024120_migrate_graduation_task_comment_status.rb
@@ -0,0 +1,5 @@
+class MigrateGraduationTaskCommentStatus < ActiveRecord::Migration[5.2]
+ def change
+ GraduationTask.where(cross_comment: true, comment_status: 0).update_all(comment_status: 2)
+ end
+end
From 4c13fb53a9d289fb2b37ce8ce600051087176b2e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 17 Sep 2019 14:06:15 +0800
Subject: [PATCH 009/394] =?UTF-8?q?=E8=81=8C=E4=B8=9A=E8=AE=A4=E8=AF=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/users/apply_professional_auth_service.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/services/users/apply_professional_auth_service.rb b/app/services/users/apply_professional_auth_service.rb
index 74ee08c85..cc6f36fff 100644
--- a/app/services/users/apply_professional_auth_service.rb
+++ b/app/services/users/apply_professional_auth_service.rb
@@ -38,11 +38,11 @@ class Users::ApplyProfessionalAuthService < ApplicationService
move_image_file! unless params[:upload_image].to_s == 'false'
- # sms_cache = Rails.cache.read("apply_pro_certification")
- # if sms_cache.nil?
- sms_notify_admin
- # Rails.cache.write("apply_pro_certification", 1)
- # end
+ sms_cache = Rails.cache.read("apply_pro_certification")
+ if sms_cache.nil?
+ sms_notify_admin
+ Rails.cache.write("apply_pro_certification", 1, expires_in: 5.minutes)
+ end
end
end
From e3d99170ffa3162c07e72b9f6d18680f70dd9196 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 17 Sep 2019 14:08:10 +0800
Subject: [PATCH 010/394] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/graduation_tasks_controller.rb | 4 +++-
.../graduation_tasks/cross_comment_setting.json.jbuilder | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index da3c680ce..2475ded42 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -513,7 +513,9 @@ class GraduationTasksController < ApplicationController
page = params[:page] ? params[:page].to_i : 1
limit = params[:limit] ? params[:limit].to_i : 10
@work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
- where(course_members: {course_group_id: group_ids}).page(page).per(limit).includes(user: [:user_extension])
+ where(course_members: {course_group_id: group_ids})
+ @user_count = @work_list.size
+ @work_list = @work_list.page(page).per(limit).includes(user: [:user_extension])
@students = @course.students.where(user_id: @work_list.pluck(:user_id))
end
diff --git a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
index 72cae6eba..a10343c0b 100644
--- a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
+++ b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
@@ -10,7 +10,7 @@ json.work_users @work_list do |work|
end
end
-json.user_count @work_list.size
+json.user_count @user_count
json.course_groups @course_groups do |group|
json.(group, :id, :name)
From 1120b3804227304c470a5ed62bd87c46ecc87cc9 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 17 Sep 2019 14:51:07 +0800
Subject: [PATCH 011/394] =?UTF-8?q?=E5=AE=9E=E5=90=8D=E8=AE=A4=E8=AF=81?=
=?UTF-8?q?=E5=8A=A0cache=EF=BC=8C5=E5=88=86=E9=92=9F=E5=86=85=E4=B8=8D?=
=?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=8F=91=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/users/apply_trail_service.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/services/users/apply_trail_service.rb b/app/services/users/apply_trail_service.rb
index 61563c301..45abd8d1b 100644
--- a/app/services/users/apply_trail_service.rb
+++ b/app/services/users/apply_trail_service.rb
@@ -24,7 +24,11 @@ class Users::ApplyTrailService < ApplicationService
apply.status = 1
else
- send_trial_apply_notify!
+ sms_cache = Rails.cache.read("apply_auth")
+ if sms_cache.nil?
+ send_trial_apply_notify!
+ Rails.cache.write("apply_auth", 1, expires_in: 5.minutes)
+ end
end
apply.save!
end
From dc4931a705f766dbed6e566008f5ed294caa216f Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 17 Sep 2019 16:58:13 +0800
Subject: [PATCH 012/394] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/graduation_work.rb | 12 ++++++++++--
.../cross_comment_setting.json.jbuilder | 2 ++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb
index aa95e8ca4..904d0cbdc 100644
--- a/app/models/graduation_work.rb
+++ b/app/models/graduation_work.rb
@@ -125,11 +125,19 @@ class GraduationWork < ApplicationRecord
graduation_work_scores.where.not(core: nil).exists?
end
+ def work_cross_teacher_ids
+ graduation_work_comment_assignations.temporary_formal.pluck(:user_id)
+ end
+
def work_cross_teachers
- User.where(id: graduation_work_comment_assignations.temporary_formal.pluck(:user_id)).map(&:real_name).join("、")
+ User.where(id: work_cross_teacher_ids).map(&:real_name).join("、")
+ end
+
+ def work_cross_group_ids
+ graduation_task_group_assignations.temporary_formal.pluck(:graduation_group_id)
end
def work_cross_groups
- course.graduation_groups.where(id: graduation_task_group_assignations.temporary_formal.pluck(:graduation_group_id)).pluck(:name).join("、")
+ course.graduation_groups.where(id: work_cross_group_ids).pluck(:name).join("、")
end
end
diff --git a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
index a10343c0b..f63bc28cc 100644
--- a/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
+++ b/app/views/graduation_tasks/cross_comment_setting.json.jbuilder
@@ -5,8 +5,10 @@ json.work_users @work_list do |work|
json.course_group_name @students.select{|member| member.user_id == work.user_id}.first.try(:course_group_name)
if @comment_status.to_i == 2
json.cross_teachers work.work_cross_teachers
+ json.cross_teacher_ids work.work_cross_teacher_ids
elsif @comment_status.to_i == 4
json.cross_groups work.work_cross_groups
+ json.cross_group_ids work.work_cross_group_ids
end
end
From 04406419f3d269a85fbbecf71cdc7cc9af4ae94a Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 18 Sep 2019 09:16:02 +0800
Subject: [PATCH 013/394] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/graduation_tasks_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 2475ded42..100a671ec 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -509,7 +509,7 @@ class GraduationTasksController < ApplicationController
@course_groups = @course.course_groups.where(id: group_ids)
# 如果传了分班id则取合集
- group_ids = group_ids & params[:group_ids] unless params[:group_ids].blank?
+ group_ids = group_ids & params[:group_ids].map(&:to_i) unless params[:group_ids].blank?
page = params[:page] ? params[:page].to_i : 1
limit = params[:limit] ? params[:limit].to_i : 10
@work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
From 2606717142aee138c4b776984073c9b5e28c055c Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 18 Sep 2019 14:18:04 +0800
Subject: [PATCH 014/394] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/application_controller.rb | 4 +-
.../graduation_tasks_controller.rb | 74 ++++++++++---------
.../graduation_works_controller.rb | 2 +-
app/helpers/graduation_tasks_helper.rb | 2 +-
app/jobs/graduation_task_cross_comment_job.rb | 4 +-
app/models/graduation_task.rb | 14 ++--
app/models/graduation_work.rb | 8 +-
lib/tasks/graduation_task.rake | 6 +-
8 files changed, 61 insertions(+), 53 deletions(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e338c1c63..2ce52d405 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -503,8 +503,8 @@ class ApplicationController < ActionController::Base
# 只看我的交叉评阅
if option[:cross_comment]
- graduation_work_id = task.formal_graduation_work_comment_assignations.where(:user_id => current_user.id)
- .pluck(:graduation_work_id).uniq if task.formal_graduation_work_comment_assignations
+ graduation_work_id = task.graduation_work_comment_assignations.where(:user_id => current_user.id)
+ .pluck(:graduation_work_id).uniq if task.graduation_work_comment_assignations
work_list = work_list.where(id: graduation_work_id)
end
diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb
index 100a671ec..6a0ce85a9 100644
--- a/app/controllers/graduation_tasks_controller.rb
+++ b/app/controllers/graduation_tasks_controller.rb
@@ -102,8 +102,8 @@ class GraduationTasksController < ApplicationController
# 只看我的交叉评阅
unless params[:cross_comment].blank?
- graduation_work_id = @task.formal_graduation_work_comment_assignations.where(:user_id =>current_user.id)
- .pluck(:graduation_work_id).uniq if @task.formal_graduation_work_comment_assignations
+ graduation_work_id = @task.graduation_work_comment_assignations.where(:user_id =>current_user.id)
+ .pluck(:graduation_work_id).uniq if @task.graduation_work_comment_assignations
@work_list = @task.graduation_works.where(id: graduation_work_id)
end
@@ -459,9 +459,7 @@ class GraduationTasksController < ApplicationController
@task.comment_status = 2 if @task.cross_comment && @task.comment_status == 0
- # unless @task.cross_comment
- # @task.graduation_work_comment_assignations.destroy_all
- # end
+ @task.graduation_work_comment_assignations.destroy_all if !@task.cross_comment
# 去掉评阅设置
# @task.comment_num = @task.cross_comment ? params[:comment_num].to_i : 3
# @task.comment_status = @task.cross_comment ? params[:comment_status] : 0
@@ -512,8 +510,14 @@ class GraduationTasksController < ApplicationController
group_ids = group_ids & params[:group_ids].map(&:to_i) unless params[:group_ids].blank?
page = params[:page] ? params[:page].to_i : 1
limit = params[:limit] ? params[:limit].to_i : 10
- @work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
- where(course_members: {course_group_id: group_ids})
+
+ # 取所有课堂的作品
+ if group_ids.sort == @course.course_groups.pluck(:id).sort
+ @work_list = @task.graduation_works
+ else
+ @work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
+ where(course_members: {course_group_id: group_ids})
+ end
@user_count = @work_list.size
@work_list = @work_list.page(page).per(limit).includes(user: [:user_extension])
@students = @course.students.where(user_id: @work_list.pluck(:user_id))
@@ -528,25 +532,27 @@ class GraduationTasksController < ApplicationController
works = @task.graduation_works.where(id: params[:work_ids])
# 手动分配:分配给老师
if !params[:user_ids].blank?
+ @task.update_attributes(comment_status: 2)
works.each do |work|
- # 之前分配的老师但现在未分配时,置为删除位,点取消时需要还原,点确认时再删除
- work.graduation_work_comment_assignations.where.not(user_id: params[:user_ids]).update_all(temporary: 2)
+ # 之前分配的老师但现在未分配时需要删除
+ work.graduation_work_comment_assignations.where.not(user_id: params[:user_ids]).destroy_all
@course.teachers.where(user_id: params[:user_ids]).pluck(:user_id).uniq.each do |user_id|
unless work.graduation_work_comment_assignations.exists?(user_id: user_id)
GraduationWorkCommentAssignation.create!(graduation_task_id: @task.id, graduation_work_id: work.id,
- user_id: user_id, temporary: 1)
+ user_id: user_id)
end
end
end
# 答辩组分配:分配答辩组
elsif !params[:graduation_group_ids].blank?
+ @task.update_attributes(comment_status: 4)
works.each do |work|
- work.graduation_task_group_assignations.where.not(graduation_group_id: params[:graduation_group_ids]).update_all(temporary: 2)
+ work.graduation_task_group_assignations.where.not(graduation_group_id: params[:graduation_group_ids]).destroy_all
@course.graduation_groups.where(id: params[:graduation_group_ids]).pluck(:id).uniq.each do |graduation_group_id|
unless work.graduation_task_group_assignations.exists?(graduation_group_id: graduation_group_id)
GraduationTaskGroupAssignation.create!(graduation_task_id: @task.id, graduation_work_id: work.id,
- graduation_group_id: graduation_group_id, temporary: 1)
+ graduation_group_id: graduation_group_id)
end
end
end
@@ -565,28 +571,28 @@ class GraduationTasksController < ApplicationController
ActiveRecord::Base.transaction do
begin
# 提交弹框
- if params[:type] == "commit"
- tip_exception("comment_status参数有误") if params[:comment_status].blank? || ![2, 4].include?(params[:comment_status].to_i)
- @task.update_attributes(comment_status: params[:comment_status])
- if params[:comment_status].to_i == 2
- @task.temporary_graduation_work_comment_assignations.update_all(temporary: 0) # 临时数据转正
- @task.delete_graduation_work_comment_assignations.destroy_all # 删除置了删除位的数据
- @task.graduation_task_group_assignations.destroy_all # 删除答辩组分配数据
- else
- @task.temporary_graduation_task_group_assignations.update_all(temporary: 0)
- @task.delete_graduation_task_group_assignations.destroy_all
- @task.graduation_work_comment_assignations.destroy_all
-
- GraduationTaskCrossCommentJob.perform_later(@task.id)
- end
- else
- # 取消时删除临时数据,恢复删除位数据
- @task.temporary_graduation_work_comment_assignations.destroy_all # 删除临时数据
- @task.delete_graduation_work_comment_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
-
- @task.temporary_graduation_task_group_assignations.destroy_all # 删除临时数据
- @task.delete_graduation_task_group_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
- end
+ # if params[:type] == "commit"
+ # tip_exception("comment_status参数有误") if params[:comment_status].blank? || ![2, 4].include?(params[:comment_status].to_i)
+ # @task.update_attributes(comment_status: params[:comment_status])
+ # if params[:comment_status].to_i == 2
+ # @task.temporary_graduation_work_comment_assignations.update_all(temporary: 0) # 临时数据转正
+ # @task.delete_graduation_work_comment_assignations.destroy_all # 删除置了删除位的数据
+ # @task.graduation_task_group_assignations.destroy_all # 删除答辩组分配数据
+ # else
+ # @task.temporary_graduation_task_group_assignations.update_all(temporary: 0)
+ # @task.delete_graduation_task_group_assignations.destroy_all
+ # @task.graduation_work_comment_assignations.destroy_all
+ #
+ # GraduationTaskCrossCommentJob.perform_later(@task.id)
+ # end
+ # else
+ # # 取消时删除临时数据,恢复删除位数据
+ # @task.temporary_graduation_work_comment_assignations.destroy_all # 删除临时数据
+ # @task.delete_graduation_work_comment_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
+ #
+ # @task.temporary_graduation_task_group_assignations.destroy_all # 删除临时数据
+ # @task.delete_graduation_task_group_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
+ # end
normal_status("操作成功")
rescue Exception => e
uid_logger(e.message)
diff --git a/app/controllers/graduation_works_controller.rb b/app/controllers/graduation_works_controller.rb
index bc10c0a91..1d26a3ed1 100644
--- a/app/controllers/graduation_works_controller.rb
+++ b/app/controllers/graduation_works_controller.rb
@@ -308,7 +308,7 @@ class GraduationWorksController < ApplicationController
end
end
- if @work.formal_graduation_work_comment_assignations.where(user_id: current_user.id).count > 0
+ if @task.cross_comment && @work.graduation_work_comment_assignations.where(user_id: current_user.id).count > 0
new_score.reviewer_role = 2
else
new_score.reviewer_role = 1
diff --git a/app/helpers/graduation_tasks_helper.rb b/app/helpers/graduation_tasks_helper.rb
index 48926ce8f..2bc059a55 100644
--- a/app/helpers/graduation_tasks_helper.rb
+++ b/app/helpers/graduation_tasks_helper.rb
@@ -15,7 +15,7 @@ module GraduationTasksHelper
# 交叉评阅
def cross_comment task, user_id
if task.cross_comment && task.status >= 3
- [{id: 1, name: "只看我的交叉评阅", count: task.formal_graduation_work_comment_assignations.myself(user_id).count}]
+ [{id: 1, name: "只看我的交叉评阅", count: task.graduation_work_comment_assignations.myself(user_id).count}]
else
[]
end
diff --git a/app/jobs/graduation_task_cross_comment_job.rb b/app/jobs/graduation_task_cross_comment_job.rb
index 38cc56178..a2d181b50 100644
--- a/app/jobs/graduation_task_cross_comment_job.rb
+++ b/app/jobs/graduation_task_cross_comment_job.rb
@@ -12,7 +12,9 @@ class GraduationTaskCrossCommentJob < ApplicationJob
if graduation_group.present? && work.present?
member_ids = graduation_group.course_members.pluck(:user_id).uniq
member_ids.each do |user_id|
- work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(user_id: user_id, graduation_task_id: task.id)
+ unless work.graduation_work_comment_assignations.exists?(user_id: user_id)
+ work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(user_id: user_id, graduation_task_id: task.id)
+ end
end
end
end
diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb
index c42c92890..c9838954a 100644
--- a/app/models/graduation_task.rb
+++ b/app/models/graduation_task.rb
@@ -14,14 +14,14 @@ class GraduationTask < ApplicationRecord
has_many :attachments, as: :container, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
- has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
- has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
- has_many :delete_graduation_work_comment_assignations, -> { temporary_delete }, class_name: "GraduationWorkCommentAssignation"
-
+ # has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
+ # has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
+ # has_many :delete_graduation_work_comment_assignations, -> { temporary_delete }, class_name: "GraduationWorkCommentAssignation"
+ #
has_many :graduation_task_group_assignations, dependent: :destroy
- has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
- has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
- has_many :delete_graduation_task_group_assignations, -> { temporary_delete }, class_name: "GraduationTaskGroupAssignation"
+ # has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
+ # has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
+ # has_many :delete_graduation_task_group_assignations, -> { temporary_delete }, class_name: "GraduationTaskGroupAssignation"
has_many :graduation_works, -> { where("is_delete = 0") }
has_many :score_graduation_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "GraduationWork"
diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb
index 904d0cbdc..73c217114 100644
--- a/app/models/graduation_work.rb
+++ b/app/models/graduation_work.rb
@@ -11,12 +11,12 @@ class GraduationWork < ApplicationRecord
has_many :graduation_work_scores, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
- has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
- has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
+ # has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
+ # has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
has_many :graduation_task_group_assignations, dependent: :destroy
- has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
- has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
+ # has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
+ # has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
validates :description, length: { maximum: 5000 }
diff --git a/lib/tasks/graduation_task.rake b/lib/tasks/graduation_task.rake
index 92a1900d2..4d8bf80b8 100644
--- a/lib/tasks/graduation_task.rake
+++ b/lib/tasks/graduation_task.rake
@@ -44,9 +44,9 @@ namespace :graduation_task do
tasks = GraduationTask.where("cross_comment = 1 and comment_time is not null and comment_time <= '#{Time.now}' and status = 2")
tasks.each do |task|
# 改成设置时都实时分配
- # if task.comment_status == 4
- # GraduationTaskCrossCommentJob.perform_later(task.id)
- # end
+ if task.comment_status == 4
+ GraduationTaskCrossCommentJob.perform_later(task.id)
+ end
task.update_attributes(status: 3)
# 给老师发消息
From 2ef8fe31b5696e3e2285e4ed23e3c17d0980d752 Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Wed, 18 Sep 2019 14:49:05 +0800
Subject: [PATCH 015/394] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1-?=
=?UTF-8?q?=E4=BA=A4=E5=8F=89=E8=AF=84=E9=98=85=E8=AE=BE=E7=BD=AE=E5=BC=B9?=
=?UTF-8?q?=E6=A1=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/graduation/style.css | 11 +
.../graduation/tasks/GraduationAcrossCheck.js | 475 ++++++++++++++++++
.../graduation/tasks/GraduationTaskDetail.js | 42 +-
.../tasks/GraduationTaskssetting.js | 16 +-
4 files changed, 532 insertions(+), 12 deletions(-)
diff --git a/public/react/src/modules/courses/graduation/style.css b/public/react/src/modules/courses/graduation/style.css
index c704a9c93..5d78f3cb9 100644
--- a/public/react/src/modules/courses/graduation/style.css
+++ b/public/react/src/modules/courses/graduation/style.css
@@ -43,3 +43,14 @@
.TopicDetailTable .bottomBody li{border-bottom: 1px solid #eee;clear: both;}
.TopicDetailTable .bottomBody li:last-child{border-bottom: none;}
+.acrossSureBtn{
+ width:40px;
+ height:24px;
+ line-height: 20px;
+ border:1px solid rgba(76,172,255,1);
+ color: #4CACFF!important;
+ float: left;
+ border-radius:4px;
+ text-align: center
+}
+
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js b/public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js
index e69de29bb..2cca4ccae 100644
--- a/public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js
+++ b/public/react/src/modules/courses/graduation/tasks/GraduationAcrossCheck.js
@@ -0,0 +1,475 @@
+import React, { Component } from 'react';
+
+import { Modal , Radio , Table , Pagination , Select ,Divider ,Icon , Input } from "antd";
+import {Link} from 'react-router-dom'
+import axios from 'axios';
+
+import '../style.css'
+
+
+const RadioGroup = Radio.Group;
+
+const { Option } = Select;
+const $ = window.$;
+
+const bindTableColumn=(that)=>{
+ let { course_groups }=that.state
+ const filter=course_groups && course_groups.map((i,key)=>{
+ let list={
+ value: i.id,
+ text: i.name
+ }
+ return list;
+ })
+ const columns = [
+ {
+ title: '序号',
+ dataIndex: 'index',
+ key: 'index',
+ width:"50px",
+ className:"edu-txt-center",
+ render: (id, student, index) => {
+ return (that.state.page - 1) * that.state.limit + index + 1
+ }
+ },
+ {
+ title: '姓名',
+ dataIndex: 'user_name',
+ key: 'user_name',
+ render: (user_name, line, index) => {
+ return(
+ {user_name}
+ )
+ }
+ },{
+ title: '学号',
+ dataIndex: 'student_id',
+ key: 'student_id',
+ render: (student_id, line, index) => {
+ return(
+ {student_id}
+ )
+ }
+ },{
+ title: '分班',
+ dataIndex: 'course_group_name',
+ key: 'course_group_name',
+ filters:filter,
+ render: (course_group_name, line, index) => {
+ return(
+ {course_group_name}
+ )
+ }
+ }
+ ];
+ if(that.state.comment_status == 2){
+ columns.push({
+ title: '交叉评阅老师',
+ dataIndex: 'cross_teachers',
+ key: 'cross_teachers',
+ width:"200px",
+ render: (cross_teachers, line, index) => {
+ return(
+ {cross_teachers}
+ )
+ }
+ })
+ }else{
+ columns.push({
+ title: '答辩组',
+ dataIndex: 'cross_groups',
+ key: 'cross_groups',
+ width:"200px",
+ render: (cross_groups, line, index) => {
+ return(
+ {cross_groups}
+ )
+ }
+ })
+ }
+ return columns;
+}
+class GraduationAcrossCheck extends Component{
+ constructor(props){
+ super(props);
+ this.state={
+ comment_status:2,
+ page:1,
+ limit:7,
+ group_ids:undefined,
+ users:undefined,
+ user_count:undefined,
+ graduation_groups:undefined,
+ course_groups:undefined,
+ teachers:undefined,
+ tableLoading:false,
+ chooseCount:0,
+ chooseId:undefined,
+ AcrossTeamIds:undefined,
+ searchValue:undefined,
+ showflag:false
+ }
+ }
+
+
+
+ // 根据分班筛选
+ filterByGroup=(value,record)=>{
+ console.log(value);
+ console.log(record)
+ }
+
+ // 切换分配方式
+ funcommentstatus = (e) =>{
+ this.setState({
+ comment_status:e.target.value,
+ chooseCount:0,
+ chooseId:[],
+ AcrossTeamIds:undefined,
+ searchValue:undefined,
+ showflag:false,
+ page:1
+ })
+ let { group_ids }=this.state;
+ this.getList(1,group_ids,e.target.value);
+ }
+
+ componentDidMount =()=>{
+ let { comment_status }=this.props;
+ let { page,group_ids }=this.state;
+ this.setState({
+ comment_status
+ })
+
+ this.getList(page,group_ids,comment_status);
+
+ window.addEventListener('click', this.clickOther)
+ }
+
+ clickOther = (e) =>{
+ if(e.target && e.target.matches('#acrossContent') || e.target.matches(".ant-modal-body")
+ || e.target.matches(".acrossfoot") || e.target.matches(".acrossHead") || e.target.matches ('.ant-radio-wrapper') ||
+ e.target.matches("th") || e.target.matches("td")) {
+ this.setState({
+ showflag:false
+ })
+ }
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('click', this.clickOther);
+ }
+
+ getList=(page,group_ids,comment_status)=>{
+ let { limit }=this.state;
+ let { task_Id }=this.props;
+ this.setState({
+ tableLoading:true
+ })
+ let url=`/graduation_tasks/${task_Id}/cross_comment_setting.json`;
+ axios.get((url),{params:{
+ page,limit,group_ids,comment_status
+ }}).then((result)=>{
+ if(result){
+ this.setState({
+ users:result.data.work_users && result.data.work_users.map((item,key)=>{
+ let list = {
+ key:item.work_id,
+ course_group_name:item.course_group_name,
+ cross_teachers: item.cross_teachers,
+ student_id:item.student_id,
+ user_name:item.user_name,
+ work_id:item.work_id
+ }
+ return list;
+ }),
+ user_count:result.data.user_count,
+ graduation_groups:result.data.graduation_groups,
+ course_groups:result.data.course_groups,
+ teachers:result.data.teachers,
+ tableLoading:false,
+ // AcrossTeamIds:result.data
+ })
+ }
+ }).catch((error)=>{
+ this.setState({
+ tableLoading:false
+ })
+ console.log(error);
+ })
+ }
+
+ // 切换分页
+ onPageChange=(page)=>{
+ this.setState({
+ page,
+ showflag:false
+ })
+ let{group_ids,comment_status}=this.state;
+ this.getList(page,group_ids,comment_status);
+ }
+
+ // 下拉切换
+ changeSelect = (AcrossTeamIds) =>{
+ this.setState({
+ AcrossTeamIds
+ })
+ }
+
+ // 重置
+ clearSelect =()=>{
+ this.setState({
+ AcrossTeamIds:undefined,
+ searchValue:undefined
+ })
+ }
+
+ // 确定分配
+ sureAcross=()=>{
+ let { AcrossTeamIds , chooseId , group_ids , comment_status }=this.state;
+ let { task_Id }=this.props;
+
+ let type = comment_status == 2 ? "user_ids" : "graduation_group_ids";
+
+ let url=`/graduation_tasks/${task_Id}/assign_works.json`;
+ if(!AcrossTeamIds || (AcrossTeamIds && AcrossTeamIds.length==0)){
+ this.props.showNotification(`请先选择${ comment_status == 2 ? "老师": "答辩组" }!`);
+ return;
+ }
+ if(!chooseId || (chooseId && chooseId.length==0)){
+ this.props.showNotification("请先选择毕设作品!");
+ return;
+ }
+ axios.post((url),{
+ [type]:AcrossTeamIds,
+ work_ids:chooseId
+ }).then((result)=>{
+ if(result){
+ this.props.showNotification(result.data.message);
+ this.getList(1,group_ids,comment_status);
+ this.setState({
+ showflag:false,
+ AcrossTeamIds:undefined,
+ chooseCount:0,
+ chooseId:[]
+ })
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+ // 筛选
+ handleTableChange =(pagination, filters, sorter)=>{
+ console.log(filters.course_group_name)
+ // if(filters.course_group_name.length > 0){
+ this.setState({
+ page:1,
+ group_ids:filters.course_group_name
+ })
+ let { comment_status }= this.state;
+ this.getList(1,filters.course_group_name,comment_status);
+ // }
+ }
+
+ // 下拉搜索
+ changeSearchValue=(e)=>{
+ this.setState({
+ searchValue:e.target.value
+ })
+ }
+ // 显示下拉
+ changeFlag=(flag)=>{
+ this.setState({
+ showflag:flag
+ })
+ }
+
+
+ render(){
+ let {
+ comment_status,
+ users,
+ user_count,
+ graduation_groups,
+ course_groups,
+ teachers,
+ page,
+ limit,
+ tableLoading,
+ chooseCount,
+ chooseId,
+ AcrossTeamIds,
+ searchValue,showflag
+ } = this.state;
+ let { modalVisible } = this.props;
+ let courseId = this.props.match.params.coursesId;
+
+ const radioStyle = {
+ display: 'block',
+ height: '30px',
+ lineHeight: '30px',
+ marginRight:'0px'
+ };
+
+
+
+ const rowSelection = {
+ // 选中行的key,选中行
+ onChange: (selectedRowKeys, selectedRows) => {
+ this.setState({
+ chooseId:selectedRowKeys,
+ chooseCount:selectedRowKeys.length,
+ showflag:false
+ })
+ console.log(selectedRowKeys);
+ },
+ selectedRowKeys:chooseId,
+ getCheckboxProps: record => ({
+ disabled: record.name === 'Disabled User', // Column configuration not to be checked
+ name: record.name,
+ }),
+ };
+
+ // 筛选下拉列表
+ const teacherList = searchValue ? teachers.filter(e=>e.user_name.indexOf(searchValue)>-1) : teachers;
+ const course_groupsList = searchValue ? course_groups.filter(e=>e.name.indexOf(searchValue)>-1) : course_groups;
+ return(
+
+
+
{questionslist.course_name} > @@ -436,7 +468,7 @@ class GraduationTaskDetail extends Component{ {/*项目在线质量检测*/} { this.props.isAdmin() ? questionslist.status===1 ? { this.end()} }>立即截止 : "" : "" } { this.props.isAdmin() ? questionslist.status===0 ? { this.publish()} }>立即发布 : "" : "" } - { this.props.isAdmin() ? 交叉评阅设置 : "" } + { this.props.isAdmin() && questionslist.cross_comment ? 交叉评阅设置 : "" } { this.props.isAdmin() ? 编辑任务 : "" }
+ { this.state.errorMsg && + {this.state.errorMsg} + } + + 保存 + { this.props.setEditableMode(false) } }>取消 +
+ + ); + } +} +const WrappedEditableCourseSupportSetting = Form.create({ name: 'dynamic_form_item' })(EditableCourseSupportSetting); +export default WrappedEditableCourseSupportSetting; diff --git a/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/ShowTableCourseSupportSetting.js b/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/ShowTableCourseSupportSetting.js new file mode 100644 index 000000000..92ab8e157 --- /dev/null +++ b/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/ShowTableCourseSupportSetting.js @@ -0,0 +1,150 @@ +import React, { Component } from 'react'; + +import moment from 'moment' + +import EditableCourseSupportSetting from './EditableCourseSupportSetting' +import { Form, Input, Icon, Button, Select } from 'antd'; + +const { Option } = Select; + + +const data = [ + { + id: 0, + ecPosition: 1, + target_weight: 0.1, + target_contents: '理解数据管理技术和数据库技术的发展,区分不同数据模型的作用和特点,描述数据库系统的类型、结构、数据独立性。', + standard_grade: 60, + subitem_contents: ':能够运用相关的工程基础和专业知识辨别材料生产中出现的技术、工艺、质量等问题' + }, + { + id: 1, + ecPosition: 2, + target_weight: 0.1, + target_contents: '理解数据管理技术和数据库技术的发展,区分不同数据模型的作用和特点,描述数据库系统的类型、结构、数据独立性。', + standard_grade: 60, + subitem_contents: ':能够运用相关的工程基础和专业知识辨别材料生产中出现的技术、工艺、质量等问题' + } +] +class ShowTableCourseSupportSetting extends Component { + componentDidMount = () => { + const course_targets = this.props.course_targets; + } + + render() { + const course_targets = this.props.course_targets; + const is_manager = this.props.is_manager; + return ( ++ 项 + 权重 + 课程目标内容 + 达成标准(分) + 对应毕业要求指标点 + + {/* + + */} + + { is_manager && { this.props.setEditableMode(true)} } + class="color-green EditCourse" data-id="5" data-tip-down="编辑"> + + } + +
++ + 课程体系 + > + {schooldata && ( schooldata.ec_course_name || '')} + + 导出课程目标 +
*/} + ++ 课程体系 > + {schooldata.ec_course_name} + + + 导出课程目标 + +
+ + +diff --git a/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/index.js b/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/index.js index 8183fb04a..65a4e5553 100644 --- a/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/index.js +++ b/public/react/src/modules/ecs/subroute/ecCourseSupportSetting/index.js @@ -7,26 +7,25 @@ import ShowTableCourseSupportSetting from './ShowTableCourseSupportSetting' import { Form, Input, Icon, Button, Select } from 'antd'; -import EcTitleCourseEvaluations from '../ecTitle/ecTitle' +// import EcTitleCourseEvaluations from '../ecTitle/ecTitle' -import { TPMIndexHOC } from '../../tpm/TPMIndexHOC'; import { SnackbarHOC, getUrl } from 'educoder' import axios from 'axios' import 'antd/dist/antd.css'; -import '../css/ecCourseEvaluations.css' -import './style.css' -import { ECModalHOC } from '../common/ECModalHOC' +// import '../css/ecCourseEvaluations.css' +import './style.scss' +import { ECModalHOC } from '../../common/ECModalHOC' const { Option } = Select; // TODO 公共方法 或 抽取到顶层组件 let _url_origin = getUrl() const $ = window.$ // https://www.educoder.net/stylesheets/educoder/edu-all.css?1546618720 -if (!window['EcCourseSupportSettingLoaded']) { - $('head').append( $('') - .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1525440977`) ); - window['EcCourseSupportSettingLoaded'] = true -} +// if (!window['EcCourseSupportSettingLoaded']) { +// $('head').append( $('') +// .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1525440977`) ); +// window['EcCourseSupportSettingLoaded'] = true +// } @@ -83,128 +82,55 @@ class EcCourseSupportSetting extends Component { } fetchCourseTargets = () => { const ec_course_id = this.props.match.params.ec_course_id; + const course_id = 706 + const url = `/ec_courses/${course_id}/course_targets.json` + // `/ec_courses/${ec_course_id}/ec_course_support_setting_data` - const url = `/ec_courses/${ec_course_id}/ec_course_support_setting_data` - axios.get(url, { - - }) - .then((response) => { - if (response.data && response.data.ec_year_id) { - if (response.data.course_targets.length === 0) { - response.data.course_targets = [ - {"target_contents":"","target_weight":'',"position": 1,"standard_grade":75,"subitem_id":"","index":"","subitem_contents":""}, - {"target_contents":"","target_weight":'',"position": 2,"standard_grade":75,"subitem_id":"","index":"","subitem_contents":""}, - {"target_contents":"","target_weight":'',"position": 3,"standard_grade":75,"subitem_id":"","index":"","subitem_contents":""}, - ] - this.setEditableMode(true) - - } - this.setState({ ...response.data }) + axios.get(url, { + + }) + .then((response) => { + if (response.data && response.data.course_targets) { + if (response.data.course_targets.length === 0) { + response.data.course_targets = [ + {"target_contents":"","target_weight":'',"position": 1,"standard_grade":75,"subitem_id":"","index":"","subitem_contents":""}, + {"target_contents":"","target_weight":'',"position": 2,"standard_grade":75,"subitem_id":"","index":"","subitem_contents":""}, + {"target_contents":"","target_weight":'',"position": 3,"standard_grade":75,"subitem_id":"","index":"","subitem_contents":""}, + ] + this.setEditableMode(true) } else { - this.props.showModal('提示', '接口异常或无数据') - // 服务端返回的数据有误 + response.data.course_targets = response.data.course_targets.map((item, index) => { + const graduation_subitem = item.graduation_subitem + return { + index: `${graduation_subitem.position}-${graduation_subitem.graduation_requirement_position}`, + position: index + 1, + standard_grade: item.standard_grade, + subitem_contents: graduation_subitem.content, + subitem_id: graduation_subitem.id, + target_contents: item.content, + target_id: item.id, + target_weight: item.weight + } + }) } + this.setState({ ...response.data }) + } else { + this.props.showModal('提示', '接口异常或无数据') + // 服务端返回的数据有误 + } - }) - .catch(function (error) { - console.log(error); - }); + }) + .catch(function (error) { + console.log(error); + }); + - const fake_data = { - "ec_year_id": 1, - "ec_course_id": 1, - "course_targets": [ - { - target_id: 0, - position: 1, - target_weight: 0.1, - target_contents: '理解数据管理技术和数据库技术的发展,区分不同数据模型的作用和特点,描述数据库系统的类型、结构、数据独立性。', - standard_grade: 60, - // biyeYaoqiuZhibiaodian: ':能够运用相关的工程基础和专业知识辨别材料生产中出现的技术、工艺、质量等问题', - "subitem_id": 52, - "index": "1-1", - "subitem_contents": "能够运用相关的工程基础和专业知识辨别材料生产中出现的技术、工艺、质量等问题" - }, - { - target_id: 1, - position: 2, - target_weight: 0.2, - target_contents: '理解数据管理技术和数据库技术的发展,区分不同数据模型的作用和特点,描述数据库系统的类型、结构、数据独立性。', - standard_grade: 61, - // biyeYaoqiuZhibiaodian: ':能够运用相关的工程基础和专业知识辨别材料生产中出现的技术、工艺、质量等问题', - "subitem_id": 53, - "index": "1-2", - "subitem_contents": "222能够运用相关的工程基础和专业知识辨别材料生产中出现的技术、工艺、质量等问题" - } - ], - "requirements": [ - { - "subitem_id": 52, - "subitem_contents": "1-子项1", - "index": "1-1" - }, - { - "subitem_id": 53, - "subitem_contents": "1-子项2", - "index": "1-2" - }, - { - "subitem_id": 54, - "subitem_contents": "2-子项1", - "index": "2-1" - }, - { - "subitem_id": 55, - "subitem_contents": "2-子项2", - "index": "2-2" - }, - { - "subitem_id": 56, - "subitem_contents": "2-子项3", - "index": "2-3" - }, - { - "subitem_id": 57, - "subitem_contents": "3-1子项", - "index": "3-1" - }, - { - "subitem_id": 58, - "subitem_contents": "4-子项1", - "index": "4-1" - }, - { - "subitem_id": 59, - "subitem_contents": "4-子项2", - "index": "4-2" - }, - { - "subitem_id": 60, - "subitem_contents": "4-子项3", - "index": "4-3" - }, - { - "subitem_id": 61, - "subitem_contents": "4-子项4", - "index": "4-4" - }, - { - "subitem_id": 62, - "subitem_contents": "5-子项1", - "index": "5-1" - }, - { - "subitem_id": 63, - "subitem_contents": "5-子项2", - "index": "5-2" - } - ] - } // test data // this.setState({ ...fake_data }) } getNavigationData=(ec_course_id)=>{ + return; // const jol =`/ec_major_schools/get_navigation_data?ec_year_id=`+ec_year_id+"&ec_course_id="+ec_course_id; const jol =`/ec_major_schools/get_navigation_data?ec_course_id=`+ec_course_id; axios.get(jol, { @@ -226,6 +152,7 @@ class EcCourseSupportSetting extends Component { }); } componentDidMount = () => { + console.log('componentDidMount ' + this.props) this.fetchCourseTargets(); const ec_course_id = this.props.match.params.ec_course_id; @@ -242,14 +169,18 @@ class EcCourseSupportSetting extends Component { const course_targets = this.state.course_targets; return ( -
@@ -262,7 +193,7 @@ class EcCourseSupportSetting extends Component { >导出课程目标
*/} -课程体系 > @@ -293,7 +224,7 @@ class EcCourseSupportSetting extends Component { href={schooldata.competition_calculation_info_url}>5.课程达成评价结果
学生数据为空,请导入数据
-
-
-
学生数据为空,请导入数据
-学生数据为空,请导入数据
-
+
+
学生数据为空,请导入数据
+学生数据为空,请导入数据
+学生数据为空,请导入数据
@@ -465,7 +465,7 @@ class EcStudentList extends Component {
- {/*{datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"}*/} - 实训作业 + {datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"}