diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 43d12cadf..68e7f5590 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3190,8 +3190,8 @@ class UsersController < ApplicationController # @courses = @user.courses.visible.where("is_delete =?", 0).order("#{sort_name} #{sort_type}") #@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") - courses = @user.courses.visible.where("is_delete =?", 0) - syllabus_ids = courses.empty? ? '(-1)' : "(" + courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" + @courses = @user.courses.visible.where("is_delete =?", 0) + syllabus_ids = @courses.empty? ? '(-1)' : "(" + @courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" @syllabus = Syllabus.where("id in #{syllabus_ids} or user_id = #{User.current.id}").order("#{sort_name} #{sort_type}") #根据 作业+资源数排序 @@ -3204,11 +3204,12 @@ class UsersController < ApplicationController # end # end @syllabus.each do |syllabus| - syllabus[:infocount] = 0 - courses = courses.select("syllabus_id = #{syllabus.id}") + count = 0 + courses = @courses.select("syllabus_id = #{syllabus.id}") courses.each do |c| - syllabus[:infocount] += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count) + count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count) end + syllabus[:infocount] = count end @c_sort == 1 ? (@syllabus = @syllabus.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@syllabus = @syllabus.sort{|x,y| y[:infocount] <=> x[:infocount]}) @syllabus = sortby_time_countcommon_nosticky @syllabus,sort_name diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index fd3be1369..dd3abe3a8 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -789,6 +789,15 @@ module CoursesHelper result end + def visable_course_homework course + if User.current.admin? || User.current.allowed_to?(:as_teacher,course) + homework_num = course.homework_commons.count + else + homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count + end + homework_num + end + def zh_course_role role if role == "TeachingAsistant" result = l(:label_TA) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 4b618bef1..8f4f443c0 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,11 +1,8 @@ <%# course_model %> <% course_file_num = visable_attachemnts_incourse(@course).count%> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> -<% if User.current.admin? || User.current.allowed_to?(:as_teacher,@course) %> - <% homework_num = @course.homework_commons.count %> -<% else %> - <% homework_num = @course.homework_commons.where("publish_time <= '#{Date.today}'").count %> -<% end %> +<% homework_num = visable_course_homework @course %> + diff --git a/app/views/users/_user_syllabus_list.html.erb b/app/views/users/_user_syllabus_list.html.erb index 4613e9e18..dbf7e301a 100644 --- a/app/views/users/_user_syllabus_list.html.erb +++ b/app/views/users/_user_syllabus_list.html.erb @@ -19,17 +19,53 @@
<% if @syllabus.any? %> - <% @syllabus.each do |syllabus|%> -
-
- + <% @syllabus.each_with_index do |syllabus, index|%> + <% courses = @courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS time").order("time desc") %> +
+
+

<%=syllabus.title %>

- <%=link_to '管理课程', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr' %> -

更新时间:2016-05-05创建老师:豆蔻

+ <%=link_to '', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr', :title => '管理课程' %> +

更新时间:<%=format_date syllabus.updated_at %> + 创建老师:<%=syllabus.user.show_name %> + 班级:<%=courses.count %> +

+ <% end %>
    @@ -50,26 +86,26 @@ var rightHeight = $(".homepageRight").height(); if (rightHeight < leftHeight) { var diffHeight = leftHeight - rightHeight; - var tmpHeight = $(".listbox").height() + diffHeight; - $(".listbox").css("height", tmpHeight); + var tmpHeight = $(".syllabus_box").height() + diffHeight; + $(".syllabus_box").css("height", tmpHeight); } - }); - $(".sy_courses_open").toggle(function(){ - //$(this).hide(); - $(this).parent().next().hide(); - $(this).addClass("sy_courses_close").removeClass("sy_courses_open"); - //$(this).parent().next().show(); - },function(){ - $(this).parent().next().show(); - $(this).addClass("sy_courses_open").removeClass("sy_courses_close"); - }); - $(".sy_courses_close").toggle(function(){ - //$(this).hide(); - $(this).parent().next().show(); - $(this).addClass("sy_courses_open").removeClass("sy_courses_close"); - //$(this).parent().next().show(); - },function(){ - $(this).parent().next().hide(); - $(this).addClass("sy_courses_close").removeClass("sy_courses_open"); + $(".sy_courses_open").toggle(function(){ + //$(this).hide(); + $(this).parent().next().hide(); + $(this).children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); + //$(this).parent().next().show(); + },function(){ + $(this).parent().next().show(); + $(this).children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); + }); + $(".sy_courses_close").toggle(function(){ + //$(this).hide(); + $(this).parent().next().show(); + $(this).children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); + //$(this).parent().next().show(); + },function(){ + $(this).parent().next().hide(); + $(this).children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); + }); }); \ No newline at end of file diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a04df39ac..142b0be42 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1556,3 +1556,22 @@ function edit_file_description(url,id){ ); } +//展开课程大纲列表中的班级 +function expand_course_list(id, target, btnid, count) { + var target = $(target); + var btn = $(btnid); + if(btn.data('init')=='0'){ + btn.data('init',1); + btn.html('点击收起'); + target.show(); + }else{ + btn.data('init',0); + btn.html('共'+count+ '个课程,点击全部展开'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + btn.parent().show(); + } +} + diff --git a/public/stylesheets/syllabus.css b/public/stylesheets/syllabus.css index d73bbc8bf..83f6cefbc 100644 --- a/public/stylesheets/syllabus.css +++ b/public/stylesheets/syllabus.css @@ -110,7 +110,7 @@ a.syllabusbox_a_blue{ .syllabus_box{ width:750px; border:1px solid #e7e7e7; background-color:#fff;} .syllabus_courses_list{ padding:15px; border-bottom:1px solid #e7e7e7; cursor:pointer;} .syllabus_courses_list:hover{ background:#f6fafd;} -a.syllabus_courses_title{ font-size:16px; color:#333; width:650px; font-weight:normal;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.syllabus_courses_title{ font-size:16px; color:#333; width:650px; font-weight:normal;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } .sy_p_grey{ margin-left:25px; color:#888; margin-top:5px; font-size:12px;} .syllabus_class_box{ padding-left:30px; background:#f6f6f6;} .syllabus_class_list{ padding:12px 0 12px 15px; height:44px;border-left:1px solid #e7e7e7;border-bottom:1px solid #e7e7e7; position:relative;}