|
|
|
@ -354,9 +354,8 @@ class Course < ApplicationRecord
|
|
|
|
|
Myshixun.where(user_id: user_id, shixun_id: shixuns).exists?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def my_subject_progress
|
|
|
|
|
my_challenge_count = Game.joins(:challenge).where(user_id: User.current.id, status: 2, challenges: {shixun_id: shixuns.published_closed}).
|
|
|
|
|
pluck(:challenge_id).uniq.size
|
|
|
|
|
def my_subject_progress myshixuns
|
|
|
|
|
my_challenge_count = Game.where(myshixun_id: myshixuns.pluck(:id), status: 2).pluck(:challenge_id).uniq.size
|
|
|
|
|
course_challeng_count = shixuns.pluck(:challenges_count).sum
|
|
|
|
|
count = course_challeng_count == 0 ? 0 : ((my_challenge_count.to_f / course_challeng_count).round(2) * 100).to_i
|
|
|
|
|
end
|
|
|
|
|