diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 56b536d30..1a8c7f7f0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3397,7 +3397,11 @@ class UsersController < ApplicationController @my_syllabuses = @user.syllabuses - my_syllabus_ids = @my_syllabuses.empty? ? "(-1)" : "(" + @my_syllabuses.map{|syllabus| syllabus.id}.join(',') + ")" + if @user == User.current + 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}") + end + sy_courses = @user.courses.visible.not_deleted syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" syllabus_members = SyllabusMember.where("user_id = #{@user.id}") @@ -3469,6 +3473,47 @@ class UsersController < ApplicationController end end + #归档班级列表 + def user_archive_courses + if User.current.logged? + @order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1 + + #确定 sort_type + if @order.to_i == @type.to_i + @c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序 + else + @c_sort = 2 + end + + 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_syllabuses = Syllabus.where("id in #{archive_ids}") + + if @order.to_i == 1 #根据 班级更新时间排序 + @archive_syllabuses = syllabus_course_list_sort @archive_syllabuses + @c_sort == 1 ? (@archive_syllabuses = @archive_syllabuses.sort{|x,y| x[:last_update] <=> y[:last_update] }) : (@archive_syllabuses = @archive_syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]}) + @type = 1 + elsif @order.to_i == 2 #根据 作业+资源数排序 + @type = 2 + @archive_syllabuses.each do |syllabus| + count = 0 + courses = syllabus.courses.not_deleted + courses.each do |c| + 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 ? (@archive_syllabuses = @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 + else + @type = 1 + end + respond_to do |format| + format.html + end + end + end + #展开课程下的班级 def expand_courses @syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first diff --git a/app/views/courses/archive_course.js.erb b/app/views/courses/archive_course.js.erb index 9d66c8441..c7cd0f729 100644 --- a/app/views/courses/archive_course.js.erb +++ b/app/views/courses/archive_course.js.erb @@ -13,5 +13,7 @@ function click_OK(){ hideModal(); <% if params[:source] == "1" %> window.location.href = "<%=syllabus_courselist_syllabus_path(@syllabus, :list_type => params[:type].to_i) %>"; + <% else params[:source] == "0" %> + window.location.href = "<%=user_courselist_path(User.current) %>"; <% end %> } \ No newline at end of file diff --git a/app/views/syllabuses/_syllabus_course_list.html.erb b/app/views/syllabuses/_syllabus_course_list.html.erb index 1ce62a1b4..995514db5 100644 --- a/app/views/syllabuses/_syllabus_course_list.html.erb +++ b/app/views/syllabuses/_syllabus_course_list.html.erb @@ -68,11 +68,11 @@ <%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "hw_btn_green fr mt5",:method => "post"%> <% end %> <% if User.current == course.teacher || User.current.admin? %> - 归档 + 归档 <% end %> <% else %> <% if User.current == course.teacher || User.current.admin? %> - 恢复 + 恢复 <% end %> <% end %>
@@ -119,19 +119,4 @@ $(function() { $(".sy_con_l").css("min-height",$(".sy_con_r").height()); }); - function archive_course(id, type){ - if(type == 0){ - var htmlvalue = ''; - pop_box_new(htmlvalue, 400, 132); - } else{ - var htmlvalue = ''; - pop_box_new(htmlvalue, 400, 200); - } - } \ No newline at end of file diff --git a/app/views/users/_courses_list.html.erb b/app/views/users/_courses_list.html.erb index d79215f9a..439a24d10 100644 --- a/app/views/users/_courses_list.html.erb +++ b/app/views/users/_courses_list.html.erb @@ -7,30 +7,32 @@更新:<%= format_date Time.at(course.updatetime) %> - 学期:<%= current_time_and_term(course) %>
- -- <% student_link = (User.current.logged? && course.open_student == 1 && course.is_public == 1) || (User.current.member_of_course?(course)) || User.current.admin? %> - " target="_blank" title="<%= student_link ? "" : "学生列表不对外公开" %>"><%= studentCount course %>学生 - | - " target="_blank" title="<%= allow_visit ? "" : "私有班级不可访问" %>"><%= visable_course_homework course %>作业 - | - " target="_blank" title="<%= allow_visit ? "" : "私有班级不可访问" %>"><%= visable_attachemnts_incourse(course).count %>资源 + 创建老师:<%= link_to course.teacher.show_name, user_path(course.teacher) %>
-此班级的信息将不再显示
+ 您和您的学生将不能在此班级中继续互动
+ 但您可以点击上方的“归档管理”
+