You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/ec_course_evaluation.rb

39 lines
1.5 KiB

6 years ago
# 工程认证课程达成度计算--课程评估标准
# status: 1 单次考核总成绩支撑课程目标, 2 单次考核的某分项成绩支撑课程目标
# score_type: 1导入的是明细成绩 2导入的是平均成绩
class EcCourseEvaluation < ApplicationRecord
belongs_to :ec_course
# 考核分项
has_many :ec_course_evaluation_subitems, dependent: :destroy
has_many :ec_student_achievements
enum status: { partly: 1, totality: 2 }, _suffix: :support # :partly_support?, :totality_support?
enum score_type: { detail: 1, average: 2 }, _suffix: :score_type # :detail_score_type?, :average_score_type?
accepts_nested_attributes_for :ec_course_evaluation_subitems, allow_destroy: true
5 years ago
alias_attribute :evaluation_count, :evluation_count
6 years ago
def imported?
import_status?
end
5 years ago
def evaluation_relates
# 总成绩支撑只有课程考核标准的名称, 分项成绩支撑是课程考核标准名称与考核分项的笛卡尔积
if status == 1
return evaluation_count.times.map { |index| { id: -1, name: "#{name}#{index + 1}", position: index + 1 } }
end
if is_course_type?
ec_course_evaluation_subitems.map.with_index { |item, index| { id: item.id, name: item.name, position: index + 1 } }
else
data = []
ec_course_evaluation_subitems.each do |item|
evaluation_count.times do |i|
data << { id: item.id, name: "#{name}#{i + 1}#{item.name}", position: i + 1 }
end
end
data
end
end
6 years ago
end