首页班级列表的归档

This commit is contained in:
cxt 2016-11-22 10:27:56 +08:00
parent 4388b7625e
commit eeacd76aa9
11 changed files with 149 additions and 26 deletions

View File

@ -92,7 +92,7 @@ class SyllabusesController < ApplicationController
def destroy def destroy
if @syllabus && @syllabus.courses.not_deleted.empty? if @syllabus && @syllabus.courses.not_deleted.empty?
@syllabus.destroy @syllabus.destroy
redirect_to user_courselist_user_path(User.current.id) redirect_to user_courselist_user_path(User.current)
end end
end end

View File

@ -3476,7 +3476,7 @@ class UsersController < ApplicationController
#归档班级列表 #归档班级列表
def user_archive_courses def user_archive_courses
if User.current.logged? if User.current.logged?
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1 @order, @c_sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
#确定 sort_type #确定 sort_type
if @order.to_i == @type.to_i if @order.to_i == @type.to_i
@ -3485,6 +3485,7 @@ class UsersController < ApplicationController
@c_sort = 2 @c_sort = 2
end end
@user = User.current
sort_name = "updated_at" sort_name = "updated_at"
archive_ids = Course.where("tea_id = #{@user.id} and is_delete = 1").blank? ? "(-1)" : "(" + Course.where("tea_id = #{@user.id} and is_delete = 1").map{|course| course.syllabus_id}.join(",") + ")" archive_ids = Course.where("tea_id = #{@user.id} and is_delete = 1").blank? ? "(-1)" : "(" + Course.where("tea_id = #{@user.id} and is_delete = 1").map{|course| course.syllabus_id}.join(",") + ")"
@archive_syllabuses = Syllabus.where("id in #{archive_ids}") @archive_syllabuses = Syllabus.where("id in #{archive_ids}")
@ -3503,13 +3504,14 @@ class UsersController < ApplicationController
end end
syllabus[:infocount] = count syllabus[:infocount] = count
end end
@c_sort == 1 ? (@archive_syllabuses = @syllabuses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@archive_syllabuses = @archive_syllabuses.sort{|x,y| y[:infocount] <=> x[:infocount]}) @c_sort == 1 ? (@archive_syllabuses = @archive_syllabuses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@archive_syllabuses = @archive_syllabuses.sort{|x,y| y[:infocount] <=> x[:infocount]})
@archive_syllabuses = sortby_time_countcommon_nosticky @archive_syllabuses,sort_name @archive_syllabuses = sortby_time_countcommon_nosticky @archive_syllabuses,sort_name
else else
@type = 1 @type = 1
end end
respond_to do |format| respond_to do |format|
format.html format.js
format.html {render :layout => 'new_base_user'}
end end
end end
end end
@ -3518,7 +3520,11 @@ class UsersController < ApplicationController
def expand_courses def expand_courses
@syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first @syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first
unless @syllabus.nil? unless @syllabus.nil?
@courses = @syllabus.courses.not_deleted.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") if params[:is_delete] && params[:is_delete] == '1'
@courses = @syllabus.courses.where("is_delete = 1").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc")
else
@courses = @syllabus.courses.not_deleted.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc")
end
respond_to do |format| respond_to do |format|
format.js format.js
end end

View File

@ -13,7 +13,11 @@ function click_OK(){
hideModal(); hideModal();
<% if params[:source] == "1" %> <% if params[:source] == "1" %>
window.location.href = "<%=syllabus_courselist_syllabus_path(@syllabus, :list_type => params[:type].to_i) %>"; window.location.href = "<%=syllabus_courselist_syllabus_path(@syllabus, :list_type => params[:type].to_i) %>";
<% else params[:source] == "0" %> <% elsif params[:source] == "0" %>
window.location.href = "<%=user_courselist_path(User.current) %>"; <% if params[:type] == "0" %>
window.location.href = "<%=user_courselist_user_path(User.current) %>";
<% else %>
window.location.href = "<%=user_archive_courses_users_path() %>";
<% end %>
<% end %> <% end %>
} }

View File

@ -140,25 +140,25 @@
<div class="subNavBox "> <div class="subNavBox ">
<div class="subNav "> <div class="subNav ">
<a href="<%=url_for(:controller => 'users', :action => 'show',:id=>@user.id)%>" class=" f14 c_blue02"> <a href="<%=url_for(:controller => 'users', :action => 'show',:id=>@user)%>" class=" f14 c_blue02">
动态 动态
</a> </a>
</div> </div>
<% if @center_flag %> <% if @center_flag %>
<div class="subNav"> <div class="subNav">
<a href="<%=url_for(:controller => 'users', :action => 'user_courselist',:id=>@user.id)%>" class=" f14 c_blue02"> <a href="<%=url_for(:controller => 'users', :action => 'user_courselist',:id=>@user)%>" class=" f14 c_blue02">
我的课程 我的课程
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.count%>)</span> <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.count%>)</span>
</a> </a>
</div> </div>
<div class="subNav"> <div class="subNav">
<a href="<%=url_for(:controller => 'users', :action => 'user_projectlist',:id=>@user.id)%>" class=" f14 c_blue02"> <a href="<%=url_for(:controller => 'users', :action => 'user_projectlist',:id=>@user)%>" class=" f14 c_blue02">
我的项目 我的项目
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.count%>)</span> <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.count%>)</span>
</a> </a>
</div> </div>
<div class="subNav"> <div class="subNav">
<a href="<%=url_for(:controller => 'users', :action => 'user_resource',:id=>@user.id,:type=>1)%>" class=" f14 c_blue02"> <a href="<%=url_for(:controller => 'users', :action => 'user_resource',:id=>@user,:type=>1)%>" class=" f14 c_blue02">
我的资源库 我的资源库
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=Attachment.where("(author_id = #{@user.id} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and container_id in (#{@user.courses.map{|c| c.id}.empty? ? '0' : @user.courses.map{|c| c.id}.join(',')}))").count%>)</span> <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=Attachment.where("(author_id = #{@user.id} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and container_id in (#{@user.courses.map{|c| c.id}.empty? ? '0' : @user.courses.map{|c| c.id}.join(',')}))").count%>)</span>
</a> </a>
@ -166,13 +166,13 @@
<% else%> <% else%>
<div class="subNav"> <div class="subNav">
<a href="<%=url_for(:controller => 'users', :action => 'user_courselist',:id=>@user.id)%>" class=" f14 c_blue02"> <a href="<%=url_for(:controller => 'users', :action => 'user_courselist',:id=>@user)%>" class=" f14 c_blue02">
TA的课程 TA的课程
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.visible.count%>)</span> <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.visible.count%>)</span>
</a> </a>
</div> </div>
<div class="subNav"> <div class="subNav">
<a href="<%=url_for(:controller => 'users', :action => 'user_projectlist',:id=>@user.id)%>" class=" f14 c_blue02"> <a href="<%=url_for(:controller => 'users', :action => 'user_projectlist',:id=>@user)%>" class=" f14 c_blue02">
TA的项目 TA的项目
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.visible.count%>)</span> <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.visible.count%>)</span>
</a> </a>

View File

@ -162,8 +162,8 @@
<% if hidden_unproject_infos %> <% if hidden_unproject_infos %>
<ul class="users_accordion mb10"> <ul class="users_accordion mb10">
<li id="user_01" class="user_icons_course"> <li id="user_01" class="user_icons_course">
<%= link_to '班级',{:controller => "users", :action => "user_courselist", :id => @user.id}, :id => "user_course_list" %> <%= link_to '班级',{:controller => "users", :action => "user_courselist", :id => @user}, :id => "user_course_list" %>
<font class="show-all-sub"><%= link_to '全部',{:controller => "users", :action => "user_courselist", :id => @user.id}, :style => "color:#aaa;" %></font> <font class="show-all-sub"><%= link_to '全部',{:controller => "users", :action => "user_courselist", :id => @user}, :style => "color:#aaa;" %></font>
<% courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10) %> <% courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10) %>
<div class="<%= courses.empty? ? 'none' : ''%>" id="homepage_left_course_list"> <div class="<%= courses.empty? ? 'none' : ''%>" id="homepage_left_course_list">
<%=render :partial => 'layouts/homepage_left_course_list', :locals => {:courses => courses} %> <%=render :partial => 'layouts/homepage_left_course_list', :locals => {:courses => courses} %>
@ -181,7 +181,7 @@
</li> </li>
<% if @user == User.current %> <% if @user == User.current %>
<li id="user_05" class="user_icons_myhw"> <li id="user_05" class="user_icons_myhw">
<%=link_to '我的作业', my_homeworks_user_path(@user.id), :target => "_blank", :style => "font-size:14px;" %> <%=link_to '我的作业', my_homeworks_user_path(@user), :target => "_blank", :style => "font-size:14px;" %>
</li> </li>
<% end %> <% end %>
<% end %> <% end %>
@ -190,8 +190,8 @@
<ul class="users_accordion mb10"> <ul class="users_accordion mb10">
<li id="user_06" class="user_icons_project"> <li id="user_06" class="user_icons_project">
<%= link_to '项目',{:controller => "users", :action => "user_projectlist", :id => @user.id}, :id => 'user_project_list'%> <%= link_to '项目',{:controller => "users", :action => "user_projectlist", :id => @user}, :id => 'user_project_list'%>
<font class="show-all-sub"><%= link_to '全部',{:controller => "users", :action => "user_projectlist", :id => @user.id}, :style => "color:#aaa;" %></font> <font class="show-all-sub"><%= link_to '全部',{:controller => "users", :action => "user_projectlist", :id => @user}, :style => "color:#aaa;" %></font>
<% projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)%> <% projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)%>
<div class="<%= projects.empty? ? 'none' : ''%>" id="homepage_left_project_list"> <div class="<%= projects.empty? ? 'none' : ''%>" id="homepage_left_project_list">
<%=render :partial => 'layouts/homepage_left_project_list', :locals => {:projects => projects} %> <%=render :partial => 'layouts/homepage_left_project_list', :locals => {:projects => projects} %>

View File

@ -1,14 +1,16 @@
<% unless courses.nil? %> <% unless courses.nil? %>
<% courses.each_with_index do |course, i| %> <% courses.each_with_index do |course, i| %>
<li class="syllabus_class_list <%= i > 2 ? 'none' : '' %>"> <li class="syllabus_class_list <%= i > 2 ? 'none' : '' %>">
<% allow_visit = User.current.member_of_course?(course) || User.current.admin? || course.is_public == 1 %> <% allow_visit = course.is_delete == 0 && (User.current.member_of_course?(course) || User.current.admin? || course.is_public == 1) %>
<% if course.is_delete == 0 %>
<span id="collect_course_icon_<%=course.id %>"> <span id="collect_course_icon_<%=course.id %>">
<%=render :partial => 'collect_course', :locals => {:course => course} %> <%=render :partial => 'collect_course', :locals => {:course => course} %>
</span> </span>
<% end %>
<div class="fl"> <div class="fl">
<div class="syllabus_class_w" style="width: 580px;"> <div class="syllabus_class_w" style="width: 580px;">
<a href="<%= allow_visit ? course_path(course.id) : "javascript:void(0)" %>" class="syllabus_class_title fl" target="_blank" title="<%= allow_visit ? "" : "私有班级不可访问" %>"><%= course.name %></a> <a href="<%= allow_visit ? course_path(course.id) : "javascript:void(0)" %>" class="syllabus_class_title fl" target="_blank" title="<%= allow_visit ? "" : "班级不可访问" %>"><%= course.name %></a>
<span class="<%= course.is_public == 0 ? 'syllabus_class_private' : 'syllabus_class_open' %> fl ml10 mt3 syllabus_class_property"><%= course.is_public == 0 ? '私有' : '公开' %></span> <span class="<%= course.is_public == 0 ? 'syllabus_class_private' : 'syllabus_class_open' %> fl ml10 mt3 syllabus_class_property"><%= course.is_public == 0 ? '私有' : '公开' %></span>
<div class="cl"></div> <div class="cl"></div>
@ -20,15 +22,22 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<% if User.current == course.teacher || User.current.admin? %> <% if User.current == @user && (User.current == course.teacher || User.current.admin?) %>
<div class="pr"> <div class="pr">
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 0, 0);" onmouseover="$('#archive_notice_<%=course.id %>').show();" onmouseout="$('#archive_notice_<%=course.id %>').hide();" class="btn_grey_big fr mt5 mr15" style="width: 56px;">归档</a> <a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, <%=course.is_delete %>, 0);" onmouseover="$('#archive_notice_<%=course.id %>').show();" onmouseout="$('#archive_notice_<%=course.id %>').hide();"
class="btn_grey_big fr mt5 mr15" style="width: 56px;"><%= course.is_delete == 0 ? '归档' : '恢复' %></a>
<div class="archive_course_notice fontGrey2 none" id="archive_notice_<%=course.id %>" style="width: 230px;"> <div class="archive_course_notice fontGrey2 none" id="archive_notice_<%=course.id %>" style="width: 230px;">
<em></em> <em></em>
<span></span> <span></span>
<p class="mt5 mb5 break_word">此班级的信息将不再显示<br/> <p class="mt5 mb5 break_word">
您和您的学生将不能在此班级中继续互动<br/> <% if course.is_delete == 0 %>
但您可以点击上方的“归档管理” 此班级的信息将不再显示<br/>
您和您的学生将不能在此班级中继续互动<br/>
但您可以点击上方的“归档管理”
<% else %>
此班级的信息将恢复显示<br/>
您和您的学生将可以重新在此班级中互动
<% end %>
</p> </p>
</div> </div>
</div> </div>

View File

@ -40,6 +40,9 @@
<ul> <ul>
<li class="icons_sy_setting"> <li class="icons_sy_setting">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<li>
<%= link_to "新建班级", new_course_path(:syllabus_id => syllabus.id), :class => "postOptionLink", :target => '_blank', :title => "新建班级"%>
</li>
<li> <li>
<%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %> <%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
</li> </li>

View File

@ -0,0 +1,60 @@
<div class="syllabus_category">
<% if @type.to_i == 2 %>
<%= link_to "", {:controller => 'users', :action => 'user_archive_courses', :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %>
<% end %>
<%= link_to "人气", {:controller => 'users', :action => 'user_archive_courses', :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %>
<% if @type.to_i == 1 %>
<%= link_to "", {:controller => 'users', :action => 'user_archive_courses', :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %>
<% end %>
<%= link_to "时间", {:controller => 'users', :action => 'user_archive_courses', :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt mr5 fr", :remote => true %>
<span class="grayTxt fl ">归档的班级</span>
<div class="cl"></div>
</div>
<% if syllabuses.any? %>
<% syllabuses.each_with_index do |syllabus, index|%>
<div class="syllabus_courses_box">
<% course_count = syllabus.courses.where("is_delete = 1").count %>
<div class="syllabus_courses_list" id="syllabus_courses_list_<%= syllabus.id %>">
<div class="<%=index == 0 ? 'sy_courses_open' : 'sy_courses_close' %>">
<span onclick="expand_courses(<%=syllabus.id %>,<%=course_count %>);" class="<%=index == 0 && course_count != 0 ? 'icons_sy_open' : 'icons_sy_close' %> fl mr5" title="点击展开/收起班级列表"></span>
<%=link_to syllabus.title, syllabus_path(syllabus.id), :class => 'syllabus_courses_title fl', :target => '_blank' %>
</div>
<p class="fl sy_p_grey">更新时间:<%=format_date syllabus.updated_at %>
<span class="mr10"></span>创建老师:<%=syllabus.user.show_name %>
<span class="mr10"></span>班级:<%=course_count %>
</p>
<div class="cl"></div>
</div>
<div class="syllabus_class_box <%=index == 0 ? '' : 'none' %>">
<ul id="syllabus_course_ul_<%=syllabus.id %>">
<% if index == 0 %>
<% courses = syllabus.courses.where("is_delete = 1").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") %>
<%= render :partial => 'users/courses_list', :locals => {:courses => courses, :syllabus => syllabus}%>
<% end %>
</ul>
</div><!--syllabus_class_box end-->
<div class="homepagePostSetting">
<ul>
<li class="icons_sy_setting">
<ul class="homepagePostSettiongText">
<li>
<%= link_to "新建班级", new_course_path(:syllabus_id => syllabus.id), :class => "postOptionLink", :target => '_blank', :title => "新建班级"%>
</li>
<li>
<%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
</li>
<% if User.current == syllabus.user %>
<li><%=link_to '删除课程', delete_syllabus_syllabus_path(syllabus), :class => 'postOptionLink', :remote => 'true'%></li>
<% end %>
</ul>
</li>
</ul>
</div>
</div>
<% end %>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View File

@ -0,0 +1,40 @@
<div class="syllabus_box" id="course-list">
<div style="border-bottom: 1px solid #e7e7e7;">
<h2 class="syllabus_h2_top fl" style="border-bottom: none;"><span class="icon_course fl mt7 mr5"></span>课程列表</h2>
<%= link_to "返回", user_courselist_user_path(@user), :class => "linkBlue2 mt15 fr mr15 f14"%>
<div class="cl"></div>
</div>
<div id="user_archive_course_list">
<%= render :partial => 'users/user_archive_course_list', :locals => {:syllabuses => @archive_syllabuses}%>
</div>
</div>
<script type="text/javascript">
//如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
$(function() {
var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 20;
var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight) {
var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".syllabus_box").height() + diffHeight;
$(".syllabus_box").css("minHeight", tmpHeight);
}
});
function expand_courses(id, count){
var div = $("#syllabus_courses_list_"+id);
var classNum = div.next().children().children("li").size();
if(classNum>0){
div.next().toggle();
div.children(":first-child").children(":first-child").toggleClass("icons_sy_close").toggleClass("icons_sy_open");
} else if(count > 0) {
var str = div.next().children().eq(0).attr('id');
var id = str.substring(19);
var user_id = <%= @user.id%>;
$.get(
'/users/'+user_id+'/expand_courses?is_delete=1&syllabus_id=' + id
);
}
}
</script>

View File

@ -0,0 +1 @@
$("#user_archive_course_list").html('<%= escape_javascript(render :partial => 'users/user_archive_course_list', :locals => {:syllabuses => @archive_syllabuses}) %>');

View File

@ -2,7 +2,7 @@
<div style="border-bottom: 1px solid #e7e7e7;"> <div style="border-bottom: 1px solid #e7e7e7;">
<h2 class="syllabus_h2_top fl" style="border-bottom: none;"><span class="icon_course fl mt7 mr5"></span>课程列表</h2> <h2 class="syllabus_h2_top fl" style="border-bottom: none;"><span class="icon_course fl mt7 mr5"></span>课程列表</h2>
<% if @user == User.current && !@archive_syllabuses.blank? %> <% if @user == User.current && !@archive_syllabuses.blank? %>
<%= link_to "归档管理", user_archive_courses_users_path(), :class => "linkBlue2 mt15 fr mr20 f14"%> <%= link_to "归档管理", user_archive_courses_users_path(), :class => "linkBlue2 mt15 fr mr15 f14"%>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>