pre_develop
daiao 6 years ago
parent 23d8e023df
commit 3e416f2538

@ -124,19 +124,22 @@ class CnmoocsService
end
def get_students_data params
subject = Subject.find_by_id params[:resouceId]
return {error: -1, messages: "资源id不对请使用一级目录资源查找"} if subject.blank?
shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id)
myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games)
score = 0
time = 0
myshixuns.each do |myshixun|
score += myshixun.total_score
shixun = Shixun.find_by_id params[:resouceId]
return {error: -1, messages: "资源id不对请使用资源的id查找"} if shixun.blank?
# shixun_ids = StageShixun.where(:stage_id => subject.stages).pluck(:shixun_id)
#myshixuns = Myshixun.where(:user_id => params[:userId], shixun_id: shixun_ids).includes(:games)
myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games)
if myshixun
score = myshixun.total_score
time = 0
myshixun.games.each do |game|
time += game.consumes_time_int
end
{error: 0, messages: '成功', data: {time: time, score: score * 10}}
else
{error: -1, messages: '用户还未开始学习此资源'}
end
{error: 0, messages: '成功', data: {time: time, score: score * 10}}
end

Loading…
Cancel
Save