diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index cec419eba..90981b52a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -51,6 +51,37 @@ class AdminController < ApplicationController end end + #管理员界面精品课程列表 + def excellent_courses + @courses = Course.where("is_excellent =? or excellent_option =?", 1, 1 ) + respond_to do |format| + format.html + end + end + + #管理员界面课程资源列表 + def course_resource_list + @resource = Attachment.where(:container_type => 'Course') + @resource = paginateHelper @resource,30 + @page = (params['page'] || 1).to_i - 1 + + respond_to do |format| + format.html + end + end + + #管理员界面項目资源列表 + def project_resource_list + @pro_resource = Attachment.where(:container_type => 'Project') + @pro_resource = paginateHelper @pro_resource,30 + @page = (params['page'] || 1).to_i - 1 + + respond_to do |format| + format.html + end + end + + def users sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 3989ad724..d98de27f6 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -71,6 +71,11 @@ module CoursesHelper project.members.count end + # 统计课程中作品的数量 + def student_works_num course + StudentWork.find_by_sql("SELECT * FROM student_works WHERE homework_common_id IN (SELECT id FROM homework_commons WHERE course_id = '#{course.id}')").count + end + # 返回教师数量,即roles表中定义的Manager def teacherCount project project ? project.members.count - studentCount(project).to_i : 0 diff --git a/app/views/admin/course_resource_list.html.erb b/app/views/admin/course_resource_list.html.erb new file mode 100644 index 000000000..4316555f7 --- /dev/null +++ b/app/views/admin/course_resource_list.html.erb @@ -0,0 +1,64 @@ +
+ 资源名称 + | ++ 资源大小 + | ++ 资源类型 + | ++ 上传时间 + | ++ 下载次数 + | ++ 上传者 + | ++ 所属课程 + | +
---|---|---|---|---|---|---|
+ <%= link_to truncate(resource.filename, :length => 18), download_named_attachment_path(resource.id, resource.filename ), :title => resource.filename,:class=>'resourcesBlack'%> + | ++ <%= number_to_human_size(resource.filesize)%> + | ++ 课程资源 + | ++ <%= format_date(resource.created_on)%> + | ++ <%= resource.downloads %> + | ++ <%= link_to(User.find(resource.author_id).realname, user_path(User.find(resource.author_id)) ) %> + | ++ <%=link_to truncate(Course.find(resource.container_id).name, :length => 10), course_path(Course.find(resource.container_id)), :title => Course.find(resource.container_id).name, :class => "hidden fl w170" %> + | +
+ 序号 + | ++ 课程名 + | ++ 主讲老师 + | ++ 学生数 + | ++ 作业数 + | ++ 作品数 + | ++ 资源数 + | ++ 帖子数 + | ++ 动态数 + | +
---|---|---|---|---|---|---|---|---|
+ <%= course.id %> + | + ++ <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> + | ++ <%= studentCount(course) %> + | ++ <%= course.homework_commons.count%> + | ++ <%= student_works_num(course) %> + | ++ <%= visable_attachemnts_incourse(course).count%> + | ++ <%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %> + + | ++ <%= course.course_activities.count%> + | +
+ 资源名称 + | ++ 资源大小 + | ++ 资源类型 + | ++ 上传时间 + | ++ 下载次数 + | ++ 上传者 + | ++ 所属项目 + | +
---|---|---|---|---|---|---|
+ <%= link_to truncate(pro_resource.filename, :length => 18), download_named_attachment_path(pro_resource.id, pro_resource.filename ), :title => pro_resource.filename,:class=>'resourcesBlack'%> + | ++ <%= number_to_human_size(pro_resource.filesize)%> + | ++ 项目资源 + | ++ <%= format_date(pro_resource.created_on)%> + | ++ <%= pro_resource.downloads %> + | ++ <%= link_to(User.find(pro_resource.author_id).realname, user_path(User.find(pro_resource.author_id)) ) %> + | ++ <%=link_to truncate(Project.find(pro_resource.container_id).name, :length => 10), project_path(Project.find(pro_resource.container_id)), :title => Project.find(pro_resource.container_id).name, :class => "hidden fl w170" %> + | +