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/helpers/subjects_helper.rb

20 lines
652 B

6 years ago
module SubjectsHelper
# 实训路径的发布状态
5 years ago
def publish_status subject, is_manager, user, shixuns
6 years ago
status = -1
if is_manager
5 years ago
status = 0 if subject.status == 0 && shixuns.count > 0
6 years ago
status = 1 if subject.status == 1
status = 2 if subject.status == 2 && user.admin?
end
status
end
# 实训路径的所有用户获得的标签
def user_shixun_tags challenge_ids, user_id
ChallengeTag.joins("join games on challenge_tags.challenge_id = games.challenge_id").
where(challenge_id: challenge_ids, games: {status: 2, user_id: user_id}).pluck("challenge_tags.name").uniq
end
6 years ago
end