Merge branch 'dev_course' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_course

dev_course
daiao 6 years ago
commit 523b646a4c

@ -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]
})

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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,

@ -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

@ -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)
json.finished_challenges_count @finished_challenges_count_map&.fetch(shixun.id, 0) || shixun.finished_challenges_count(user)
Loading…
Cancel
Save