课程大纲列表

This commit is contained in:
cxt 2016-06-30 15:36:46 +08:00
parent ebb697a49f
commit ac4218bfb0
6 changed files with 99 additions and 37 deletions

View File

@ -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).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).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) @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_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}") @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
# end # end
@syllabus.each do |syllabus| @syllabus.each do |syllabus|
syllabus[:infocount] = 0 count = 0
courses = courses.select("syllabus_id = #{syllabus.id}") courses = @courses.select("syllabus_id = #{syllabus.id}")
courses.each do |c| 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 end
syllabus[:infocount] = count
end end
@c_sort == 1 ? (@syllabus = @syllabus.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@syllabus = @syllabus.sort{|x,y| y[:infocount] <=> x[:infocount]}) @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 @syllabus = sortby_time_countcommon_nosticky @syllabus,sort_name

View File

@ -789,6 +789,15 @@ module CoursesHelper
result result
end 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 def zh_course_role role
if role == "TeachingAsistant" if role == "TeachingAsistant"
result = l(:label_TA) result = l(:label_TA)

View File

@ -1,11 +1,8 @@
<%# course_model %> <%# course_model %>
<% course_file_num = visable_attachemnts_incourse(@course).count%> <% course_file_num = visable_attachemnts_incourse(@course).count%>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> <% 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 = visable_course_homework @course %>
<% homework_num = @course.homework_commons.count %>
<% else %>
<% homework_num = @course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
<% end %>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html"> <html lang="en" xmlns="http://www.w3.org/1999/html">
<head> <head>

View File

@ -19,17 +19,53 @@
<div class="syllabus_courses_box"> <div class="syllabus_courses_box">
<% if @syllabus.any? %> <% if @syllabus.any? %>
<% @syllabus.each do |syllabus|%> <% @syllabus.each_with_index do |syllabus, index|%>
<div class="syllabus_courses_list "> <% 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") %>
<div class="sy_courses_open"> <div class="syllabus_courses_list">
<span class="icons_sy_open fl mr5"></span> <div class="<%=index == 0 ? 'sy_courses_open' : 'sy_courses_close' %>">
<span class="<%=index == 0 ? 'icons_sy_open' : 'icons_sy_close' %> fl mr5"></span>
<h3 class="syllabus_courses_title fl"><%=syllabus.title %></h3> <h3 class="syllabus_courses_title fl"><%=syllabus.title %></h3>
</div> </div>
<%=link_to '管理课程', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr' %> <%=link_to '', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr', :title => '管理课程' %>
<p class="fl sy_p_grey">更新时间2016-05-05<span class="mr10"></span>创建老师:豆蔻</p> <p class="fl sy_p_grey">更新时间:<%=format_date syllabus.updated_at %>
<span class="mr10"></span>创建老师:<%=syllabus.user.show_name %>
<span class="mr10"></span>班级:<%=courses.count %>
</p>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div class="syllabus_class_box <%=index == 0 ? '' : 'none' %>">
<ul id="syllabus_course_ul_<%=syllabus.id %>">
<% unless courses.nil? %>
<% courses.each_with_index do |course, i| %>
<li class="syllabus_class_list <%=i > 2 ? 'none' : '' %>">
<a href="<%=course_path(course.id) %>" target="_blank">
<span class="icons_sy_cir "></span>
<div class="fl">
<div class="syllabus_class_w ">
<p class="syllabus_class_title fl"><%=course.name %></p>
<span class="fr sy_p_grey">主讲老师:<%=course.teacher.show_name %></span>
<div class="cl"></div>
</div>
<div class="">
<p class="fl grayTxt ">更新:<%=course.time %><span class="mr10"></span>学期:<%=current_time_and_term(course) %></p>
<p class="list-info fr grayTxt"><span><%=studentCount course %></span><span>学生</span><span>|</span><span><%=visable_course_homework course %></span><span>作业</span><span>|</span><span><%=visable_attachemnts_incourse(@course).count %></span><span>资源</span></p>
<div class="cl"></div>
</div>
</div>
<span class="icons_sy_arrow fl mt19 ml10" ></span>
<div class="cl"></div>
</a>
</li>
<% end %>
<% if courses.count > 3 %>
<li class="syllabus_class_list_more" id="syllabus_class_list_more_<%=syllabus.id %>">
<a href="javascript:void(0);" id="expand_list_<%=syllabus.id %>" data-init="0" onclick="expand_course_list(<%=syllabus.id %>,'#syllabus_course_ul_<%=syllabus.id %> li','#expand_list_<%=syllabus.id %>',<%=courses.count %>)">共<%=courses.count %>个课程,点击全部展开</a>
</li>
<% end %>
<% end %>
</ul>
</div><!--syllabus_class_box end-->
<% end %> <% end %>
<div> <div>
<ul class="wlist" id="pages" > <ul class="wlist" id="pages" >
@ -50,26 +86,26 @@
var rightHeight = $(".homepageRight").height(); var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight) { if (rightHeight < leftHeight) {
var diffHeight = leftHeight - rightHeight; var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".listbox").height() + diffHeight; var tmpHeight = $(".syllabus_box").height() + diffHeight;
$(".listbox").css("height", tmpHeight); $(".syllabus_box").css("height", tmpHeight);
} }
});
$(".sy_courses_open").toggle(function(){ $(".sy_courses_open").toggle(function(){
//$(this).hide(); //$(this).hide();
$(this).parent().next().hide(); $(this).parent().next().hide();
$(this).addClass("sy_courses_close").removeClass("sy_courses_open"); $(this).children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open");
//$(this).parent().next().show(); //$(this).parent().next().show();
},function(){ },function(){
$(this).parent().next().show(); $(this).parent().next().show();
$(this).addClass("sy_courses_open").removeClass("sy_courses_close"); $(this).children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close");
}); });
$(".sy_courses_close").toggle(function(){ $(".sy_courses_close").toggle(function(){
//$(this).hide(); //$(this).hide();
$(this).parent().next().show(); $(this).parent().next().show();
$(this).addClass("sy_courses_open").removeClass("sy_courses_close"); $(this).children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close");
//$(this).parent().next().show(); //$(this).parent().next().show();
},function(){ },function(){
$(this).parent().next().hide(); $(this).parent().next().hide();
$(this).addClass("sy_courses_close").removeClass("sy_courses_open"); $(this).children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open");
});
}); });
</script> </script>

View File

@ -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();
}
}

View File

@ -110,7 +110,7 @@ a.syllabusbox_a_blue{
.syllabus_box{ width:750px; border:1px solid #e7e7e7; background-color:#fff;} .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{ padding:15px; border-bottom:1px solid #e7e7e7; cursor:pointer;}
.syllabus_courses_list:hover{ background:#f6fafd;} .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;} .sy_p_grey{ margin-left:25px; color:#888; margin-top:5px; font-size:12px;}
.syllabus_class_box{ padding-left:30px; background:#f6f6f6;} .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;} .syllabus_class_list{ padding:12px 0 12px 15px; height:44px;border-left:1px solid #e7e7e7;border-bottom:1px solid #e7e7e7; position:relative;}