From c81391e8db0ef5c328f3c8b80e16714729ad407c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 13 Feb 2020 12:53:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=AE=E9=80=9A=E4=BD=9C=E4=B8=9A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_commons/index.json.jbuilder | 5 ++++- app/views/homework_commons/works_list.json.jbuilder | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index db3603746..a508659e8 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -17,7 +17,10 @@ json.homeworks @homework_commons.each do |homework| json.status_time curr_status[:time] json.time_status curr_status[:time_status] json.allow_late homework.allow_late - json.author homework.user.real_name + json.author homework.user&.real_name + json.author_img url_to_avatar(homework.user) + json.author_login homework.user&.login + json.created_at homework.created_at.strftime("%Y-%m-%d") # 只有在主目录才显示 json.upper_category_name homework.course_second_category&.name unless params[:category] diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index f5e6ca01a..cd2f17cf5 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -84,6 +84,7 @@ elsif @user_course_identity == Course::STUDENT json.user_login @work.user.login json.student_id @work.user.student_id json.user_name @work.user.real_name + json.user_img url_to_avatar(@work.user) json.group_name @member.course_group_name end @@ -108,6 +109,7 @@ if @homework.homework_type == "practice" json.view_answer_count work.myshixun.try(:view_answer_count).to_i json.user_login work.user.try(:login) json.user_name work.user.try(:real_name) + json.user_img url_to_avatar(work.user) json.student_id work.user.try(:student_id) json.group_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name) json.work_status work.compelete_status @@ -169,6 +171,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" json.user_login @is_evaluation ? "--" : work.user.try(:login) json.user_name @is_evaluation ? "匿名" : work.user.try(:real_name) + json.user_img url_to_avatar(@is_evaluation ? "0" : work.user) end end