From 177dded9690bc4c350f6b91d4e197be69181e1cc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 6 Jul 2019 17:02:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_commons/index.json.jbuilder | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index 5b9717c2f..60aa720f5 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -25,14 +25,16 @@ json.homeworks @homework_commons.each do |homework| if @user_course_identity < Course::STUDENT if homework.homework_type == "practice" - json.shixun_identifier homework.shixuns.first.try(:identifier) + json.shixun_identifier homework.shixuns.take.try(:identifier) end elsif @user_course_identity == Course::STUDENT if homework.homework_type == "practice" + shixun = homework.shixuns.take # json.challenge_count homework.shixuns.first.try(:challenges_count).to_i current_myshixun = homework.user_work(@user.id).try(:myshixun) + myshixun = current_myshixun ? current_myshixun : shixun.myshixuns.find_by(user_id: @user.id) # json.game_count current_myshixun ? current_myshixun.exec_count : 0 - json.task_operation task_operation_url(current_myshixun, homework.shixuns.first) + json.task_operation task_operation_url(current_myshixun, shixun) else work = homework.user_work(@user.id) json.work_id work.try(:id)