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

dev_forum
daiao 5 years ago
commit dea4278de6

@ -37,7 +37,7 @@ class GraduationTasksController < ApplicationController
@all_count = @course.graduation_tasks.size @all_count = @course.graduation_tasks.size
@published_count = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").size @published_count = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").size
@task_count = @tasks.size @task_count = @tasks.size
@tasks = @tasks.reorder("#{default_order}").page(page).per(15).includes(:graduation_works, course: [course_members: :teacher_course_groups]) @tasks = @tasks.reorder("#{default_order}").page(page).per(15).includes(:graduation_works)
end end
# 任务问答 # 任务问答
@ -72,7 +72,7 @@ class GraduationTasksController < ApplicationController
@work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension]) @work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
@all_work_count = @work_list.count @all_work_count = @work_list.count
@teachers = @course.teachers.where.not(user_id: current_user.id) @teachers = @course.teachers.where.not(user_id: current_user.id).includes(:user)
# 教师评阅搜索 0: 未评, 1 已评 # 教师评阅搜索 0: 未评, 1 已评
unless params[:teacher_comment].blank? unless params[:teacher_comment].blank?
graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id) graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id)
@ -110,9 +110,9 @@ class GraduationTasksController < ApplicationController
end end
# 排序 # 排序
rorder = params[:order].blank? ? "updated_at" : params[:order] rorder = params[:order].blank? ? "update_time" : params[:order]
b_order = params[:b_order].blank? ? "desc" : params[:b_order] b_order = params[:b_order].blank? ? "desc" : params[:b_order]
if rorder == "created_at" || rorder == "work_score" if rorder == "update_time" || rorder == "work_score"
@work_list = @work_list.order("graduation_works.#{rorder} #{b_order}") @work_list = @work_list.order("graduation_works.#{rorder} #{b_order}")
elsif rorder == "student_id" elsif rorder == "student_id"
@work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}") @work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}")
@ -123,6 +123,8 @@ class GraduationTasksController < ApplicationController
@work_count = @work_list.count @work_count = @work_list.count
@work_excel = @work_list @work_excel = @work_list
@work_list = @work_list.page(page).per(limit) @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" if params[:format] == "xlsx"
complete_works = @work_excel.where("work_status > 0").size complete_works = @work_excel.where("work_status > 0").size

@ -22,16 +22,16 @@ class SubjectsController < ApplicationController
# 最热排序 # 最热排序
if reorder == "myshixun_count" if reorder == "myshixun_count"
if select if select
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, COUNT(myshixuns.id) AS myshixun_member_count FROM myshixuns, stage_shixuns, subjects subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
WHERE myshixuns.shixun_id = stage_shixuns.shixun_id AND stage_shixuns.subject_id = subjects.id on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2 AND `subjects`.`name` like '%#{search}%' 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") AND `subjects`.`repertoire_id` = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
else else
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status,
subjects.shixuns_count, COUNT(myshixuns.id) AS myshixun_member_count FROM myshixuns, stage_shixuns, subjects subjects.shixuns_count, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
WHERE myshixuns.shixun_id = stage_shixuns.shixun_id AND stage_shixuns.subject_id = subjects.id on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
AND `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") GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
end end
else else
@ -65,9 +65,11 @@ class SubjectsController < ApplicationController
@total_count = @subjects.size @total_count = @subjects.size
if reorder != "myshixun_count" if reorder != "myshixun_count"
@subjects = @subjects.page(page).per(limit).includes(:shixuns) @subjects = @subjects.page(page).per(limit).includes(:shixuns, :repertoire)
else else
@subjects = @subjects[offset, limit] @subjects = @subjects[offset, limit]
subject_ids = @subjects.pluck(:id)
@subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, :repertoire)
end end
end end

@ -67,7 +67,7 @@ module GraduationTasksHelper
# 作品数统计type 1 已提交 0 未提交 # 作品数统计type 1 已提交 0 未提交
def grduationwork_count task, type def grduationwork_count task, type
works = task.graduation_works works = task.graduation_works
type == 1 ? works.where("work_status !=?", 0).size : works.where("work_status =?", 0).size type == 1 ? works.select{|work| work.work_status != 0}.size : works.select{|work| work.work_status == 0}.size
end end
# 普通/分组 作业作品状态数组 # 普通/分组 作业作品状态数组

@ -68,7 +68,7 @@ class GraduationWork < ApplicationRecord
# 作品是否能够分配指导老师 # 作品是否能够分配指导老师
def assign_power?(course_identity) def assign_power?(course_identity)
course_identity < Course::STUDENT && self.graduation_task.cross_comment.present? && self.graduation_task.comment_status == 2 course_identity < Course::STUDENT && graduation_task.cross_comment && graduation_task.comment_status == 2
end end
# 老师评阅分 # 老师评阅分

@ -31,7 +31,7 @@ class Subject < ApplicationRecord
# 挑战过路径的成员数 # 挑战过路径的成员数
def member_count def member_count
shixuns.sum(:myshixuns_count) shixuns.pluck(:myshixuns_count).sum
end end
def all_score def all_score

@ -1,10 +1,6 @@
json.course_identity @identity json.course_identity @identity
json.course_public @course.is_public == 1 json.course_public @course.is_public == 1
json.is_end @course.is_end json.is_end @course.is_end
json.all_count @all_count
json.published_count @published_count
json.unpublished_count @all_count - @published_count
json.task_count @task_count
json.tasks @tasks.each do |task| json.tasks @tasks.each do |task|
# task_private = @identity > Course::STUDENT && !task.is_public # task_private = @identity > Course::STUDENT && !task.is_public
@ -29,3 +25,7 @@ json.tasks @tasks.each do |task|
end end
end end
json.all_count @all_count
json.published_count @published_count
json.unpublished_count @all_count - @published_count
json.task_count @task_count

@ -34,6 +34,7 @@ if @task.published? || @user_course_identity < Course::STUDENT
json.work_count @work_count json.work_count @work_count
json.all_work_count @all_work_count json.all_work_count @all_work_count
end end
# 学生数据 # 学生数据
json.work_lists do json.work_lists do
json.array! @work_list do |work| json.array! @work_list do |work|
@ -41,7 +42,7 @@ if @task.published? || @user_course_identity < Course::STUDENT
json.user_id work.user.id json.user_id work.user.id
json.name work.user.real_name json.name work.user.real_name
json.student_id work.user.student_id json.student_id work.user.student_id
json.class_grouping_name work.class_grouping_name json.class_grouping_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name)
json.ultimate_score work.ultimate_score json.ultimate_score work.ultimate_score
if @task.have_grouping? if @task.have_grouping?
json.grouping_name work.grouping_name json.grouping_name work.grouping_name
@ -58,7 +59,7 @@ if @task.published? || @user_course_identity < Course::STUDENT
end end
json.late_penalty work.late_penalty if @task.allow_late json.late_penalty work.late_penalty if @task.allow_late
json.final_score work_final_score work, @current_user, @user_course_identity json.final_score work_final_score work, @current_user, @user_course_identity
json.assign work.assign_power?(@user_course_identity) json.assign @assign_power
json.view_work @view_work || @current_user.id == work.user_id json.view_work @view_work || @current_user.id == work.user_id
end end
end end

Loading…
Cancel
Save