课堂在线学习

dev_cs
cxt 5 years ago
parent e1cda8ee61
commit 45db8554e4

@ -357,7 +357,7 @@ class Course < ApplicationRecord
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
course_challeng_count = course.shixuns.pluck(:challenges_count).sum
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

@ -8,4 +8,4 @@ json.start_learning @start_learning
json.learned @start_learning ? @course.my_subject_progress : 0
json.last_shixun @start_learning ? last_subject_shixun(@user.id, @subject) : ""
json.last_shixun @start_learning ? last_subject_shixun(@user.id, @course) : ""
Loading…
Cancel
Save