socialforge/app/helpers/syllabuses_helper.rb

73 lines
1.3 KiB
Ruby

# encoding: utf-8
module SyllabusesHelper
def get_syllabuses_by_tag(tag_name)
Syllabus.tagged_with(tag_name).order('updated_at desc')
end
def teacher_count syllabus
count = 0
courses = syllabus.courses
unless courses.empty?
courses.each do |c|
count += TeacherAndAssistantCount c
end
end
count
end
def student_count syllabus
count = 0
courses = syllabus.courses
unless courses.empty?
courses.each do |c|
count += studentCount c
end
end
count
end
def file_count syllabus
count = 0
courses = syllabus.courses
unless courses.empty?
courses.each do |c|
count += visable_attachemnts_incourse(c).count
end
end
count
end
#课程性质下拉框
def syllabus_type
type = []
option1 = []
option2 = []
option3 = []
option4 = []
option5 = []
option6 = []
option1 << "请选择"
option1 << 0
option2 << "公共必修课"
option2 << 1
option3 << "学科必修课"
option3 << 2
option4 << "专业选修课"
option4 << 3
option5 << "实践必修课"
option5 << 4
option6 << "实践选修课"
option6 << 5
type << option1
type << option2
type << option3
type << option4
type << option5
type << option6
type
end
end