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

dev_forum
jingquan huang 5 years ago
commit e40e1d9965

@ -10,17 +10,20 @@ class DiscussesController < ApplicationController
if current_user.admin?
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
disscusses = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s,
:root_id => nil).joins(challenge: :games)
.where("discusses.user_id = games.user_id").select("discusses.*, games.identifier")
:root_id => nil)
else
disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and
(discusses.hidden = :hidden or discusses.user_id = :user_id)",
{dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id})
.joins(challenge: :games).where("discusses.user_id = games.user_id").select("discusses.*, games.identifier")
@disscuss_count = disscusses.count("discusses.id")
end
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset)
@manger = @container.has_manager?(current_user)
if @manger
@discusses = disscusses.limit(LIMIT).joins("left join games on discusses.challenge_id = games.challenge_id and discusses.user_id = games.user_id")
.select("discusses.*, games.identifier").includes(:user, :praise_treads).offset(offset)
else
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset)
end
@current_user = current_user
end

@ -55,6 +55,8 @@ class GraduationTasksController < ApplicationController
page = params[:page] || 1
limit = params[:limit] || 20
@work = @task.graduation_works.where(user_id: current_user.id)
@students = @course.students
@assign_power = @user_course_identity < Course::STUDENT && @task.cross_comment && @task.comment_status == 2
#end_time @task.allow_late ? @task.late_time : @task.end_time
# 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品
if @task.published? && (@user_course_identity < Course::STUDENT ||
@ -123,8 +125,6 @@ class GraduationTasksController < ApplicationController
@work_count = @work_list.count
@work_excel = @work_list
@work_list = @work_list.page(page).per(limit)
@students = @course.students
@assign_power = @user_course_identity < Course::STUDENT && @task.cross_comment && @task.comment_status == 2
if params[:format] == "xlsx"
complete_works = @work_excel.where("work_status > 0").size

@ -129,7 +129,7 @@ class ShixunsController < ApplicationController
select m.user_id, u.login, u.lastname, m.updated_at,
(select sum(cost_time) from games g where g.myshixun_id = m.id) as time,
(select sum(final_score) from games g where g.myshixun_id = m.id) as score
from (myshixuns m join users u on m.user_id = u.id) where m.shixun_id = #{@shixun.id} and m.status = 1
from (users u left join myshixuns m on m.user_id = u.id) where m.shixun_id = #{@shixun.id} and m.status = 1
order by score desc, time asc limit 10
"
@myshixuns = Myshixun.find_by_sql(sql)

@ -25,13 +25,13 @@ class SubjectsController < ApplicationController
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
'subjects'.'hidden' = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%'
AND `subjects`.`repertoire_id` = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
else
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
`subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%'
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%'
GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
end
else

@ -7,10 +7,10 @@ json.time time_from_now(discuss.created_at)
json.position discuss.position
json.shixun_id discuss.dis_id
json.hidden discuss.hidden
json.manage current_user.manager_of_shixun?(container)
json.manage @manger
json.reward discuss.reward
#json.game_url discuss.game_url(container, current_user)
json.game_url "/tasks/#{discuss.identifier}" if @manger
json.game_url "/tasks/#{discuss.identifier}" if @manger && !children
# 主贴和回复有一些不同点
if discuss.parent_id
json.can_delete discuss.can_deleted?(current_user)

@ -1,8 +1,8 @@
json.disscuss_count @disscuss_count
json.all @current_user.admin?
json.comments @discusses do |discuss|
json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user }
json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user, children: false}
json.children discuss.child_discuss(current_user) do |c_d|
json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user }
json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user, children: true }
end
end

Loading…
Cancel
Save