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

dev_aliyun_beta
杨树林 6 years ago
commit 256649d53a

@ -18,8 +18,8 @@ class Users::QuestionBanksController < Users::BaseController
def load_question_banks_solve_count def load_question_banks_solve_count
question_bank_ids = @question_banks.map(&:id) question_bank_ids = @question_banks.map(&:id)
@solve_count_map = @solve_count_map =
case params[:category] case params[:object_type]
when 'common', 'group' then when 'normal', 'group' then
StudentWork.where(is_delete: false, work_status: [1, 2, 3]).joins(:homework_common) StudentWork.where(is_delete: false, work_status: [1, 2, 3]).joins(:homework_common)
.where(homework_commons: { homework_bank_id: question_bank_ids }) .where(homework_commons: { homework_bank_id: question_bank_ids })
.group('homework_commons.homework_bank_id').count .group('homework_commons.homework_bank_id').count
@ -42,14 +42,14 @@ class Users::QuestionBanksController < Users::BaseController
end end
def query_params def query_params
params.permit(:type, :category, :course_list_id, :sort_by, :sort_direction) params.permit(:type, :object_type, :course_list_id, :sort_by, :sort_direction)
end end
def check_query_params! def check_query_params!
params[:type] = 'personal' if params[:type].blank? || !%w(personal publicly).include?(params[:type]) params[:type] = 'personal' if params[:type].blank? || !%w(personal publicly).include?(params[:type])
if params[:category].blank? || !%w(common group exercise poll gtask gtopic).include?(params[:category]) if params[:object_type].blank? || !%w(normal group exercise poll gtask gtopic).include?(params[:object_type])
params[:category] = 'common' params[:object_type] = 'normal'
end end
if params[:sort_by].blank? || !%w(updated_at name contributor).include?(params[:sort_by]) if params[:sort_by].blank? || !%w(updated_at name contributor).include?(params[:sort_by])

@ -22,8 +22,8 @@ class Users::QuestionBankService
course_lists = CourseList.joins(relation_name).where.not(relation_name => { id: nil }) course_lists = CourseList.joins(relation_name).where.not(relation_name => { id: nil })
category_condition = category_condition =
case params[:category] case params[:object_type]
when 'common' then { homework_type: 1 } when 'normal' then { homework_type: 1 }
when 'group' then { homework_type: 3 } when 'group' then { homework_type: 3 }
when 'exercise' then { container_type: 'Exercise' } when 'exercise' then { container_type: 'Exercise' }
when 'poll' then { container_type: 'Poll' } when 'poll' then { container_type: 'Poll' }
@ -47,8 +47,8 @@ class Users::QuestionBankService
def class_name def class_name
@_class_name ||= begin @_class_name ||= begin
case params[:category] case params[:object_type]
when 'common', 'group' then 'HomeworkBank' when 'normal', 'group' then 'HomeworkBank'
when 'exercise', 'poll' then 'ExerciseBank' when 'exercise', 'poll' then 'ExerciseBank'
when 'gtask' then 'GtaskBank' when 'gtask' then 'GtaskBank'
when 'gtopic' then 'GtopicBank' when 'gtopic' then 'GtopicBank'
@ -58,8 +58,8 @@ class Users::QuestionBankService
end end
def category_filter(relations) def category_filter(relations)
case params[:category] case params[:object_type]
when 'common' then when 'normal' then
relations.where(homework_type: 1) relations.where(homework_type: 1)
when 'group' then when 'group' then
relations.where(homework_type: 3) relations.where(homework_type: 3)

@ -0,0 +1,11 @@
class MigrateCourseGroupPosition < ActiveRecord::Migration[5.2]
def change
Course.all.each do |course|
if course.course_groups.exists?(position: 0)
course.course_groups.each_with_index do |group, index|
group.update_attributes(position: index+1)
end
end
end
end
end
Loading…
Cancel
Save