毕业设计的勾选

dev_course
cxt 5 years ago
parent ea2de283d9
commit 7833d10cae

@ -913,7 +913,7 @@ class CoursesController < ApplicationController
def left_banner def left_banner
@user = current_user @user = current_user
@is_teacher = @user.teacher_of_course?(@course) @is_teacher = @user.teacher_of_course?(@course)
@course_modules = @course.course_modules.where.not(module_type: "activity").where(hidden: 0) @course_modules = @course.course_modules.where(hidden: 0)
@hidden_modules = @course.course_modules.where(hidden: 1) @hidden_modules = @course.course_modules.where(hidden: 1)
@second_category_type = ["shixun_homework", "graduation", "attachment", "board", "course_group"] @second_category_type = ["shixun_homework", "graduation", "attachment", "board", "course_group"]
end end

@ -7,7 +7,7 @@ class Course < ApplicationRecord
has_many :course_infos, dependent: :destroy has_many :course_infos, dependent: :destroy
# 课堂左侧导航栏的模块 # 课堂左侧导航栏的模块
has_many :course_modules, -> {where hidden: 0}, dependent: :destroy has_many :course_modules, dependent: :destroy
has_many :board_course_modules, -> { board_module }, class_name: "CourseModule" has_many :board_course_modules, -> { board_module }, class_name: "CourseModule"
has_many :attachment_course_modules, -> { attachment_module }, class_name: "CourseModule" has_many :attachment_course_modules, -> { attachment_module }, class_name: "CourseModule"
has_many :common_course_modules, -> { common_homework_module }, class_name: "CourseModule" has_many :common_course_modules, -> { common_homework_module }, class_name: "CourseModule"

@ -7,6 +7,7 @@ class CourseModule < ApplicationRecord
validates :module_name, length: { maximum: 20 } validates :module_name, length: { maximum: 20 }
scope :not_hidden, -> { where(hidden: 0) }
scope :graduation_module, -> { where(module_type: "graduation") } scope :graduation_module, -> { where(module_type: "graduation") }
scope :graduation_module_not_hidden, -> { graduation_module.where(hidden: 0) } scope :graduation_module_not_hidden, -> { graduation_module.where(hidden: 0) }
scope :board_module, -> { where(module_type: 'board') } scope :board_module, -> { where(module_type: 'board') }

@ -12,7 +12,7 @@ json.courses do
json.is_public course.is_public json.is_public course.is_public
json.is_accessible course.is_public == 1 || @user.course_identity(course) < Course::NORMAL json.is_accessible course.is_public == 1 || @user.course_identity(course) < Course::NORMAL
json.is_end course.is_end json.is_end course.is_end
json.first_category_url module_url(course.course_modules.first, course) json.first_category_url module_url(course.course_modules.not_hidden.first, course)
end end
end end
json.courses_count @courses_count json.courses_count @courses_count

@ -4,7 +4,7 @@ json.members_count course.members_count
json.homework_commons_count course.homework_commons_count json.homework_commons_count course.homework_commons_count
json.attachments_count course.attachments.count json.attachments_count course.attachments.count
json.first_category_url module_url(course.course_modules.where.not(module_type: "activity").where(hidden: 0).order(position: :desc).first, course) json.first_category_url module_url(course.course_modules.where(hidden: 0).order(position: :desc).first, course)
json.is_public course.is_public json.is_public course.is_public
json.can_visited observed_logged_user? || course.can_visited? json.can_visited observed_logged_user? || course.can_visited?

Loading…
Cancel
Save