Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_cs
SylorHuang 5 years ago
commit 690d346ed6

@ -378,6 +378,7 @@ DEPENDENCIES
kaminari (~> 1.1, >= 1.1.1)
listen (>= 3.0.5, < 3.2)
mysql2 (>= 0.4.4, < 0.6.0)
newrelic_rpm
oauth2
pdfkit
puma (~> 3.11)

@ -0,0 +1,4 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-schools-index-page').length > 0) {
}
});

@ -0,0 +1,3 @@
.admins-schools-index-page {
}

@ -0,0 +1,30 @@
class Admins::SchoolsController < Admins::BaseController
def index
params[:sort_by] ||= 'created_at'
params[:sort_direction] ||= 'desc'
schools = Admins::SchoolQuery.call(params)
@schools = paginate schools
school_ids = @schools.map(&:id)
@department_count = Department.where(school_id: school_ids).group(:school_id).count
end
def destroy
users = User.joins(:user_extension).where(user_extensions: { school_id: current_school.id })
ActiveRecord::Base.transaction do
users.update_all(profile_completed: false)
current_school.destroy!
end
render_delete_success
end
private
def current_school
@_current_school ||= School.find(params[:id])
end
end

@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
#before_action :check_account
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
OPENKEY = "79e33abd4b6588941ab7622aed1e67e8"
helper_method :current_user
@ -246,6 +247,17 @@ class ApplicationController < ActionController::Base
User.current = find_current_user
uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))
# 开放课程通过链接访问的用户
if !User.current.logged? && !params[:chinaoocTimestamp].blank? && !params[:websiteName].blank? && !params[:chinaoocKey].blank?
content = "#{OPENKEY}#{params[:websiteName]}#{params[:chinaoocTimestamp]}"
if Digest::MD5.hexdigest(content) == params[:chinaoocKey]
user = open_class_user
start_user_session(user) if user
User.current = user
end
end
if !User.current.logged? && Rails.env.development?
User.current = User.find 1
end
@ -604,4 +616,27 @@ class ApplicationController < ActionController::Base
def set_export_cookies
cookies[:fileDownload] = true
end
# 149课程的评审用户数据创建包含创建课堂学生
def open_class_user
user = User.find_by(login: "OpenClassUser")
unless user
ActiveRecord::Base.transaction do
user_params = {status: 1, login: "OpenClassUser", lastname: "开放课程",
nickname: "开放课程", professional_certification: 1, certification: 1, grade: 0,
password: "12345678", phone: "11122223333", profile_completed: 1}
user = User.create!(user_params)
UserExtension.create!(user_id: user.id, gender: 0, school_id: 3396, :identity => 1, :student_id => "openclassuser") # 3396
subject = Subject.find_by(id: 149)
if subject
subject.courses.each do |course|
CourseMember.create!(course_id: course.id, role: 3, user_id: user.id) if !course.course_members.exists?(user_id: user.id)
end
end
end
end
user
end
end

@ -40,8 +40,8 @@ class CollegesController < ApplicationController
def teachers
@teachers = User.find_by_sql("SELECT users.id, users.login, users.lastname, users.firstname, users.nickname, IFNULL((SELECT count(shixuns.id) FROM shixuns where shixuns.user_id =users.id group by shixuns.user_id), 0) AS publish_shixun_count,
(SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) and c.school_id = #{current_school.id} AND m.user_id=users.id AND c.is_delete = 0) as course_count
FROM `users`, user_extensions ue where users.id=ue.user_id and ue.identity=0 and ue.school_id=#{current_school.id} ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
(SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.user_id=users.id AND m.role in (1,2,3) and c.school_id = #{current_school.id} AND c.is_delete = 0) as course_count
FROM `users`, user_extensions ue where ue.school_id=#{current_school.id} and users.id=ue.user_id and ue.identity=0 ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
# ).order("publish_shixun_count desc, experience desc").limit(10)
@teachers =
@teachers.map do |teacher|

@ -23,7 +23,7 @@ module GitHelper
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
# 字符编码问题GB18030编码识别率不行
decode_content =
if cd["encoding"] == 'GB18030' && cd['confidence'] == 1.0
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
else
content.force_encoding('UTF-8')

@ -3,6 +3,10 @@ module PaginateHelper
page = params[:page].to_i <= 0 ? 1 : params[:page].to_i
per_page = params[:per_page].to_i > 0 && params[:per_page].to_i < 50 ? params[:per_page].to_i : opts[:per_page] || 20
Kaminari.paginate_array(objs).page(page).per(per_page)
if objs.is_a?(Array)
Kaminari.paginate_array(objs).page(page).per(per_page)
else
objs.page(page).per(per_page)
end
end
end

@ -47,6 +47,10 @@ class Ecs::BaseController < ApplicationController
page = params[:page].to_i <= 0 ? 1 : params[:page].to_i
per_page = params[:per_page].to_i > 0 ? params[:per_page].to_i : 20
Kaminari.paginate_array(objs).page(page).per(per_page)
if objs.is_a?(Array)
Kaminari.paginate_array(objs).page(page).per(per_page)
else
objs.page(page).per(per_page)
end
end
end

@ -15,19 +15,31 @@ class Ecs::EcGraduationRequirementsController < Ecs::BaseController
end
def create
graduation_requirement = current_year.graduation_requirements.new
graduation_requirement = current_year.ec_graduation_requirements.new
@graduation_requirement = Ecs::SaveGraduationRequirementeService.call(graduation_requirement, create_params)
render 'show'
end
def update
graduation_requirement = current_year.graduation_requirements.find(params[:id])
@graduation_requirement = Ecs::SaveGraduationRequirementeService.call(graduation_requirement, update_params)
@graduation_requirement = Ecs::SaveGraduationRequirementeService.call(current_graduation_requirement, update_params)
render 'show'
end
def destroy
ActiveRecord::Base.transaction do
current_graduation_requirement.destroy!
current_year.ec_graduation_requirements.where('position > ?', current_graduation_requirement.position)
.update_all('position = position - 1')
end
render_ok
end
private
def current_graduation_requirement
@_current_graduation_requirement ||= current_year.ec_graduation_requirements.find(params[:id])
end
def create_params
params.permit(:position, :content, graduation_subitems: [:content])
end

@ -1,4 +1,6 @@
class Ecs::EcMajorSchoolsController < Ecs::BaseController
skip_before_action :check_user_permission!, only: [:show]
def index
major_schools = current_school.ec_major_schools.not_template
@ -20,7 +22,18 @@ class Ecs::EcMajorSchoolsController < Ecs::BaseController
@count = major_schools.count #检索后的数量,小于或等于全部数量
@major_schools = paginate(major_schools.includes(:users, :ec_major))
@template_major_school = current_school.ec_major_schools.is_template.first #示例专业
@template_major_school = EcMajorSchool.is_template.first #示例专业
end
# :show是 /api/ec_major_schools/:id
def show
@major = EcMajorSchool.find(params[:id])
school = @major.school
return if current_user.admin? || school.manager?(current_user)
return if @major.manager?(current_user)
render_forbidden
end
def create

@ -1,7 +1,7 @@
class Ecs::EcMajorsController < Ecs::BaseController
def index
school_major_subquery = current_school.ec_major_schools.select(:ec_major_id) #学校已选择的专业
ec_majors = EcMajor.where.not(id: school_major_subquery)
@major_ids = current_school.ec_major_schools.pluck(:ec_major_id) #学校已选择的专业
ec_majors = EcMajor.all
if params[:search].present?
ec_majors = ec_majors.search_name_or_code(params[:search])

@ -2,7 +2,7 @@ class Ecs::EcTrainingObjectivesController < Ecs::BaseController
before_action :check_major_manager_permission!, only: [:create]
def show
@training_objective = current_year.ec_training_objective
@training_objective = current_year.ec_training_objective || current_year.build_ec_training_objective
respond_to do |format|
format.json

@ -10,7 +10,7 @@ class Ecs::EcYearsController < Ecs::BaseController
end
@count = ec_years.count
@ec_years = paginate ec_years
@ec_years = paginate ec_years.order(year: :desc)
return if @ec_years.blank?
@ -27,13 +27,17 @@ class Ecs::EcYearsController < Ecs::BaseController
.where(ec_graduation_requirements: { ec_year_id: year_ids }).group('ec_year_id').count
end
def show
@year = current_year
end
def create
if current_major_school.ec_years.exists?(year: params[:year].to_i)
render_error('届别已存在')
return
end
@ec_year = CopyEcYearService.call(current_major_school, params[:year].to_i)
@ec_year = Ecs::CopyEcYearService.call(current_major_school, params[:year].to_i)
end
def destroy

@ -3,6 +3,7 @@ class Ecs::GraduationCourseSupportsController < Ecs::BaseController
def show
@graduation_subitems = current_year.ec_graduation_subitems
.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC')
.includes(:ec_graduation_requirement, ec_course_supports: :ec_course)
@course_count = current_year.ec_courses.count

@ -0,0 +1,6 @@
class Ecs::GraduationSubitemsController < Ecs::BaseController
def index
subitems = current_year.ec_graduation_subitems.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC')
@graduation_subitems = subitems.includes(:ec_graduation_requirement)
end
end

@ -3,7 +3,8 @@ class Ecs::MajorManagersController < Ecs::BaseController
before_action :check_manager_permission!
def create
@user = Ecs::CreateMajorManagerService.call(current_major_school, params[:user_id])
Ecs::CreateMajorManagerService.call(current_major_school, params[:user_ids])
render_ok
rescue Ecs::CreateMajorManagerService::Error => ex
render_error(ex.message)
end

@ -14,5 +14,13 @@ class Ecs::ReachEvaluationsController < Ecs::BaseController
end
def create
relations = current_year.ec_graduation_requirements.joins(ec_graduation_subitems: :ec_course_support)
ec_course_ids = relations.pluck('ec_course_supports.ec_course_id').uniq
EcCourse.where(id: ec_course_ids).each do |ec_course|
Ecs::CalculateCourseEvaluationService.call(ec_course)
end
render_ok
end
end

@ -14,7 +14,7 @@ class Ecs::StudentsController < Ecs::BaseController
end
def import
success_count = Ecs::ImportStudentService.call(current_year, params[:attachment_id])
success_count = Ecs::ImportStudentService.call(current_year, params)
render_ok(success_count: success_count)
rescue Ecs::ImportStudentService::Error => ex
render_error(ex.message)

@ -0,0 +1,22 @@
class Ecs::UsersController < Ecs::BaseController
skip_before_action :check_user_permission!
before_action :check_manager_permission!
def index
users = UserQuery.call(params)
@count = users.count
@users = paginate users.includes(user_extension: [:school, :department])
@manager_ids = current_major_school.ec_major_school_users.pluck(:user_id)
end
private
def current_major_school
@_ec_major_school ||= EcMajorSchool.find(params[:ec_major_school_id])
end
def current_school
@_current_school ||= current_major_school.school
end
end

@ -324,7 +324,7 @@ class GraduationTasksController < ApplicationController
tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间必须晚于当前时间") if params[:end_time] <= strf_time(Time.now)
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > @course.end_date.end_of_day
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
# ActiveRecord::Base.transaction do
begin
@ -401,7 +401,7 @@ class GraduationTasksController < ApplicationController
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S")
tip_exception("截止时间不能早于发布时间") if params[:publish_time] > params[:end_time]
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > @course.end_date.end_of_day
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
@task.publish_time = params[:publish_time]
@task.end_time = params[:end_time]
@ -414,7 +414,7 @@ class GraduationTasksController < ApplicationController
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S")
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > @course.end_date.end_of_day
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
@task.end_time = params[:end_time]
end
@ -426,7 +426,7 @@ class GraduationTasksController < ApplicationController
tip_exception("补交结束时间不能为空") if params[:late_time].blank?
tip_exception("补交结束时间不能早于截止时间") if params[:late_time] <= @task.end_time
tip_exception("补交结束时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:late_time] > @course.end_date.end_of_day
@course.end_date.present? && params[:late_time] > strf_time(@course.end_date.end_of_day)
tip_exception("迟交扣分应为正整数") if params[:late_penalty] && params[:late_penalty].to_i < 0
@task.allow_late = true

@ -271,7 +271,11 @@ class MyshixunsController < ApplicationController
unless @hide_code || @myshixun.shixun&.vnc_evaluate
# 远程版本库文件内容
last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"]
content = params[:content]
content = if @myshixun.mirror_name.select {|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present?
params[:content].gsub(/\t/, ' ').gsub(/ /, ' ') # 这个不是空格在windows机器上带来的问题
else
params[:content]
end
Rails.logger.info("###11222333####{content}")
Rails.logger.info("###222333####{last_content}")

@ -264,8 +264,9 @@ class QuestionBanksController < ApplicationController
# new_exercise.create_exercise_list
# exercise.update_column(:quotes, exercise.quotes+1)
# end
new_exercise if new_exercise.save!
new_exercise.save!
exercise.update_column(:quotes, exercise.quotes+1)
new_exercise
end
end
@ -292,8 +293,9 @@ class QuestionBanksController < ApplicationController
# new_poll.create_polls_list
# poll.update_column(:quotes, poll.quotes+1)
# end
new_poll if new_poll.save!
new_poll.save!
poll.update_column(:quotes, poll.quotes+1)
new_poll
end
end

@ -321,11 +321,12 @@ class StudentWorksController < ApplicationController
ActiveRecord::Base.transaction do
begin
revise_attachment = @work.attachments.where(attachtype: 7).reorder("created_on desc").last
if revise_attachment.present? && @work.student_works_scores.where("created_at > '#{revise_attachment.created_on}'
and score is not null").count == 0
revise_attachment.destroy
end
# 补交作业附件不覆盖之前上传的附件
# revise_attachment = @work.attachments.where(attachtype: 7).reorder("created_on desc").last
# if revise_attachment.present? && @work.student_works_scores.where("created_at > '#{revise_attachment.created_on}'
# and score is not null").count == 0
# revise_attachment.destroy
# end
Attachment.associate_container(params[:attachment_ids], @work.id, @work.class, 7)
revise_attachment = Attachment.where(attachtype: 7, container_id: @work.id, container_type: "StudentWork").last
revise_attachment.update_attributes(description: params[:description]) if revise_attachment.present?

@ -368,7 +368,7 @@ class SubjectsController < ApplicationController
@schools.map do |s|
school_courses = Course.where(id: course_ids, school_id: s.id)
course_count = school_courses.count
student_count = StudentsForCourse.where(course_id: school_courses.pluck(:id)).count
student_count = CourseMember.where(course_id: school_courses.pluck(:id), role: 4).count
homework_count = HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id
where c.school_id = #{s.id} and hc.id in(#{homework_common_id})").first.try(:cnt)
s.attributes.dup.merge({name: s.name, course_count: course_count, student_count: student_count,homework_count: homework_count})

@ -55,7 +55,13 @@ class Users::BaseController < ApplicationController
page = page_value
per_page = per_page_value
return Kaminari.paginate_array(objs).page(page).per(per_page) unless opts[:special] && observed_logged_user?
unless opts[:special] && observed_logged_user?
if objs.is_a?(Array)
return Kaminari.paginate_array(objs).page(page).per(per_page)
else
return objs.page(page).per(per_page)
end
end
# note: 为实现第一页少一条记录,让前端放置新建入口
if page == 1

@ -81,7 +81,7 @@ module TidingDecorator
end
def student_join_course_content
I18n.t(locale_format) % Course.find_by(id: container_id)&.name
I18n.t(locale_format) % [trigger_user.show_real_name, Course.find_by(id: container_id)&.name]
end
def teacher_join_course_content

@ -0,0 +1,22 @@
module Ecs::EcYearsHelper
def achieved_graduation_course_count(ec_year)
return 0 if ec_year.ec_courses.count.zero?
course_ids = ec_year.ec_courses.map(&:id)
target_count_map = EcCourseTarget.where(ec_course_id: course_ids).group(:ec_course_id).count
ec_year.ec_courses.sum { |course| course.complete_target_count == target_count_map[course.id] ? 1 : 0 }
end
def achieved_graduation_objective_count(ec_year)
return 0 if ec_year.ec_graduation_subitems.count.zero?
subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id)
relations = EcGraduationRequirementCalculation.joins(:ec_course_support).where(ec_course_supports: { ec_graduation_subitem_id: subitem_ids })
reached_map = relations.where(status: true).group('ec_graduation_subitem_id').count
reached_map.keys.size
end
end

@ -8,7 +8,7 @@ class ApplyTeacherRoleJoinCourseNotifyJob < ApplicationJob
return if user.blank? || course.blank?
attrs = %i[user_id trigger_user_id container_id container_type belong_container_id
belong_container_type tiding_type extra created_at updated_at]
belong_container_type tiding_type status extra created_at updated_at]
same_attrs = {
trigger_user_id: user.id, container_id: course.id, container_type: 'JoinCourse', status: 0,

@ -45,6 +45,8 @@ module Util
def conceal(str, type = nil)
str = str.to_s
return if str.blank?
case type
when :phone then "#{str[0..2]}***#{str[-4..-1]}"
when :email then "#{str[0..2]}***#{str[str.rindex('@')..-1]}"

@ -18,10 +18,18 @@ module Util::FileManage
File.exist?(disk_filename(source_type, source_id))
end
def exists?(source)
File.exist?(disk_filename(source.class, source.id))
end
def disk_file_url(source_type, source_id)
File.join('/images', relative_path, "#{source_type}", "#{source_id}")
end
def source_disk_file_url(source)
File.join('/images', relative_path, "#{source.class}", "#{source.id}")
end
def disk_auth_filename(source_type, source_id, type)
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
end

@ -32,6 +32,6 @@ class CourseMessage < ApplicationRecord
belong_container: course, extra: content.to_i == 2 ? '9' : '7', tiding_type: 'System', status: deal_status
)
# 将申请消息置为已处理
Tiding.where(trigger_user_id: user_id, container_id: course_id, container_type: 'JoinCourse', status: 0).update_all(status: 1)
Tiding.where(trigger_user_id: course_message_id, container_id: course_id, container_type: 'JoinCourse', status: 0).update_all(status: 1)
end
end

@ -5,7 +5,7 @@ class Department < ApplicationRecord
has_many :member_users, through: :department_members, source: :user
has_many :user_extensions, dependent: :nullify
has_many :apply_add_departments
has_many :apply_add_departments, dependent: :destroy
scope :without_deleted, -> { where(is_delete: false) }

@ -1,7 +1,6 @@
class EcCourseStudentScore < ApplicationRecord
belongs_to :ec_year_student
belongs_to :ec_course
belongs_to :ec_course_target
has_many :ec_student_score_targets, dependent: :delete_all
end

@ -1,9 +1,10 @@
class EcCourseSupport < ApplicationRecord
default_scope { order(position: :asc) }
alias_attribute :weights, :weigths
belongs_to :ec_course
belongs_to :ec_graduation_subitem
# TODO: 将 ec_graduation_subitem_courses 移除,这个表作为关系表
has_one :ec_graduation_requirement_calculation, dependent: :destroy

@ -1,4 +1,3 @@
# TODO:: change table column :weigths => :weight
class EcCourseTarget < ApplicationRecord
belongs_to :ec_course
@ -8,6 +7,8 @@ class EcCourseTarget < ApplicationRecord
has_many :ec_course_achievement_methods, dependent: :destroy
has_many :ec_achievement_evaluation_relates, dependent: :destroy
alias_attribute :weight, :weigths
validates :content, presence: true
validates :standard_grade, numericality: { only_integer: true, greater_than: 0 }
validates :weight, presence: true, numericality: { less_than_or_equal_to: 1, greater_than_or_equal_to: 0 }

@ -1,4 +1,6 @@
class EcGraduationRequirement < ApplicationRecord
default_scope { order(position: :asc) }
belongs_to :ec_year
has_many :ec_graduation_subitems, dependent: :destroy
@ -7,5 +9,5 @@ class EcGraduationRequirement < ApplicationRecord
validates :position, presence: true, numericality: { only_integer: true, greater_than: 0 }
validates :content, presence: true
default_scope { order(position: :asc) }
accepts_nested_attributes_for :ec_graduation_subitems, allow_destroy: true
end

@ -12,6 +12,8 @@ class EcMajorSchool < ApplicationRecord
scope :is_template, -> { where(template_major: true) }
scope :not_template, -> { where(template_major: false) }
delegate :code, :name, to: :ec_major
# 是否为该专业管理员
def manager?(user)
ec_major_school_users.exists?(user_id: user.id)

@ -1,4 +1,6 @@
class EcTrainingSubitem < ApplicationRecord
default_scope { order(position: :asc) }
belongs_to :ec_training_objective
has_many :ec_requirement_vs_objectives, foreign_key: :ec_training_objective_id, dependent: :destroy

@ -9,4 +9,11 @@ class EcYear < ApplicationRecord
has_many :ec_graduation_requirements, dependent: :destroy
has_many :ec_graduation_subitems, through: :ec_graduation_requirements
has_many :ec_year_students, dependent: :destroy
has_many :ec_course_users, dependent: :destroy
has_many :managers, through: :ec_course_users, source: :user
def prev_year
self.class.find_by(year: year.to_i - 1)
end
end

@ -48,7 +48,7 @@ class GraduationWork < ApplicationRecord
def delete_atta atta
last_score = graduation_work_scores.where.not(score: nil).last
atta.author_id == user_id && (!last_score.present? || last_score.try(:created_at) < atta.created_on)
(atta.author_id == self.user_id) && (last_score.blank? || last_score.try(:created_at) < atta.created_on)
end
# 分班名

@ -17,6 +17,7 @@ class School < ApplicationRecord
has_many :partners, dependent: :destroy
has_many :apply_add_departments, dependent: :destroy
has_many :user_extensions, dependent: :nullify
# 学校管理员
def manager?(user)

@ -21,7 +21,7 @@ class StudentGraduationTopic < ApplicationRecord
def send_tiding
self.tidings << Tiding.new(:user_id => self.graduation_topic.tea_id, :trigger_user_id => self.user_id, :parent_container_id => self.graduation_topic_id, :parent_container_type => "GraduationTopic",
:belong_container_id => self.graduation_topic.course_id, :belong_container_type => "Course", :viewed => 0, :status => 0, :tiding_type => "GraduationTopic")
:belong_container_id => self.graduation_topic.course_id, :belong_container_type => "Course", :viewed => 0, :status => 0, :tiding_type => "Apply")
end
# 学生名称

@ -106,7 +106,7 @@ class StudentWork < ApplicationRecord
def delete_atta atta
last_score = student_works_scores.where.not(score: nil).last
atta.author_id == user_id && (!last_score.present? || last_score.try(:created_at) < atta.created_on)
((atta.author_id == self.user_id) && (last_score.blank? || last_score.try(:created_at) < atta.created_on))
end
# 作品总体评价

@ -46,8 +46,7 @@ class Subject < ApplicationRecord
# 挑战过路径的成员数(金课统计去重后的报名人数)
def member_count
excellent && CourseMember.where(role: 4, course_id: courses.pluck(:id)).pluck(:user_id).length > shixuns.pluck(:myshixuns_count).sum ?
CourseMember.where(role: 4, course_id: courses.pluck(:id)).pluck(:user_id).length : shixuns.pluck(:myshixuns_count).sum
excellent ? CourseMember.where(role: 4, course_id: courses.pluck(:id)).pluck(:user_id).length : shixuns.pluck(:myshixuns_count).sum
end
def all_score

@ -22,4 +22,9 @@ class Tiding < ApplicationRecord
value
end
def anonymous?
(container_type == 'StudentWorksScore' && extra.to_i == 3) ||
(container_type == 'StudentWorksScoresAppeal' && parent_container_type == 'StudentWork' && tiding_type == 'System')
end
end

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
class UserExtension < ApplicationRecord
# identity 0: 教师教授 1: 学生, 2: 专业人士, 3: 开发者
enum identity: { teacher: 0, student: 1, professional: 2, developer: 3, cnmooc: 4, unselect: -1 }
enum identity: { teacher: 0, student: 1, professional: 2, developer: 3, enterprise: 4, unselect: -1 }
belongs_to :user, touch: true
belongs_to :school, optional: true

@ -0,0 +1,23 @@
class Admins::SchoolQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :users_count, :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
schools = School.all
keyword = strip_param(:keyword)
schools = schools.where('schools.name LIKE ?', "%#{keyword}%") if keyword
schools = schools.joins(:user_extensions).group(:id)
schools = schools.select('schools.*, COUNT(*) AS users_count')
custom_sort schools, params[:sort_by], params[:sort_direction]
end
end

@ -1,3 +1,9 @@
class ApplicationQuery
include Callable
private
def strip_param(key)
params[key].to_s.strip.presence
end
end

@ -0,0 +1,28 @@
class UserQuery < ApplicationQuery
attr_reader :params
def initialize(params)
@params = params
end
def call
users = User.where(type: 'User')
# 真实姓名
if name = strip_param(:name)
users = users.where('LOWER(CONCAT(users.lastname, users.firstname)) LIKE ?', "%#{name.downcase}%")
end
# 单位名称
if school = strip_param(:school)
users = users.joins(user_extension: :school).where('schools.name LIKE ?', "%#{school}%")
end
# 职业
if (identity = strip_param(:identity)) && UserExtension.identities.keys.include?(identity)
users = users.joins(:user_extension).where(user_extensions: { identity: identity })
end
users
end
end

@ -1,4 +1,4 @@
class CopyEcYearService < ApplicationService
class Ecs::CopyEcYearService < ApplicationService
attr_reader :major_school, :to_year
def initialize(major_school, year)

@ -27,7 +27,7 @@ class Ecs::CreateCourseService < ApplicationService
private
def create_default_score_levels!(ec_course)
EcScoreLevel.bulk_insert(:ec_course_id, :score, :level, :position) do |worker|
EcScoreLevel.bulk_insert(:ec_course_id, :score, :level, :position, :created_at, :updated_at) do |worker|
[
{ ec_course_id: ec_course.id, score: 90, level: '优秀', position: 1 },
{ ec_course_id: ec_course.id, score: 80, level: '良好', position: 2 },

@ -3,29 +3,30 @@ class Ecs::CreateMajorManagerService < ApplicationService
MAJOR_MANAGER_COUNT_LIMIT = 5 # 专业管理员数量限制
attr_reader :major_school, :user_id
attr_reader :major_school, :user_ids
def initialize(major_school, user_id)
def initialize(major_school, user_ids)
@major_school = major_school
@user_id = user_id
@user_ids = user_ids
end
def call
raise Error, '示例专业不能添加管理员' if major_school.template_major?
user = User.find_by(id: params[:user_id])
raise Error, '该用户不存在' if user.blank?
@user_ids = User.where(id: user_ids).pluck(:id)
if major_school.ec_major_school_users.exists?(user_id: user.id)
raise Error, '该用户已经是该专业的管理员了'
if major_school.ec_major_school_users.exists?(user_id: user_ids)
raise Error, '所选用户中存在该专业的管理员'
end
if major_school.ec_major_school_users.count >= MAJOR_MANAGER_COUNT_LIMIT
raise Error, '该专业管理员数量已达上限'
if major_school.ec_major_school_users.count + user_ids.count > MAJOR_MANAGER_COUNT_LIMIT
raise Error, "该专业管理员数量超过上限(#{MAJOR_MANAGER_COUNT_LIMIT}人)"
end
major_school.ec_major_school_users.create!(user: user)
user
ActiveRecord::Base.transaction do
user_ids.each do |user_id|
major_school.ec_major_school_users.create!(user_id: user_id)
end
end
end
end

@ -11,13 +11,16 @@ class Ecs::CreateTrainingObjectiveService < ApplicationService
def call
training_objective.content = params[:content].to_s.strip
attributes = build_accepts_nested_attributes(
training_objective,
training_objective.ec_training_subitems,
params[:training_subitems],
&method(:training_subitem_param_handler)
)
training_objective.assign_attributes(ec_training_subitems_attributes: attributes)
if params.key?(:training_subitems)
attributes = build_accepts_nested_attributes(
training_objective,
training_objective.ec_training_subitems,
params[:training_subitems],
&method(:training_subitem_param_handler)
)
attributes.each_with_index { |attr, index| attr[:position] = index + 1 }
training_objective.assign_attributes(ec_training_subitems_attributes: attributes)
end
training_objective.save!
training_objective

@ -1,18 +1,17 @@
class Ecs::ImportStudentService < ApplicationService
Error = Class.new(StandardError)
attr_reader :ec_year, :attachment
attr_reader :ec_year, :params
def initialize(ec_year, attachment_id)
@ec_year = ec_year
@attachment = Attachment.find_by(id: attachment_id)
def initialize(ec_year, params)
@ec_year = ec_year
@params = params
end
def call
raise Error, '文件不存在' if attachment.blank?
raise Error, '文件不存在' if params[:file].blank? || !params[:file].is_a?(ActionDispatch::Http::UploadedFile)
path = attachment.diskfile
excel = Ecs::ImportStudentExcel.new(path)
excel = Ecs::ImportStudentExcel.new(params[:file].path)
success_count = 0
EcYearStudent.bulk_insert(:student_id, :name, :created_at, :updated_at) do |worker|

@ -17,12 +17,12 @@ class Ecs::QueryCourseEvaluationService < ApplicationService
end
def graduation_subitem_evaluations
student_scores = ec_course.ec_course_student_scores.joins(:ec_course_target).group(:ec_course_target_id)
student_scores = ec_course.ec_course_student_scores.joins(ec_student_score_targets: :ec_course_target).group(:ec_course_target_id)
student_scores = student_scores.select('AVG(score) as average_score, ec_course_target_id')
student_score_map = student_scores.group_by { |item| item.ec_course_target_id }
subitem_targets = ec_course.ec_graduation_subitem_course_targets
.includes(ec_graduation_subitem: :ec_graduation_requirement)
.includes(:ec_course_target, ec_graduation_subitem: :ec_graduation_requirement)
subitem_targets.group_by(&:ec_graduation_subitem_id).map do |_id, arr|
subitem = arr.first.ec_graduation_subitem
@ -37,7 +37,7 @@ class Ecs::QueryCourseEvaluationService < ApplicationService
arr.map(&:ec_course_target).uniq.each do |target|
target_total_rates += target.weight.to_f
student_score = student_score_map[target.id]
student_score = student_score_map[target.id]&.first
reach_real_target += student_score.average_score.to_f * target.weight.to_f if student_score
end
@ -60,8 +60,19 @@ class Ecs::QueryCourseEvaluationService < ApplicationService
def score_levels_map
@_score_levels_map ||= begin
index = 0
ec_course.ec_score_levels.each_with_object({}) do |level, obj|
obj[level.id.to_s] = level.as_json(only: %i[id position score level])
hash = level.as_json(only: %i[id position score level])
hash[:description] =
case index
when 0 then "#{level.score}分以上"
when ec_course.ec_score_levels.to_a.size - 1 then "低于#{level.score}"
else "#{level.score}~#{ec_course.ec_score_levels[index - 1].score - 1}"
end
index += 1
obj[level.id.to_s] = hash
end
end
end
@ -87,23 +98,29 @@ class Ecs::QueryCourseEvaluationService < ApplicationService
@_course_achievement += data[:average_score].to_f * course_target.weight.to_f
# 计算学生成绩分布区间
student_count = 0
data[:score_levels] = score_levels.map do |score_level|
level_condition_proc =
if (score_level.position - 1).zero? # 第一区间
-> (score_target){ score_target.score >= score_level.score ? 1 : 0 }
elsif score_levels.position == score_levels.size # 末尾区间
elsif score_level.position == score_levels.size # 末尾区间
-> (score_target){ score_target.score < score_level.score ? 1 : 0 }
else
# 中间区间
-> (score_target){ score_target.score >= score_level.score && score_target.score < score_targets[score_level.position - 1] ? 1 : 0 }
-> (score_target){ score_target.score >= score_level.score && score_target.score < score_levels[score_level.position - 1].score ? 1 : 0 }
end
# 计算该成绩区间人数
count = score_targets.sum(&level_condition_proc)
student_count += count
{ id: score_level.id, count: count }
end
data[:score_levels].each do |score_level|
score_level[:rate] = score_level[:count].fdiv(student_count).round(2)
end
data
end
end

@ -9,6 +9,8 @@ class Ecs::SaveGraduationCourseSupportsService < ApplicationService
end
def call
set_course_supports_position!
Ecs::SaveGraduationCourseSupportForm.new(params).validate!
accepts_attributes = build_accepts_nested_attributes(
@ -20,4 +22,10 @@ class Ecs::SaveGraduationCourseSupportsService < ApplicationService
graduation_subitem.save!
graduation_subitem
end
def set_course_supports_position!
params[:course_supports].each_with_index do |item, index|
item[:position] = index + 1
end
end
end

@ -40,8 +40,8 @@ class Users::ApplyProfessionalAuthService < ApplicationService
# sms_cache = Rails.cache.read("apply_pro_certification")
# if sms_cache.nil?
# sms_notify_admin
Rails.cache.write("apply_pro_certification", 1)
sms_notify_admin
# Rails.cache.write("apply_pro_certification", 1)
# end
end
end

@ -27,8 +27,8 @@ class StatisticSchoolDailyReportTask
# 新增实训评测数量
shixun_evaluate_count = EvaluateRecord.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = evaluate_records.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN members ON members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON members.course_id = courses.id AND hc.course_id = courses.id')
.joins('LEFT JOIN course_members ON course_members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON course_members.course_id = courses.id AND hc.course_id = courses.id')
.where(courses: { school_id: school.id })
.where(created_at: yesterday).reorder(nil).count

@ -2,10 +2,10 @@ class StatisticSchoolReportTask
def call
School.find_each do |school|
evaluate_count = Game.joins(:challenge)
.joins('LEFT JOIN members ON members.user_id = games.user_id')
.joins('LEFT JOIN course_members ON course_members.user_id = games.user_id')
.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN courses ON hc.course_id = courses.id AND members.course_id = courses.id')
.joins('LEFT JOIN courses ON hc.course_id = courses.id AND course_members.course_id = courses.id')
.where(courses: { school_id: school.id })
.sum(:evaluate_count)

@ -0,0 +1,16 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('单位列表') %>
<% end %>
<div class="box search-form-container school-list-form">
<%= form_tag(admins_schools_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '部门名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
<%#= javascript_void_link '新建单位', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-school-modal' } %>
</div>
<div class="box school-list-container">
<%= render partial: 'admins/schools/shared/list', locals: { schools: @schools } %>
</div>

@ -0,0 +1 @@
$('.school-list-container').html("<%= j(render partial: 'admins/schools/shared/list', locals: { schools: @schools }) %>");

@ -0,0 +1,48 @@
<table class="table table-hover text-center school-list-table">
<thead class="thead-light">
<tr>
<th width="6%">ID</th>
<th width="6%">LOGO</th>
<th width="8%">标识码</th>
<th width="14%" class="text-left">单位名称</th>
<th width="6%">地区</th>
<th width="6%">城市</th>
<th width="16%">详细地址</th>
<th width="6%"><%= sort_tag('用户数', name: 'users_count', path: admins_schools_path) %></th>
<th width="6%">部门数</th>
<th width="12%"><%= sort_tag('创建时间', name: 'created_at', path: admins_schools_path) %></th>
<th width="14%">操作</th>
</tr>
</thead>
<tbody>
<% if schools.present? %>
<% schools.each do |school| %>
<tr class="school-item-<%= school.id %>">
<td><%= school.id %></td>
<td>
<% if Util::FileManage.exists?(school) %>
<%= image_tag(Util::FileManage.source_disk_file_url(school).to_s + "?#{Time.now.to_i}", width: 40, height: 40, class: 'preview-image') %>
<% else %>
<%= content_tag(:span, '--', class: 'text-secondary') %>
<% end %>
</td>
<td><%= display_text school.identifier %></td>
<td class="text-left"><%= school.name %></td>
<td><%= school.province %></td>
<td><%= school.city %></td>
<td class="text-left"><%= school.address %></td>
<td><%= school.users_count %></td>
<td><%= @department_count.fetch(school.id, 0) %></td>
<td><%= school.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td>
<%= delete_link '删除', admins_school_path(school, element: ".school-item-#{school.id}"), class: 'delete-school-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: schools } %>

@ -31,6 +31,7 @@
<li>
<%= sidebar_item_group('#schools-submenu', '单位管理', icon: 'building') do %>
<li><%= sidebar_item(admins_schools_path, '单位列表', icon: 'university', controller: 'admins-schools') %></li>
<li><%= sidebar_item(admins_departments_path, '部门列表', icon: 'sitemap', controller: 'admins-departments') %></li>
<% end %>
</li>

@ -12,7 +12,7 @@
<div class="form-group mr-2">
<label for="identity">职业:</label>
<% identity_options = [['全部', '']] + UserExtension.identities.map { |k, v| [I18n.t("user.identity.#{k}"), v] } %>
<% identity_options = [['全部', ''], ['教师', 0], ['学生', 1], ['专业人士', 2]] %>
<%= select_tag(:identity, options_for_select(identity_options), class: 'form-control') %>
</div>

@ -13,7 +13,7 @@ wb.styles do |style|
name = course_evaluation.name
items_size = course_evaluation.ec_course_evaluation_subitems.count
sheet.add_row name, style: bg_style
sheet.add_row [name], style: bg_style
sheet.merge_cells wb.rows.first.cells[(1..(items_size * course_evaluation.evaluation_count))]
data = []

@ -1 +1 @@
json.course_evaluations @course_evaluations, partial: 'shared/ec_course_evaluation', as: :ec_course_evaluation
json.course_evaluations @course_evaluations, partial: 'ecs/course_evaluations/shared/ec_course_evaluation', as: :ec_course_evaluation

@ -1 +1 @@
json.partial! 'shared/ec_course_evaluation', ec_course_evaluation: @course_evaluation
json.partial! 'ecs/course_evaluations/shared/ec_course_evaluation', ec_course_evaluation: @course_evaluation

@ -1 +1 @@
json.course_evaluations @course_evaluations, partial: 'shared/ec_course_evaluation_slim', as: :ec_course_evaluation
json.course_evaluations @course_evaluations, partial: 'ecs/course_evaluations/shared/ec_course_evaluation_slim', as: :ec_course_evaluation

@ -1,2 +1,2 @@
json.course_targets @course_targets, partial: 'shared/course_target', as: :ec_course_target
json.course_targets @course_targets, partial: 'ecs/course_targets/shared/course_target', as: :ec_course_target

@ -15,7 +15,7 @@ wb.styles do |style|
name = "#{@_current_course.name}课程目标"
wb.add_worksheet(name: name) do |sheet|
sheet.add_row name, style: title_style
sheet.add_row [name], style: title_style
sheet.add_row []
sheet.add_row []

@ -1,2 +1,2 @@
json.count @count
json.ec_courses @ec_courses, partial: 'shared/ec_course_slim', as: :ec_course
json.ec_courses @ec_courses, partial: 'ecs/ec_courses/shared/ec_course_slim', as: :ec_course

@ -1,3 +1,3 @@
json.count @graduation_requirements.size
json.graduation_requirements @graduation_requirements, partial: 'shared/ec_graduation_requirement', as: :ec_graduation_requirement
json.graduation_requirements @graduation_requirements, partial: '/ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement

@ -6,15 +6,15 @@ wb = xlsx_package.workbook
wb.styles do |style|
title_style = style.add_style(sz: 16, height: 20, b: true)
ec_year_style = style.add_style(sz: 10, height: 14)
label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center })
label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center, vertical: :center })
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
wb.add_worksheet(:name => '毕业要求及指标点') do |sheet|
sheet.add_row '毕业要求及指标点', style: title_style
sheet.add_row ['毕业要求及指标点'], style: title_style
sheet.add_row []
sheet.add_row ['专业代码', major.code], style: ec_year_style
sheet.add_row ['专业代码', major.code.to_s + ' '], style: ec_year_style
sheet.add_row ['专业名称', major.name], style: ec_year_style
sheet.add_row ['学年', "#{ec_year.year}学年"], style: ec_year_style
@ -32,12 +32,15 @@ wb.styles do |style|
end
items_size = requirement.ec_graduation_subitems.size
sheet.merge_cells("A#{index}:A#{index + items_size}")
sheet.merge_cells("B#{index}:B#{index + items_size}")
if items_size.zero?
sheet.add_row [requirement_content, ''], style: content_style
else
sheet.merge_cells("A#{index + 1}:A#{index + items_size}")
end
index += items_size
end
sheet.column_widths [400, 400]
sheet.column_widths 100, 100
end
end

@ -1,2 +1,2 @@
json.partial! 'shared/ec_graduation_requirement', ec_graduation_requirement: @graduation_requirement
json.partial! 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', ec_graduation_requirement: @graduation_requirement

@ -3,7 +3,7 @@ json.count @count
# 示例专业
json.template_ec_major_school do
json.partial! 'ecs/ec_major_schools/shared/ec_major_school', ec_major_school: @template_major_school
json.partial! 'ecs/ec_major_schools/shared/ec_major_school', ec_major_school: @template_major_school if @template_major_school
end
# 专业
@ -11,5 +11,5 @@ json.ec_major_schools @major_schools do |ec_major_school|
json.partial! 'ecs/ec_major_schools/shared/ec_major_school', ec_major_school: ec_major_school
# 专业管理员
json.major_managers ec_major_school.users, partial: 'ecs/ec_major_schools/shared/ec_major_school', as: :user
json.major_managers ec_major_school.users, partial: 'users/user_simple', as: :user
end

@ -0,0 +1,6 @@
json.extract! @major, :id, :code, :name, :template_major
json.school_id @major.school.id
json.school_name @major.school.name
can_manager = @major.manager?(current_user) || @major.school.manager?(current_user) || current_user.admin_or_business?
json.can_manager can_manager

@ -1,2 +1,7 @@
json.count @count
json.es_majors @ec_majors, partial: 'ecs/majors/shared/ec_major', as: :ec_major
json.ec_majors do
json.array! @ec_majors.each do |major|
json.extract! major, :id, :name, :code
json.selected @major_ids.include?(major.id)
end
end

@ -1,3 +1,3 @@
json.extract! ec_training_objective, :id, :content
json.ec_training_items ec_training_objective.ec_training_subitems, partial: 'ec_training_subitem', as: :ec_training_subitem
json.ec_training_items ec_training_objective.ec_training_subitems, partial: '/ecs/ec_training_objectives/shared/ec_training_subitem', as: :ec_training_subitem

@ -1 +1 @@
json.partial! 'shared/ec_training_objective', ec_training_objective: @training_objective
json.partial! '/ecs/ec_training_objectives/shared/ec_training_objective', ec_training_objective: @training_objective

@ -6,11 +6,11 @@ wb = xlsx_package.workbook
wb.styles do |style|
title_style = style.add_style(sz: 16, height: 20, b: true)
ec_year_style = style.add_style(sz: 10, height: 14)
label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center })
label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', border: { style: :thin, color: '000000' }, alignment: { horizontal: :center, vertical: :center })
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
wb.add_worksheet(:name => '培养目标及目标分解') do |sheet|
sheet.add_row '培养目标及目标分解', style: title_style
sheet.add_row ['培养目标及目标分解'], style: title_style
sheet.add_row []
sheet.add_row []
@ -27,6 +27,6 @@ wb.styles do |style|
end
items_size = training_objective.ec_training_subitems.size
sheet.merge_cells("A9:A#{9 + items_size}")
sheet.merge_cells("A9:A#{9 + items_size - 1}")
end
end

@ -8,7 +8,16 @@ json.ec_years do
json.training_subitem_count @training_subitem_count_map.fetch(ec_year.id, 0)
json.graduation_requirement_count @graduation_requirement_count_map.fetch(ec_year.id, 0)
json.course_count @course_count_map.fetch(ec_year.id, 0)
json.course_target_count @course_target_count_map.fetch(ec_year.id, 0)
json.graduation_subitem_count @graduation_subitem_count_map.fetch(ec_year.id, 0)
course_target = @course_target_count_map.fetch(ec_year.id, 0)
graduation_subitem = @graduation_subitem_count_map.fetch(ec_year.id, 0)
achieved_course = achieved_graduation_course_count(ec_year)
achieved_objective = achieved_graduation_objective_count(ec_year)
json.course_target_count course_target
json.graduation_subitem_count graduation_subitem
json.achieved_graduation_course_count achieved_course
json.achieved_graduation_objective_count achieved_objective
json.status graduation_subitem == achieved_objective ? 'achieved' : 'not_achieved'
end
end

@ -0,0 +1,13 @@
json.extract! @year, :id, :year
major = @year.ec_major_school
json.major_id major.id
json.major_name major.name
json.major_code major.code
school = major.school
json.school_id school.id
json.school_name school.name
can_manager = major.manager?(current_user) || school.manager?(current_user) || current_user.admin_or_business?
json.can_manager can_manager

@ -1 +1 @@
json.partial! 'shared/ec_graduation_subitem', ec_graduation_subitem: @graduation_subitem
json.partial! 'ecs/graduation_course_supports/shared/ec_graduation_subitem', ec_graduation_subitem: @graduation_subitem

@ -2,4 +2,5 @@ json.extract! ec_graduation_subitem, :id, :position, :content, :ec_graduation_re
json.graduation_requirement_position ec_graduation_subitem.ec_graduation_requirement.position
json.course_supports ec_graduation_subitem.ec_course_supports, partial: 'ec_course_support', as: :ec_course_support
json.course_supports ec_graduation_subitem.ec_course_supports, partial: 'ecs/graduation_course_supports/shared/ec_course_support', as: :ec_course_support
json.weights_total ec_graduation_subitem.ec_course_supports.to_a.sum(&:weights)

@ -1,3 +1,3 @@
json.course_count @course_count
json.graduation_subitems @graduation_subitems, partial: 'shared/ec_graduation_subitem', as: :ec_graduation_subitem
json.graduation_subitems @graduation_subitems, partial: 'ecs/graduation_course_supports/shared/ec_graduation_subitem', as: :ec_graduation_subitem
json.count @graduation_subitems.size

@ -14,7 +14,7 @@ wb.styles do |style|
tip_style = style.add_style(sz: 11, height: 16, color: 'FFA07A')
wb.add_worksheet(:name => '课程体系对毕业要求的支撑') do |sheet|
sheet.add_row '课程体系VS毕业要求', style: title_style
sheet.add_row ['课程体系VS毕业要求'], style: title_style
sheet.merge_cells wb.rows.first.cells[(1..(3 + max_support_length - 1))]
sheet.add_row []

@ -0,0 +1,8 @@
json.graduation_subitems do
json.array! @graduation_subitems do |graduation_subitem|
json.extract! graduation_subitem, :id, :position, :content
json.graduation_requirement_position graduation_subitem.ec_graduation_requirement.position
end
end
json.count @graduation_subitems.size

@ -13,4 +13,4 @@ json.school do
json.name current_school.name
end
json.school_managers @school_managers, partial: 'ecs/shared/user', as: :user
json.school_managers @school_managers, partial: 'users/user_simple', as: :user

@ -1 +0,0 @@
json.partial! 'ecs/shared/user', user: @user

@ -10,7 +10,7 @@ wb.styles do |style|
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
wb.add_worksheet(name: '达成度-毕业要求综合评价报表') do |sheet|
sheet.add_row '培养目标及目标分解', style: title_style
sheet.add_row ['达成度-毕业要求综合评价报表'], style: title_style
sheet.merge_cells("A1:D1")
sheet.add_row []

@ -1,4 +1,4 @@
json.graduation_requirements @graduation_requirements, partial: 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement
json.training_subitems @training_subitems, partial: 'ecs/ec_training_subitems/shared/ec_training_subitem', as: :ec_training_subitem
json.requirement_support_objectives @requirement_support_objectives, partial: 'shared/requirement_support_objective', as: :requirement_support_objective
json.requirement_support_objectives @requirement_support_objectives, partial: 'ecs/requirement_support_objectives/shared/requirement_support_objective', as: :requirement_support_objective

@ -16,7 +16,7 @@ wb.styles do |style|
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
wb.add_worksheet(:name => '毕业要求对培养目标的支撑') do |sheet|
sheet.add_row '毕业要求 vs 培养目标矩阵', style: title_style
sheet.add_row ['毕业要求 vs 培养目标矩阵'], style: title_style
sheet.merge_cells wb.rows.first.cells[(1..subitem_size)]

@ -1 +1 @@
json.score_levels @score_levels, partial: 'shared/ec_score_level', as: :ec_score_level
json.score_levels @score_levels, partial: 'ecs/score_levels/shared/ec_score_level', as: :ec_score_level

@ -1,2 +1,2 @@
json.count @count
json.students @students, partial: 'shared/ec_year_student', as: :ec_year_student
json.students @students, partial: 'ecs/students/shared/ec_year_student', as: :ec_year_student

@ -1,4 +1,4 @@
json.graduation_standards @graduation_standards, partial: 'ecs/shared/ec_graduation_standard', as: :ec_graduation_standard
json.graduation_subitems @graduation_subitems, partial: 'ecs/shared/ec_graduation_subitem', as: :ec_graduation_subitem
json.subitem_support_standards @subitem_support_standards, partial: 'shared/subitem_support_standard', as: :subitem_support_standard
json.subitem_support_standards @subitem_support_standards, partial: 'ecs/subitem_support_standards/shared/subitem_support_standard', as: :subitem_support_standard

@ -17,7 +17,7 @@ wb.styles do |style|
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
wb.add_worksheet(:name => '毕业要求对通用标准的支撑') do |sheet|
sheet.add_row '毕业要求 vs 通用标准矩阵', style: title_style
sheet.add_row ['毕业要求 vs 通用标准矩阵'], style: title_style
sheet.merge_cells wb.rows.first.cells[(1..standards_size)]

@ -0,0 +1,12 @@
json.count @count
json.users do
json.array! @users.each do |user|
json.id user.id
json.name user.real_name
json.identity user.identity
json.school_name user.school_name
json.department_name user.department_name
json.phone Util.conceal(user.phone, :phone)
json.manager @manager_ids.include?(user.id)
end
end

@ -11,7 +11,7 @@ json.update_user_name @is_evaluation ? "匿名" : @work.update_user.try(:real_na
json.update_atta @homework.late_duration && @is_author
json.attachments @attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)}
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false}
end
unless @is_evaluation

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save