From ac7c1e8ac6af2c49464c3cf6916096542ac8694d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 15:58:45 +0800 Subject: [PATCH 01/25] =?UTF-8?q?D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 15b59e863..9eec32521 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -44,7 +44,7 @@ class StudentWorksController < ApplicationController # 统一设置的作业取所有学生,否则取已发布的分班学生 students = @homework.unified_setting? ? @course.students : @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id)) unless params[:search].blank? - @members = students.joins(user: :user_extensions).where("user_id != #{current_user.id} and (concat(users.lastname, users.firstname) + @members = students.joins(user: :user_extension).where("user_id != #{current_user.id} and (concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?)", "%#{params[:search]}%", "%#{params[:search]}%") else From 6a887e21e3b1507ee5eee75fa72fad5ca2075e57 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 16:01:19 +0800 Subject: [PATCH 02/25] =?UTF-8?q?D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 9eec32521..aa0a0f171 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -44,7 +44,7 @@ class StudentWorksController < ApplicationController # 统一设置的作业取所有学生,否则取已发布的分班学生 students = @homework.unified_setting? ? @course.students : @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id)) unless params[:search].blank? - @members = students.joins(user: :user_extension).where("user_id != #{current_user.id} and (concat(users.lastname, users.firstname) + @members = students.joins(user: :user_extension).where("course_members.user_id != #{current_user.id} and (concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?)", "%#{params[:search]}%", "%#{params[:search]}%") else From 32a9916fc46359565cf0ecdae5a6c311f62e0fc8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 16:11:00 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_public_navigation.json.jbuilder | 5 +++-- app/views/homework_commons/index.json.jbuilder | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/homework_commons/_homework_public_navigation.json.jbuilder b/app/views/homework_commons/_homework_public_navigation.json.jbuilder index 09dd076c0..2c803bee8 100644 --- a/app/views/homework_commons/_homework_public_navigation.json.jbuilder +++ b/app/views/homework_commons/_homework_public_navigation.json.jbuilder @@ -3,8 +3,9 @@ json.course_name course.name json.is_end course.is_end json.category homework.category_info member = course.course_members.find_by(user_id: user.id, is_active: 1) -json.homework_status homework_curr_status(homework, user.course_identity(course), course, member, member&.teacher_course_groups)[:status] -json.time_status homework_curr_status(homework, user.course_identity(course), course, member, member&.teacher_course_groups)[:time_status] +curr_status = homework_curr_status(homework, user.course_identity(course), course, member, member&.teacher_course_groups) +json.homework_status curr_status[:status] +json.time_status curr_status[:time_status] json.homework_name homework.name json.homework_id homework.id json.homework_type homework.homework_type diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index c9074cc2b..262d4d92d 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -13,15 +13,16 @@ json.category_name @category.try(:name) json.homeworks @homework_commons.each do |homework| # homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public + curr_status = homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups) json.homework_id homework.id json.name homework.name json.private_icon !homework.is_public - json.status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:status] - json.status_time homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time] - json.time_status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time_status] + json.status curr_status[:status] + json.status_time curr_status[:time] + json.time_status curr_status[:time_status] json.allow_late homework.allow_late - unless homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:status].include?("未发布") + unless curr_status[:status].include?("未发布") json.commit_count studentwork_count homework, 1, @user.id json.uncommit_count studentwork_count homework, 0, @user.id end From 2b87d06598862af98a31f27c3a87c9f3fb745433 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 16:19:29 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E4=BA=A4=E5=8F=89=E8=AF=84=E9=98=85?= =?UTF-8?q?=E4=BA=BA=E5=8E=BB=E6=8E=89=E5=BD=93=E5=89=8D=E8=80=81=E5=B8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 435dbd4ed..3a6762663 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -71,7 +71,7 @@ class GraduationTasksController < ApplicationController @work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension]) @all_work_count = @work_list.count - @teachers = @course.teachers + @teachers = @course.teachers.where.not(user_id: current_user.id) # 教师评阅搜索 0: 未评, 1 已评 unless params[:teacher_comment].blank? graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id) From 6264af326309883b63207e1447994db662940022 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 16:32:03 +0800 Subject: [PATCH 05/25] =?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/controllers/homework_commons_controller.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index c0d72e1ee..4c01a7dc0 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -89,12 +89,7 @@ class HomeworkCommonsController < ApplicationController @homework_commons = @homework_commons.page(page).per(15) if @homework_type == 4 - if @user_course_identity == Course::STUDENT - @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :shixuns, - student_works: [myshixun: [:games]]) - else - @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :shixuns, :student_works) - end + @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :shixuns, :student_works) else @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :homework_detail_group, :student_works) From 464956935709ebf0ded574d49059bd1b2358bfc0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 21 Jun 2019 16:40:21 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 4c01a7dc0..bb37283ca 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -89,10 +89,9 @@ class HomeworkCommonsController < ApplicationController @homework_commons = @homework_commons.page(page).per(15) if @homework_type == 4 - @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :shixuns, :student_works) + @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :shixuns) else - @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :homework_detail_group, - :student_works) + @homework_commons = @homework_commons.includes(:homework_detail_manual, :published_settings, :homework_detail_group) end end From 48eab5234f8bb3cf0001b9548166df51994587e8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 17:04:53 +0800 Subject: [PATCH 07/25] =?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/controllers/graduation_tasks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 3a6762663..a1f1d01c4 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -98,7 +98,7 @@ class GraduationTasksController < ApplicationController unless params[:cross_comment].blank? graduation_work_id = @task.graduation_work_comment_assignations.where(:user_id =>current_user.id) .pluck(:graduation_work_id).uniq if @task.graduation_work_comment_assignations - @work_list = @work_list.where(id: graduation_work_id) + @work_list = @task.graduation_works.where(id: graduation_work_id) end # 输入姓名和学号搜索 From 4e65aaa214c647efbe92945fcd2ae92dde4e292b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 21 Jun 2019 17:09:44 +0800 Subject: [PATCH 08/25] fix bug --- app/controllers/exercises_controller.rb | 16 +++++++++++----- app/helpers/exercises_helper.rb | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e2d6110bd..e4204d9d1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1023,7 +1023,7 @@ class ExercisesController < ApplicationController if @t_user_exercise_status == 3 get_each_student_exercise(@exercise.id,@exercise_questions,@exercise_current_user_id) end - get_user_answer_status(@exercise_questions,@exercise_current_user_id) + get_user_answer_status(@exercise_questions,@exercise_current_user_id,@exercise,@t_user_exercise_status) rescue Exception => e uid_logger_error(e.message) @@ -1117,7 +1117,7 @@ class ExercisesController < ApplicationController @student_status = 0 else @student_status = 1 - get_user_answer_status(@exercise_questions,@exercise_current_user_id) + get_user_answer_status(@exercise_questions,@exercise_current_user_id,@exercise,get_exercise_status) end end end @@ -1685,11 +1685,17 @@ class ExercisesController < ApplicationController end end - def get_user_answer_status(exercise_questions,user_id) + def get_user_answer_status(exercise_questions,user_id,exercise,exercise_user_status) @question_status = [] @exercise_all_questions = [] + ex_question_random = exercise.question_random question_answered = 0 exercise_questions.each_with_index do |q,index| + if ex_question_random && exercise_user_status != 3 + ques_number = index + 1 + else + ques_number = q.question_number + end if q.question_type != 5 ques_vote = q.exercise_answers.search_exercise_answer("user_id",user_id) else @@ -1725,12 +1731,12 @@ class ExercisesController < ApplicationController end question_status = { :ques_id => q.id, - :ques_number => index+1, #仅问题的显示位置变化,但是问题的question_number 不会变化,与之相关的choice/standard_answer/answer不会变化 + :ques_number => ques_number, #仅问题的显示位置变化,但是问题的question_number 不会变化,与之相关的choice/standard_answer/answer不会变化 :ques_status => ques_status, } question_options = { :question => q, - :ques_number => index+1, + :ques_number => ques_number, } @question_status = @question_status.push(question_status).sort_by {|k| k[:ques_number]} @exercise_all_questions = @exercise_all_questions.push(question_options).sort_by {|k| k[:ques_number]} diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 95ec0ac24..53b2fa4c1 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -323,6 +323,7 @@ module ExercisesHelper else show_unreview_count = nil end + logger.info("##########__________exercise_end_time__________###############{exercise_end_time}") if exercise_status == 2 && exercise_end_time.present? ex_left_time = how_much_time(exercise_end_time) From fb6d114fde7fb9ca30201f2502be462aaef3f65c Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 21 Jun 2019 17:21:25 +0800 Subject: [PATCH 09/25] add descendants_count to solve index sort by hot --- app/controllers/messages_controller.rb | 49 ++++++++----------- app/models/message.rb | 17 +++---- app/views/messages/index.json.jbuilder | 5 ++ ...83604_add_descendants_count_to_messages.rb | 5 ++ lib/tasks/course_board_message_count.rake | 17 +++++++ 5 files changed, 53 insertions(+), 40 deletions(-) create mode 100644 db/migrate/20190621083604_add_descendants_count_to_messages.rb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 98f453424..5569ec165 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -17,17 +17,25 @@ class MessagesController < ApplicationController @page = params[:page] || 1 @page_size = params[:page_size] || 15 - sort = params[:sort] || 0 + sort = params[:sort].to_i == 1 ? 'asc' : 'desc' sort_type = params[:sort_type] || 'time' - sort = sort.to_i - sort_type = sort_type.strip - @messages = @board.messages.root_nodes.by_keywords(params[:search]).includes(:praise_treads, :author, :children) - @messages = @messages.ordered(sort: sort, sort_type: sort_type) - @messages = sort_by_all_replies(sort, sort_type, @messages) + messages = @board.messages.root_nodes.by_keywords(params[:search]) - @messages = sort_by_sticky(@messages) - @messages = Kaminari.paginate_array(@messages).page(@page).per(@page_size) + messages = messages.order('(sticky = 1) DESC') # 置顶 + + messages = + case sort_type + when 'time' then messages.reorder("created_on #{sort}") + when 'hot' then messages.reorder("descendants_count #{sort}") + else messages.reorder("created_on #{sort}") + end + + messages = messages.includes(:author) + @messages = Kaminari.paginate_array(messages).page(@page).per(@page_size) + + ids = @messages.map(&:id) + @praises_count_map = Message.where(root_id: ids).group(:root_id).sum(:praises_count) end def reply_list @@ -43,33 +51,16 @@ class MessagesController < ApplicationController def reply return normal_status(2, "回复内容不能为空") if params[:content].blank? - begin - @reply = Message.create!(board: @message.board, - author: current_user, - parent: @message, - message_detail_attributes: { + @reply = Message.create!(board: @message.board, root: @message.root, author: current_user, parent: @message, + message_detail_attributes: { content: params[:content] - } - ) - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - raise ActiveRecord::Rollback - end + }) end def sticky_top return normal_status(403, "您没有权限进行该操作") unless current_user.teacher_of_course?(@message.board.course) - ActiveRecord::Base.transaction do - begin - @message.update_attributes(:sticky => @message.sticky == 1 ? 0 : 1) - rescue Exception => e - uid_logger_error(e.message) - tip_exception(e.message) - raise ActiveRecord::Rollback - end - end + @message.update_attributes(:sticky => @message.sticky == 1 ? 0 : 1) end def bulk_delete diff --git a/app/models/message.rb b/app/models/message.rb index d3d507a72..c3b3bca40 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -4,6 +4,8 @@ class Message < ApplicationRecord belongs_to :board, counter_cache: true belongs_to :author, class_name: "User", foreign_key: 'author_id' belongs_to :parent, class_name: "Message", foreign_key: "parent_id", counter_cache: :replies_count, optional: true + belongs_to :root, class_name: 'Message', foreign_key: :root_id, counter_cache: :descendants_count, optional: true + has_one :message_detail, dependent: :destroy accepts_nested_attributes_for :message_detail, update_only: true @@ -12,6 +14,7 @@ class Message < ApplicationRecord has_many :tidings, as: :container, dependent: :destroy has_many :attachments, as: :container, dependent: :destroy has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # 课程动态 + has_many :descendants, class_name: 'Message', foreign_key: :root_id, dependent: :destroy scope :root_nodes, -> { where("parent_id IS NULL") } #判断该信息是帖子还是回复。null为发布的帖子 scope :reply_nodes, -> { where("parent_id IS NOT NULL") } @@ -70,24 +73,16 @@ class Message < ApplicationRecord # 包含二级回复的总点赞数 def total_praises_count - praises_count + children.includes(:children).reduce(0) { |count, filed| - sub_sum_count = filed.children.reduce(0) { |sub_count, sub_filed| sub_count += sub_filed.praises_count } - count += filed.praises_count - sub_sum_count += count - } + descendants.sum(:praises_count) end # 包含二级回复数的总回复数 def total_replies_count - replies_count + children.includes(:children).reduce(0) { |count, child| - sub_sum_count = child.children.reduce(0) { |sub_count, sub_child| sub_count += sub_child.replies_count } - count += child.replies_count - sub_sum_count += count - } + descendants_count end def has_replies - children.present? + children.exists? end # diff --git a/app/views/messages/index.json.jbuilder b/app/views/messages/index.json.jbuilder index 026e193a6..60d35e769 100644 --- a/app/views/messages/index.json.jbuilder +++ b/app/views/messages/index.json.jbuilder @@ -6,6 +6,11 @@ json.data do json.total_count @messages.total_count json.messages do json.array! @messages do |message| + json.extract! message, :id, :parent_id, :subject, :created_on, :total_replies_count, + :praises_count, :visits, :sticky, :is_hidden, :is_public + + json.total_praises_count @praises_count_map.fetch(message.id, 0) + json.partial! "messages/message", message: message json.author do json.partial! "users/user_simple", user: message.author diff --git a/db/migrate/20190621083604_add_descendants_count_to_messages.rb b/db/migrate/20190621083604_add_descendants_count_to_messages.rb new file mode 100644 index 000000000..02b721583 --- /dev/null +++ b/db/migrate/20190621083604_add_descendants_count_to_messages.rb @@ -0,0 +1,5 @@ +class AddDescendantsCountToMessages < ActiveRecord::Migration[5.2] + def change + add_column :messages, :descendants_count, :integer, default: 0 + end +end diff --git a/lib/tasks/course_board_message_count.rake b/lib/tasks/course_board_message_count.rake index 35e439403..49f33c615 100644 --- a/lib/tasks/course_board_message_count.rake +++ b/lib/tasks/course_board_message_count.rake @@ -20,6 +20,23 @@ namespace :course_board do end end + desc 'transfer root id && statistic descendants count' + task messages_descendants_count_transfer: :environment do + Message.root_nodes.find_each do |root| + logger("Current transfer root id: #{root.id} ~") + children_ids = root.children.pluck(:id) + next if children_ids.blank? + + second_children_ids = Message.where(parent_id: children_ids).pluck(:id) + + ids = children_ids.concat(second_children_ids).uniq + Message.where(id: ids).update_all(root_id: root.id) + + Message.reset_counters(root.id, :descendants) + logger("transfer success ~") + end + end + def logger(msg) puts msg end From 1629fbf2223ee54683a42be066d988afc8830aba Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 17:25:00 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homework_commons/works_list.json.jbuilder | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 1d3110604..a1618d8ff 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -29,8 +29,9 @@ elsif @user_course_identity == Course::STUDENT json.left_time left_time @homework, @current_user.id if @homework.homework_type == "practice" - json.(@work, :id, :work_status, :update_time, :late_penalty, :ultimate_score) + json.(@work, :id, :work_status, :update_time, :ultimate_score) + json.late_penalty @work.late_penalty if @homework.allow_late json.cost_time @work.myshixun.try(:total_cost_time) json.work_score work_score_format(@work.work_score, true, @homework.score_open) json.final_score work_score_format(@work.final_score, true, @homework.score_open) @@ -38,7 +39,7 @@ elsif @user_course_identity == Course::STUDENT json.eff_score work_score_format(@work.eff_score, true, @homework.score_open) json.complete_count @work.myshixun.try(:passed_count) else - json.(@work, :id, :work_status, :update_time, :late_penalty, :absence_penalty, :appeal_penalty, :ultimate_score) + json.(@work, :id, :work_status, :update_time, :ultimate_score) json.work_score work_score_format(@work.work_score, true, @homework.score_open) json.final_score work_score_format(@work.final_score, true, @homework.score_open) @@ -48,13 +49,17 @@ elsif @user_course_identity == Course::STUDENT json.ta_comment_count @work.ta_comment_count + json.late_penalty @work.late_penalty if @homework.allow_late + if @homework.anonymous_comment json.student_comment_count @work.student_comment_num + json.absence_penalty @work.absence_penalty end if @homework.anonymous_appeal json.appeal_all_count @work.appeal_all_count json.appeal_deal_count @work.appeal_deal_count + json.appeal_penalty @work.appeal_penalty end if @homework.homework_type == "group" @@ -76,8 +81,9 @@ if @homework.homework_type == "practice" json.work_efficiency @homework.work_efficiency json.student_works @student_works.each do |work| - json.(work, :id, :work_status, :update_time, :late_penalty, :ultimate_score) + json.(work, :id, :work_status, :update_time, :ultimate_score) + json.late_penalty work.late_penalty if @homework.allow_late json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) json.efficiency work_score_format(work.efficiency, @current_user == work.user, @homework.score_open) @@ -103,8 +109,9 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" # json.student_comment_count anon_comments(@current_user, work.id).count else json.(work, :id, :work_status, :update_time, :work_score, :final_score, :teacher_score, :student_score, - :teaching_asistant_score, :late_penalty, :absence_penalty, :appeal_penalty, :ultimate_score) + :teaching_asistant_score, :ultimate_score) + json.late_penalty work.late_penalty if @homework.allow_late json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @homework.score_open) @@ -117,6 +124,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" # 作品匿评条数 if @homework.anonymous_comment json.student_comment_count @homework_detail_manual.comment_status > 2 ? work.student_comment_num : 0 + json.absence_penalty work.absence_penalty end json.student_id work.user.try(:student_id) @@ -133,6 +141,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" if @homework.anonymous_appeal json.appeal_all_count work.appeal_all_count json.appeal_deal_count work.appeal_deal_count + json.appeal_penalty work.appeal_penalty end json.user_login @is_evaluation ? "--" : work.user.try(:login) From 2a9e521d5465277f87d84f6b2047c1e3bb942c5a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 17:31:15 +0800 Subject: [PATCH 11/25] =?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/graduation_tasks/tasks_list.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index fe7ffddc4..5868be4fb 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -1,6 +1,7 @@ json.partial! "public_navigation", locals: {graduation: @task, course: @course} json.user_course_identity @user_course_identity json.course_group_count @course.course_groups_count +json.cross_comment @task.cross_comment # 课程发布才有数据 if @task.published? || @user_course_identity < Course::STUDENT # 老师身份才有的分类信息 From e269f32591c3b3907b20751b68c39d5d027247d6 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 21 Jun 2019 17:33:04 +0800 Subject: [PATCH 12/25] fix --- app/controllers/messages_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 5569ec165..3dac97899 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -22,13 +22,13 @@ class MessagesController < ApplicationController messages = @board.messages.root_nodes.by_keywords(params[:search]) - messages = messages.order('(sticky = 1) DESC') # 置顶 + messages = messages.reorder('(sticky = 1) DESC') # 置顶 messages = case sort_type - when 'time' then messages.reorder("created_on #{sort}") - when 'hot' then messages.reorder("descendants_count #{sort}") - else messages.reorder("created_on #{sort}") + when 'time' then messages.order("created_on #{sort}") + when 'hot' then messages.order("descendants_count #{sort}") + else messages.order("created_on #{sort}") end messages = messages.includes(:author) From 471edd3607fff9aab1176a21b501f46a39741038 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 21 Jun 2019 19:17:58 +0800 Subject: [PATCH 13/25] fix bug --- app/helpers/application_helper.rb | 2 +- app/helpers/exercises_helper.rb | 1 - app/tasks/exercise_publish_task.rb | 32 +++++++++++------------------- lib/tasks/poll_publish.rake | 7 ++++--- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ac50e78d3..42bc16343 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -109,7 +109,7 @@ module ApplicationHelper # 计算到结束还有多长时间 **天**小时**分 def how_much_time(time) - if time.nil? + if time.nil? || time < Time.now #6.21 -hs 增加小于time.now '' else result = ((time - Time.now.to_i).to_i / (24*60*60)).to_s + " 天 " diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 53b2fa4c1..95ec0ac24 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -323,7 +323,6 @@ module ExercisesHelper else show_unreview_count = nil end - logger.info("##########__________exercise_end_time__________###############{exercise_end_time}") if exercise_status == 2 && exercise_end_time.present? ex_left_time = how_much_time(exercise_end_time) diff --git a/app/tasks/exercise_publish_task.rb b/app/tasks/exercise_publish_task.rb index 7f3ee63ee..9d62e4d2e 100644 --- a/app/tasks/exercise_publish_task.rb +++ b/app/tasks/exercise_publish_task.rb @@ -5,7 +5,7 @@ class ExercisePublishTask def publish Rails.logger.info("log--------------------------------exercise_publish start") puts "--------------------------------exercise_publish start" - exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + exercises = Exercise.includes(:exercise_users).where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) exercises.each do |exercise| exercise.update_column('exercise_status', 2) course = exercise.course @@ -67,21 +67,21 @@ class ExercisePublishTask end def end - exercises = Exercise.where("end_time <= ? and exercise_status = ?",Time.now,2) + Rails.logger.info("log--------------------------------exercise_end start") + puts "--------------------------------exercise_end start" + # 1。统一设置的试卷 + exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now) exercises.each do |exercise| - course = exercise.course ex_type = exercise.exercise_questions.pluck(:question_type).uniq - exercise.update_attribute('exercise_status', 3) + exercise.update_column('exercise_status', 3) exercise.exercise_users.each do |exercise_user| if exercise_user.commit_status == 0 && !exercise_user.start_at.nil? - # exercise_user.update_attributes(:commit_status => 1, :end_at => Time.now, :status => true) s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] if ex_type.include?(4) #是否包含主观题 subjective_score = exercise_user.subjective_score else subjective_score = -1.0 end - # subjective_score = exercise_user.subjective_score total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score total_score = s_score + total_score_subjective_score commit_option = { @@ -93,21 +93,20 @@ class ExercisePublishTask :subjective_score => subjective_score } exercise_user.update_attributes(commit_option) - # if exercise_user.user.exercise_answers.where(:exercise_question_id => exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? - # exercise_user.update_attributes(:subjective_score => 0) - # end end end end - all_exercises = Exercise.where("end_time > ? and exercise_status = ?",Time.now,2) + # 2.非统一的试卷 + all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now) exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")" ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}") ex_group_settings.each do |exercise_setting| exercise = exercise_setting.exercise + exercise.update_column('exercise_status', 3) ex_types = exercise.exercise_questions.pluck(:question_type).uniq users = exercise.course.students.where(:course_group_id => exercise_setting.course_group_id) - exercise_users = exercise.exercise_users.where(:user_id => users.map(&:user_id)) + exercise_users = exercise.exercise_users.where(:user_id => users.pluck(:user_id)) exercise_users.each do |exercise_user| if exercise_user.commit_status == 0 && !exercise_user.start_at.nil? @@ -117,7 +116,6 @@ class ExercisePublishTask subjective_score = -1.0 end s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] - # subjective_score = exercise_user.subjective_score total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score total_score = s_score + total_score_subjective_score commit_option = { @@ -129,17 +127,11 @@ class ExercisePublishTask :subjective_score => subjective_score } exercise_user.update_attributes(commit_option) - # exercise_user.update_attributes(:commit_status => 1, :end_at => Time.now, :status => true) - - # s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] - # exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0))) - # if exercise_user.user.exercise_answers.where(:exercise_question_id => exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? - # exercise_user.update_attributes(:subjective_score => 0.0) - # end end end end - Rails.logger.info("log--------------------------------exercise_end completed") + Rails.logger.info("log--------------------------------exercise_end end") + puts "--------------------------------exercise_end end" end end \ No newline at end of file diff --git a/lib/tasks/poll_publish.rake b/lib/tasks/poll_publish.rake index c33ad3afb..d10db7a5d 100644 --- a/lib/tasks/poll_publish.rake +++ b/lib/tasks/poll_publish.rake @@ -6,7 +6,7 @@ namespace :poll_publish do task :publish => :environment do puts "--------------------------------poll_publish start" # 统一设置发布时间的问卷 - polls = Poll.where("publish_time is not null and polls_status = 1 and publish_time <=?",Time.now) + polls = Poll.includes(:poll_users).where("publish_time is not null and polls_status = 1 and publish_time <=?",Time.now) polls.each do |poll| poll.update_attributes(:polls_status => 2) course = poll.course @@ -71,7 +71,7 @@ namespace :poll_publish do task :nearly_end => :environment do puts "--------------------------------poll_nearly_end start" # 统一设置发布时间的问卷 - polls = Poll.where("polls_status = 2 and unified_setting = 1 and end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) + polls = Poll.includes(:poll_users).where("polls_status = 2 and unified_setting = 1 and end_time <=? and end_time > ?", Time.now + 86400, Time.now + 84600) polls.each do |poll| if poll.tidings.where(:parent_container_type => "NearlyEnd").count == 0 course = poll.course @@ -111,7 +111,7 @@ namespace :poll_publish do end task :end => :environment do - polls = Poll.where("polls_status = 2 and unified_setting = 1 and end_time <=?",Time.now) + polls = Poll.includes(:poll_users).where("polls_status = 2 and unified_setting = 1 and end_time <=?",Time.now) polls.each do |poll| poll.update_attributes(:polls_status => 3) poll.poll_users.each do |poll_user| @@ -123,6 +123,7 @@ namespace :poll_publish do PollGroupSetting.where("end_time < ? and end_time > ?", Time.now + 1800, Time.now - 1800).each do |poll_setting| poll = poll_setting.poll + poll.update_column('polls_status',3) users = poll.course.course_members.where(:course_group_id => poll_setting.course_group_id) poll_users = poll.poll_users.where(:user_id => users.map(&:user_id)) From 0babcc3195e67dab8516fb3c846252289d7097fe Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 21 Jun 2019 19:57:50 +0800 Subject: [PATCH 14/25] =?UTF-8?q?exercise=E5=AE=9A=E6=97=B6=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 2 +- app/tasks/exercise_publish_task.rb | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 95ec0ac24..1b201d875 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -352,7 +352,7 @@ module ExercisesHelper score2 = 0.0 #填空题 score5 = 0.0 #实训题 ques_stand = [] #问题是否正确 - exercise_questions = exercise.exercise_questions + exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers) exercise_questions.each do |q| if q.question_type != 5 answers_content = q.exercise_answers.search_answer_users("user_id",user.id) #学生的答案 diff --git a/app/tasks/exercise_publish_task.rb b/app/tasks/exercise_publish_task.rb index 9d62e4d2e..6f18dc403 100644 --- a/app/tasks/exercise_publish_task.rb +++ b/app/tasks/exercise_publish_task.rb @@ -70,12 +70,12 @@ class ExercisePublishTask Rails.logger.info("log--------------------------------exercise_end start") puts "--------------------------------exercise_end start" # 1。统一设置的试卷 - exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now) + exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900) exercises.each do |exercise| ex_type = exercise.exercise_questions.pluck(:question_type).uniq exercise.update_column('exercise_status', 3) exercise.exercise_users.each do |exercise_user| - if exercise_user.commit_status == 0 && !exercise_user.start_at.nil? + if exercise_user.commit_status == 0 && exercise_user.start_at.present? s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] if ex_type.include?(4) #是否包含主观题 subjective_score = exercise_user.subjective_score @@ -84,6 +84,8 @@ class ExercisePublishTask end total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score total_score = s_score + total_score_subjective_score + Rails.logger.info("log-------------total_score-------------------total_scoretotal_scoretotal_scoretotal_score#{total_score}") + commit_option = { :status => 1, :commit_status => 1, @@ -98,12 +100,15 @@ class ExercisePublishTask end # 2.非统一的试卷 - all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now) + all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900) exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")" ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}") ex_group_settings.each do |exercise_setting| exercise = exercise_setting.exercise - exercise.update_column('exercise_status', 3) + if exercise&.end_time <= Time.now + exercise.update_column('exercise_status', 3) + end + ex_types = exercise.exercise_questions.pluck(:question_type).uniq users = exercise.course.students.where(:course_group_id => exercise_setting.course_group_id) exercise_users = exercise.exercise_users.where(:user_id => users.pluck(:user_id)) From d0942590513334483e89139c51333c6496afe0bd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 21 Jun 2019 20:51:37 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=88=86=E6=95=B0=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 6 - app/controllers/concerns/git_helper.rb | 6 + app/helpers/exercises_helper.rb | 145 ++++++++++++---------- 3 files changed, 86 insertions(+), 71 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 98dd577a1..d1aac6f3a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -349,12 +349,6 @@ class ApplicationController < ActionController::Base end end - #实训题的关卡url初始化 - def challenge_path(path) - cha_path = path.present? ? path.split(";") : [] - cha_path.reject(&:blank?)[0].try(:strip) - end - # 适用与已经用url_safe编码后,回调字符串形式 def tran_base64_decode64(str) s_size = str.size % 4 diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 0d8c91a55..f6724a654 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -49,4 +49,10 @@ module GitHelper GitService.fork_repository(repo_path: original_rep_path, fork_repository_path: (new_repo_name + ".git")) container.update_attributes!(:repo_name => new_repo_name) end + + #实训题的关卡url初始化 + def challenge_path(path) + cha_path = path.present? ? path.split(";") : [] + cha_path.reject(&:blank?)[0].try(:strip) + end end \ No newline at end of file diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 1b201d875..67eb373ef 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -352,7 +352,7 @@ module ExercisesHelper score2 = 0.0 #填空题 score5 = 0.0 #实训题 ques_stand = [] #问题是否正确 - exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers) + exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers,:exercise_shixun_challenges) exercise_questions.each do |q| if q.question_type != 5 answers_content = q.exercise_answers.search_answer_users("user_id",user.id) #学生的答案 @@ -360,84 +360,99 @@ module ExercisesHelper answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user.id) #学生的答案 end if q.question_type <= 2 #为选择题或判断题时 - answer_choice_array = [] - answers_content.each do |a| - answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 - end - user_answer_content = answer_choice_array.sort - standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 - if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 - if standard_answer.count > 0 - multi_each_score = (q.question_score / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 - else - multi_each_score = 0.0 + if answers_content.present? #学生有回答时 + answer_choice_array = [] + answers_content.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 end - answers_content.update_all(:score => multi_each_score) - score1 = score1 + q.question_score - end - elsif q.question_type == 3 #填空题 - null_standard_answer = q.exercise_standard_answers - standard_answer_array = null_standard_answer.select(:exercise_choice_id,:answer_text) - standard_answer_ids = standard_answer_array.pluck(:exercise_choice_id).reject(&:blank?).uniq #标准答案的exercise_choice_id数组 - standard_answer_count = standard_answer_ids.count - if standard_answer_count > 0 #存在标准答案时才有分数 - each_standard_score = (q.question_score.to_f / standard_answer_count).round(1) #每一空的得分 - else - each_standard_score = 0.0 - end - if q.is_ordered - answers_content.each do |u| - i_standard_answer = standard_answer_array.where(exercise_choice_id:u.exercise_choice_id).pluck(:answer_text).reject(&:blank?).map!(&:downcase) #该选项的全部标准答案 - if i_standard_answer.include?(u.answer_text.downcase) #该空的标准答案包含用户的答案才有分数 - u.update_attribute("score",each_standard_score) - score2 = score2 + each_standard_score + user_answer_content = answer_choice_array.sort + standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + if standard_answer.count > 0 + q_score_1 = (q.question_score / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 + else + q_score_1 = 0.0 end + answers_content.update_all(:score => q_score_1) + score1 = score1 + q.question_score end else - st_answer_text = standard_answer_array.pluck(:answer_text).reject(&:blank?).map!(&:downcase) - answers_content.each do |u| - u_answer_text = u.answer_text.downcase - if st_answer_text.include?(u_answer_text) #只要标准答案包含用户的答案,就有分数。同时,下一次循环时,就会删除该标准答案。防止用户的相同答案获分 - u.update_attribute("score",each_standard_score) - score2 = score2 + each_standard_score - st_answer_text.delete(u_answer_text) + score1 += 0.0 + end + elsif q.question_type == 3 #填空题 + if answers_content.present? + null_standard_answer = q.exercise_standard_answers + standard_answer_array = null_standard_answer.select(:exercise_choice_id,:answer_text) + standard_answer_ids = standard_answer_array.pluck(:exercise_choice_id).reject(&:blank?).uniq #标准答案的exercise_choice_id数组 + standard_answer_count = standard_answer_ids.count + if standard_answer_count > 0 #存在标准答案时才有分数 + q_score_2 = (q.question_score.to_f / standard_answer_count) #每一空的得分 + else + q_score_2 = 0.0 + end + if q.is_ordered + answers_content.each do |u| + i_standard_answer = standard_answer_array.where(exercise_choice_id:u.exercise_choice_id).pluck(:answer_text).reject(&:blank?).map!(&:downcase) #该选项的全部标准答案 + if i_standard_answer.include?(u.answer_text.downcase) #该空的标准答案包含用户的答案才有分数 + u.update_column('score',q_score_2) + score2 = score2 + q_score_2 + end + end + else + st_answer_text = standard_answer_array.pluck(:answer_text).reject(&:blank?).map!(&:downcase) + answers_content.each do |u| + u_answer_text = u.answer_text.downcase + if st_answer_text.include?(u_answer_text) #只要标准答案包含用户的答案,就有分数。同时,下一次循环时,就会删除该标准答案。防止用户的相同答案获分 + u.update_column("score",q_score_2) + score2 = score2 + q_score_2 + st_answer_text.delete(u_answer_text) + end end end + else + score2 += 0.0 end elsif q.question_type == 5 #实训题时,主观题这里不评分 - q.exercise_shixun_challenges.each do |exercise_cha| - game = Game.user_games(user.id,exercise_cha.challenge_id).first #当前用户的关卡 - if game.present? - exercise_cha_score = 0 - answer_status = 0 - cha_path = challenge_path exercise_cha.challenge.path - if game.status == 2 && game.final_score >= 0 - exercise_cha_score = game.real_score exercise_cha.question_score #每一关卡的得分 - answer_status = 1 - end - if exercise_cha.exercise_shixun_answers.search_shixun_answers("user_id",user.id).blank? #把关卡的答案存入试卷的实训里 - game_challenge = game.game_codes.search_challenge_path(cha_path).first - if game_challenge.present? - game_code = game_challenge - code = game_code.try(:new_code) + if answers_content.present? + q.exercise_shixun_challenges.each do |exercise_cha| + game = Game.user_games(user.id,exercise_cha.challenge_id).first #当前用户的关卡 + if game.present? + exercise_cha_score = 0.0 + answer_status = 0 + cha_path = challenge_path exercise_cha.challenge.path + if game.status == 2 && game.final_score >= 0 + exercise_cha_score = exercise_cha.question_score #每一关卡的得分 + answer_status = 1 + end + ex_shixun_answer_content = answers_content.where(exercise_shixun_challenge_id: exercise_cha.id) + if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + game_challenge = game.game_codes.search_challenge_path(cha_path).first + if game_challenge.present? + game_code = game_challenge + code = game_code.try(:new_code) + else + code = git_fle_content(exercise_cha.shixun.repo_path,cha_path) + end + sx_option = { + :exercise_question_id => q.id, + :exercise_shixun_challenge_id => exercise_cha.id, + :user_id => user.id, + :score => exercise_cha_score, + :answer_text => code, + :status => answer_status + } + ExerciseShixunAnswer.create(sx_option) else - code = git_fle_content(exercise_cha.shixun.repo_path,cha_path) + ex_shixun_answer_content.first.update_column('score',exercise_cha_score) end - sx_option = { - :exercise_question_id => q.id, - :exercise_shixun_challenge_id => exercise_cha.id, - :user_id => user.id, - :score => exercise_cha_score, - :answer_text => code, - :status => answer_status - } - ExerciseShixunAnswer.create(sx_option) + score5 += exercise_cha_score end - score5 += exercise_cha_score end + else + score5 += 0.0 end end - user_scores = answers_content.score_reviewed.pluck(:score).sum + user_scores = answers_content.present? ? answers_content.score_reviewed.pluck(:score).sum : 0.0 if user_scores > 0 stand_answer = 1 else From 7135094316a7113c1d5f6dd79e1e6028fbdaff85 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 22 Jun 2019 09:12:23 +0800 Subject: [PATCH 16/25] fix reply message api --- app/controllers/messages_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 3dac97899..60a1c171c 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -51,7 +51,8 @@ class MessagesController < ApplicationController def reply return normal_status(2, "回复内容不能为空") if params[:content].blank? - @reply = Message.create!(board: @message.board, root: @message.root, author: current_user, parent: @message, + @reply = Message.create!(board: @message.board, root_id: @message.root_id || @message.id, + author: current_user, parent: @message, message_detail_attributes: { content: params[:content] }) From 2420ce6a1ba0491b23a25a8e9fd9efe95e8ae52b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 09:29:57 +0800 Subject: [PATCH 17/25] fix bug --- app/tasks/exercise_publish_task.rb | 2 -- app/views/exercise_questions/_exercise_questions.json.jbuilder | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/tasks/exercise_publish_task.rb b/app/tasks/exercise_publish_task.rb index 6f18dc403..282968755 100644 --- a/app/tasks/exercise_publish_task.rb +++ b/app/tasks/exercise_publish_task.rb @@ -84,8 +84,6 @@ class ExercisePublishTask end total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score total_score = s_score + total_score_subjective_score - Rails.logger.info("log-------------total_score-------------------total_scoretotal_scoretotal_scoretotal_score#{total_score}") - commit_option = { :status => 1, :commit_status => 1, diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 10dc46abf..b5a01ed06 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -1,5 +1,6 @@ json.question_id question.id -json.question_number question.question_number +# json.question_number question.question_number +json.q_position question.question_number json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s From 7ddd0c4f5d45bf07be04a03e306b12033a88b2c3 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 22 Jun 2019 09:42:39 +0800 Subject: [PATCH 18/25] fix user shixuns list filter bug and n+1 bug --- app/controllers/users/shixuns_controller.rb | 4 ++++ app/decorators/shixun_decorator.rb | 4 ---- app/models/shixun.rb | 4 ++++ app/services/users/shixun_service.rb | 2 +- app/views/users/shixuns/shared/_shixun.json.jbuilder | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/users/shixuns_controller.rb b/app/controllers/users/shixuns_controller.rb index c4c0d4c07..7b840a0a1 100644 --- a/app/controllers/users/shixuns_controller.rb +++ b/app/controllers/users/shixuns_controller.rb @@ -4,6 +4,10 @@ class Users::ShixunsController < Users::BaseController @count = shixuns.count @shixuns = paginate(shixuns.includes(:first_tag_repertoire), special: true) + + ids = @shixuns.map(&:id) + @finished_challenges_count_map = Game.joins(:myshixun).where(user_id: observed_user.id, status: 2) + .where(myshixuns: { shixun_id: ids }).group('myshixuns.shixun_id').count end private diff --git a/app/decorators/shixun_decorator.rb b/app/decorators/shixun_decorator.rb index 50e2e27eb..4b7a0714a 100644 --- a/app/decorators/shixun_decorator.rb +++ b/app/decorators/shixun_decorator.rb @@ -1,8 +1,4 @@ module ShixunDecorator - def finished_challenges_count(user) - Game.joins(:myshixun).where(user_id: user.id, status: 2, myshixuns: { shixun_id: id }).count - end - def human_status I18n.t("shixun.status.#{status}") end diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 9ccefca92..556a4400f 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -233,4 +233,8 @@ class Shixun < ApplicationRecord shixun_members.where(role: [1, 2]).exists?(user_id: user.id) end + + def finished_challenges_count(user) + Game.joins(:myshixun).where(user_id: user.id, status: 2, myshixuns: { shixun_id: id }).count + end end diff --git a/app/services/users/shixun_service.rb b/app/services/users/shixun_service.rb index b5e5586f1..4730a5777 100644 --- a/app/services/users/shixun_service.rb +++ b/app/services/users/shixun_service.rb @@ -58,7 +58,7 @@ class Users::ShixunService when 'passed' then 1 when 'processing' then 0 end - relations.where(myshixuns: { status: status }) if status + relations = relations.where(myshixuns: { status: status }) if status relations end diff --git a/app/views/users/shixuns/shared/_shixun.json.jbuilder b/app/views/users/shixuns/shared/_shixun.json.jbuilder index 13cc3a9ee..8427ead58 100644 --- a/app/views/users/shixuns/shared/_shixun.json.jbuilder +++ b/app/views/users/shixuns/shared/_shixun.json.jbuilder @@ -6,4 +6,4 @@ json.name shixun.name json.status shixun.status json.human_status shixun.human_status json.challenges_count shixun.challenges_count -json.finished_challenges_count shixun.finished_challenges_count(user) \ No newline at end of file +json.finished_challenges_count @finished_challenges_count_map&.fetch(shixun.id, 0) || shixun.finished_challenges_count(user) \ No newline at end of file From ab6c1bd682d153ff779b2a1fff97e38176d1c24f Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 22 Jun 2019 09:45:42 +0800 Subject: [PATCH 19/25] fix user projects filter bug --- app/services/users/subject_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/users/subject_service.rb b/app/services/users/subject_service.rb index e0d8377c2..7e3eaaa81 100644 --- a/app/services/users/subject_service.rb +++ b/app/services/users/subject_service.rb @@ -65,7 +65,7 @@ class Users::SubjectService when 'finished' then subjects.having('finished = 1').map(&:id) end - relations.where(id: subject_ids) if subject_ids.present? + relations = relations.where(id: subject_ids) if subject_ids.present? relations end @@ -75,7 +75,7 @@ class Users::SubjectService when 'applying' then 1 when 'published' then 2 end - relations.where(status: status) if status + relations = relations.where(status: status) if status relations end From 130a39ed5b2eac847ed6116ca8e49932d3ac4f5f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 09:46:14 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 7 ++++--- app/models/homework_common.rb | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index e4ade6e9f..a2f5add51 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -165,7 +165,7 @@ class Course < ApplicationRecord all_course_module_types.each do |type| hidden_value = course_module_types.include?(type) ? 0 : 1 - course_module = get_course_module_by_type(type, self.id) + course_module = course_modules.where(module_type: type).first course_module.update_attribute(:hidden, hidden_value) if course_module.present? end end @@ -174,8 +174,9 @@ class Course < ApplicationRecord %w[activity shixun_homework common_homework group_homework graduation exercise poll attachment board course_group] end - def get_course_module_by_type(type, course_id) - CourseModule.where(course_id: course_id, module_type: type).first + def get_course_module_by_type(type) + #CourseModule.where(course_id: course_id, module_type: type).first + self.course_modules.where(module_type: type).first end # 创建课程讨论区 diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index d67b6e0fd..c3bfd2dd9 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -170,7 +170,7 @@ class HomeworkCommon < ApplicationRecord #删除时更新题库中的引用数 def update_homework_bank_quotes - old_banks = HomeworkBank.where(homework_common_id: self.id) + old_banks = self.homework_bank unless old_banks.blank? old_banks.each do |bank| bank.update_attributes(quotes: (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0, homework_common_id: nil) @@ -243,10 +243,15 @@ class HomeworkCommon < ApplicationRecord end def min_group_publish_time - HomeworkGroupSetting.where("homework_common_id = #{self.id} and publish_time is not null").pluck(:publish_time).min + #HomeworkGroupSetting.where("homework_common_id = #{self.id} and publish_time is not null").pluck(:publish_time).min + # 可以使用includes + self.homework_group_settings.where("publish_time is not null").pluck(:publish_time).min end def max_group_end_time - HomeworkGroupSetting.where("homework_common_id = #{self.id} and end_time is not null").pluck(:end_time).max + #HomeworkGroupSetting.where("homework_common_id = #{self.id} and end_time is not null").pluck(:end_time).max + # 可以使用includes + self.homework_group_settings.where("end_time is not null").pluck(:end_time).max + end end From e318ee25b5707c9c66f57aa9242b115bbd0a56c6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 09:53:35 +0800 Subject: [PATCH 21/25] fix bug --- .../exercise_questions/_exercise_questions.json.jbuilder | 2 +- app/views/exercises/start_answer.json.jbuilder | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index b5a01ed06..7a05c2e11 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -1,6 +1,6 @@ json.question_id question.id # json.question_number question.question_number -json.q_position question.question_number +json.q_position ques_position.present? ? ques_position : question.question_number json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s diff --git a/app/views/exercises/start_answer.json.jbuilder b/app/views/exercises/start_answer.json.jbuilder index fb9916696..4cc461d56 100644 --- a/app/views/exercises/start_answer.json.jbuilder +++ b/app/views/exercises/start_answer.json.jbuilder @@ -36,9 +36,9 @@ json.partial! "exercises/exercise_scores" json.exercise_questions do json.array! @exercise_all_questions do |q| question = q[:question] - ques_position = q[:ques_number] #问题的序号,当问题为随机时,重新更新后的问题序号 + # ques_position = q[:ques_number] #问题的序号,当问题为随机时,重新更新后的问题序号 question_info = get_exercise_question_info(question,@exercise,@exercise_user_current,@ex_answerer.id) - json.q_position ques_position + # json.q_position q[:ques_number] #问题的序号,当问题为随机时,重新更新后的问题序号 if @t_user_exercise_status == 3 this_answer_status = "0.0" user_score = "0.0" @@ -58,6 +58,7 @@ json.exercise_questions do user_answer: question_info[:answered_content], choices:question.exercise_choices, exercise_type:3, - shixun_type:question_info[:shixun_type] + shixun_type:question_info[:shixun_type], + ques_position: q[:ques_number] end end \ No newline at end of file From 2ec730e4fd1772250b1ea8f06b9cbc39b10b6e32 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 10:01:13 +0800 Subject: [PATCH 22/25] fix bug --- app/views/exercise_questions/edit.json.jbuilder | 3 ++- app/views/exercise_questions/show.json.jbuilder | 3 ++- app/views/exercises/_user_exercise_info.json.jbuilder | 3 ++- app/views/exercises/blank_exercise.json.jbuilder | 3 ++- app/views/exercises/edit.json.jbuilder | 3 ++- app/views/exercises/show.json.jbuilder | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/exercise_questions/edit.json.jbuilder b/app/views/exercise_questions/edit.json.jbuilder index 32567d813..35db720c7 100644 --- a/app/views/exercise_questions/edit.json.jbuilder +++ b/app/views/exercise_questions/edit.json.jbuilder @@ -5,4 +5,5 @@ json.partial! "exercise_questions/exercise_questions", choices:@exercise_choices, shixun_challenges: @exercise_question_shixun, exercise_type:1, - user_answer:[] \ No newline at end of file + user_answer:[], + ques_position:nil \ No newline at end of file diff --git a/app/views/exercise_questions/show.json.jbuilder b/app/views/exercise_questions/show.json.jbuilder index e8662a611..c27fe21a5 100644 --- a/app/views/exercise_questions/show.json.jbuilder +++ b/app/views/exercise_questions/show.json.jbuilder @@ -5,4 +5,5 @@ json.partial! "exercise_questions/exercise_questions", choices:@exercise_choices, shixun_challenges: @exercise_question_shixun, exercise_type:1, - user_answer:[] + user_answer:[], + ques_position:nil diff --git a/app/views/exercises/_user_exercise_info.json.jbuilder b/app/views/exercises/_user_exercise_info.json.jbuilder index a3b7b208c..5b5d0c725 100644 --- a/app/views/exercises/_user_exercise_info.json.jbuilder +++ b/app/views/exercises/_user_exercise_info.json.jbuilder @@ -62,7 +62,8 @@ json.exercise_questions do shixun_challenges: q.exercise_shixun_challenges, exercise_type: ex_type, user_answer: user_ques_answers[:answered_content], - shixun_type: user_ques_answers[:shixun_type] + shixun_type: user_ques_answers[:shixun_type], + ques_position:nil if user_ques_comments.count > 0 json.question_comments do json.partial! "exercises/exercise_comments", question_comment:user_ques_answers[:question_comment].first diff --git a/app/views/exercises/blank_exercise.json.jbuilder b/app/views/exercises/blank_exercise.json.jbuilder index 631f0dcb3..16b5449fb 100644 --- a/app/views/exercises/blank_exercise.json.jbuilder +++ b/app/views/exercises/blank_exercise.json.jbuilder @@ -11,7 +11,8 @@ json.exercise_questions do choices:q.exercise_choices, shixun_challenges: q.exercise_shixun_challenges, exercise_type:2, - user_answer:[] + user_answer:[], + ques_position:nil end end diff --git a/app/views/exercises/edit.json.jbuilder b/app/views/exercises/edit.json.jbuilder index 61ec71db5..71a6fcf07 100644 --- a/app/views/exercises/edit.json.jbuilder +++ b/app/views/exercises/edit.json.jbuilder @@ -15,7 +15,8 @@ json.exercise_questions do shixun_challenges: q.exercise_shixun_challenges, exercise_type:1, user_answer:[], - shixun_type:0 + shixun_type:0, + ques_position:nil end end diff --git a/app/views/exercises/show.json.jbuilder b/app/views/exercises/show.json.jbuilder index 8f6517c2c..d92eebeab 100644 --- a/app/views/exercises/show.json.jbuilder +++ b/app/views/exercises/show.json.jbuilder @@ -18,7 +18,8 @@ json.exercise_questions do shixun_challenges: q.exercise_shixun_challenges, exercise_type:1, user_answer:[], - shixun_type:0 + shixun_type:0, + ques_position:nil end end From 5d3c49f1972f643f3fa106395fbe221a32e9c7d9 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 22 Jun 2019 10:19:56 +0800 Subject: [PATCH 23/25] fix user homepage info api --- app/decorators/user_decorator.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index 0ee9a4b43..a0f9f7fdd 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -39,19 +39,19 @@ module UserDecorator apply = ApplyAction.order(created_at: :desc).find_by(user_id: id, container_type: 'TrialAuthorization') - apply && !apply.status.zero? + apply.present? && !apply.status.zero? end # 是否已经签到 def attendance_signed? attendance = Attendance.find_by(user_id: id) - attendance && Util.days_between(Time.zone.now, attendance.created_at).zero? + attendance.present? && Util.days_between(Time.zone.now, attendance.created_at).zero? end # 明日签到金币 def tomorrow_attendance_gold - Attendance.find_by(user_id: id)&.next_gold + Attendance.find_by(user_id: id)&.next_gold || 50 end # ----------- 账号管理 ------------- From 2c7f9f9f77106ca40da3ac59f84d17a3a307c287 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 10:21:21 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=AF=95=E8=AE=BE=E4=BD=9C=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=A2=9E=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/helpers/graduation_tasks_helper.rb | 16 ++++++++++++++++ app/models/graduation_task.rb | 2 ++ app/views/graduation_tasks/index.json.jbuilder | 7 ++++--- .../graduation_tasks/tasks_list.json.jbuilder | 10 ++++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/helpers/graduation_tasks_helper.rb b/app/helpers/graduation_tasks_helper.rb index a5f05d623..b9039544d 100644 --- a/app/helpers/graduation_tasks_helper.rb +++ b/app/helpers/graduation_tasks_helper.rb @@ -131,4 +131,20 @@ module GraduationTasksHelper end end end + + # 阶段剩余时间 + def task_left_time task + if task.publish_time && task.publish_time < Time.now + if task.end_time > Time.now + status = "剩余提交时间" + time = "#{how_much_time(task.end_time)}" + else + if task.allow_late && task.late_time && task.late_time >= Time.now + status = "剩余补交时间" + time = "#{how_much_time(task.late_time)}" + end + end + end + {status: status, time: time} + end end diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb index 8d89da693..d85f9782d 100644 --- a/app/models/graduation_task.rb +++ b/app/models/graduation_task.rb @@ -168,6 +168,8 @@ class GraduationTask < ApplicationRecord end end + + # 是否具有分组 def have_grouping? self.task_type == 2 diff --git a/app/views/graduation_tasks/index.json.jbuilder b/app/views/graduation_tasks/index.json.jbuilder index 80780b209..7fcececd9 100644 --- a/app/views/graduation_tasks/index.json.jbuilder +++ b/app/views/graduation_tasks/index.json.jbuilder @@ -12,10 +12,11 @@ json.tasks @tasks.each do |task| json.name task.name json.private_icon !task.is_public json.task_status task.status #6.12 -hs - json.status task_curr_status(task, @course)[:status] - json.status_time task_curr_status(task, @course)[:time] + task_curr_status = task_curr_status(task, @course) + json.status task_curr_status[:status] + json.status_time task_curr_status[:time] - unless task_curr_status(task, @course)[:status].include?("未发布") + unless task_curr_status[:status].include?("未发布") json.commit_count grduationwork_count task, 1 json.uncommit_count grduationwork_count task, 0 end diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index 5868be4fb..a0cffc41b 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -26,8 +26,14 @@ if @task.published? || @user_course_identity < Course::STUDENT # 是否具有分组 json.have_grouping @task.have_grouping? - json.work_count @work_count - json.all_work_count @all_work_count + if @user_course_identity == Course::STUDENT + json.commit_count grduationwork_count @task, 1 + json.uncommit_count grduationwork_count @task, 0 + json.left_time task_left_time @task + else + json.work_count @work_count + json.all_work_count @all_work_count + end # 学生数据 json.work_lists do json.array! @work_list do |work| From c216cfd44b785c1506a040eb045e44762766a8ba Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 10:35:43 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=88=9B=E5=BB=BA=E5=88=99=E5=92=8C=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E5=AE=9E=E8=AE=AD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/show_right.json.jbuilder | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/shixuns/show_right.json.jbuilder b/app/views/shixuns/show_right.json.jbuilder index e3414df55..fe3c5d0f5 100644 --- a/app/views/shixuns/show_right.json.jbuilder +++ b/app/views/shixuns/show_right.json.jbuilder @@ -1,6 +1,6 @@ -# json.partial! 'shixuns/right', locals: { shixun: @shixun } +json.partial! 'shixuns/right', locals: { shixun: @shixun } -#json.follow follow?(@shixun.owner, User.current) -#json.fans_count @fans_count -#json.followed_count @followed_count +json.follow follow?(@shixun.owner, User.current) +json.fans_count @fans_count +json.followed_count @followed_count json.user_shixuns_count @user_own_shixuns