From 4388b7625e619c8b601a3dc52ed0b8845d1106f7 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 21 Nov 2016 16:58:25 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E5=BD=92=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 47 ++++++++++++++++++- app/views/courses/archive_course.js.erb | 2 + .../syllabuses/_syllabus_course_list.html.erb | 19 +------- app/views/users/_courses_list.html.erb | 28 ++++++----- .../users/_syllabus_course_list.html.erb | 6 +-- app/views/users/user_archive_courses.html.erb | 0 app/views/users/user_courselist.html.erb | 8 +++- config/routes.rb | 1 + public/javascripts/application.js | 16 +++++++ public/stylesheets/css/courses.css | 8 +++- public/stylesheets/syllabus.css | 2 +- 11 files changed, 98 insertions(+), 39 deletions(-) create mode 100644 app/views/users/user_archive_courses.html.erb 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 @@
-
+
" class="syllabus_class_title fl" target="_blank" title="<%= allow_visit ? "" : "私有班级不可访问" %>"><%= course.name %> <%= course.is_public == 0 ? '私有' : '公开' %> -

更新:<%= 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) %>

-
- + <% if User.current == course.teacher || User.current.admin? %> +
+ 归档 +
+ + +

此班级的信息将不再显示
+ 您和您的学生将不能在此班级中继续互动
+ 但您可以点击上方的“归档管理” +

+
+
+ <% end %>
diff --git a/app/views/users/_syllabus_course_list.html.erb b/app/views/users/_syllabus_course_list.html.erb index 0759cb5b6..6c8e2140e 100644 --- a/app/views/users/_syllabus_course_list.html.erb +++ b/app/views/users/_syllabus_course_list.html.erb @@ -1,16 +1,12 @@
<% if @type.to_i == 2 %> <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %> - <% else %> - <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %> <% end %> <%= link_to "人气", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %> <% if @type.to_i == 1 %> <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %> - <% else %> - <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortdownbtn sort_no fr", :remote => true %> <% end %> - <%= link_to "时间", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt fr", :remote => true %> + <%= link_to "时间", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt mr5 fr", :remote => true %> <%=@user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "加入"%>的课程
diff --git a/app/views/users/user_archive_courses.html.erb b/app/views/users/user_archive_courses.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/users/user_courselist.html.erb b/app/views/users/user_courselist.html.erb index 8f41b051e..b247ed230 100644 --- a/app/views/users/user_courselist.html.erb +++ b/app/views/users/user_courselist.html.erb @@ -1,5 +1,11 @@
-

课程列表

+
+

课程列表

+ <% if @user == User.current && !@archive_syllabuses.blank? %> + <%= link_to "归档管理", user_archive_courses_users_path(), :class => "linkBlue2 mt15 fr mr20 f14"%> + <% end %> +
+
<%= render :partial => 'users/user_syllabus_list'%>
diff --git a/config/routes.rb b/config/routes.rb index 3848c4b46..f3cc8c159 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -579,6 +579,7 @@ RedmineApp::Application.routes.draw do post 'user_select_homework' post 'check_homework' get 'all_journals' + get 'user_archive_courses' end member do diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 3f5a739f9..6c0f615dd 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -2240,3 +2240,19 @@ function getIssueStatistics(url){ } +function archive_course(id, type, source){ + if(type == 0){ + var htmlvalue = '

提示

'+ + '

您是否确定归档此班级

' + + '取  消' + + '确  定
'; + pop_box_new(htmlvalue, 400, 132); + } else{ + var htmlvalue = '

提示

'+ + '

您和您的学生将可以重新在此班级中互动
此班级的动态会在首页中显示

' + + '您是否确定恢复此班级

取  消' + + '确  定
'; + pop_box_new(htmlvalue, 400, 200); + } +} + diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 1f7301772..91a22a177 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -597,4 +597,10 @@ a:hover.blueCir{ background:#3598db; color:#fff;} a.ex_icon_de{ background:url(/images/course/icons.png) 0px -342px no-repeat; width:16px; height:27px; display:block;float:right;} a:hover.ex_icon_de{ background:url(/images/course/icons.png) -20px -342px no-repeat;} .ex_icon_edit{ background:url(/images/course/icons.png) 0px -276px no-repeat; width:16px; height:27px; display:block;float:right; margin-right:10px;} -a:hover.ex_icon_edit{ background:url(/images/course/icons.png) -21px -276px no-repeat;} \ No newline at end of file +a:hover.ex_icon_edit{ background:url(/images/course/icons.png) -21px -276px no-repeat;} + +/*首页课程列表归档按钮提示*/ +/*分组作业评分提示框*/ +.archive_course_notice {width:220px; position:absolute; padding:5px 10px; white-space:nowrap; background-color:#fff; right:-265px; top:-15px; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);} +.archive_course_notice em {display:block; border-width:10px; position:absolute;top:26px; left:-20px; border-style:dashed solid dashed dashed; border-color:transparent #eaeaea transparent transparent; font-size:0; line-height:0;} +.archive_course_notice span {display:block; border-width:10px; position:absolute;top:26px; left:-18px; border-style:dashed solid dashed dashed; border-color:transparent #fff transparent transparent; font-size:0; line-height:0;} diff --git a/public/stylesheets/syllabus.css b/public/stylesheets/syllabus.css index 64640f96f..499e4a336 100644 --- a/public/stylesheets/syllabus.css +++ b/public/stylesheets/syllabus.css @@ -65,7 +65,7 @@ input.syllabus_input_min{ .syllabus_class_list_more{padding:8px; text-align:center;border-left:1px solid #e7e7e7;border-bottom:1px solid #e7e7e7;} .syllabus_class_list_more:hover{ background:#ececec;} .syllabus_class_list_more a{ color:#ff7e00;} -a.syllabus_class_title{ font-size:14px; color:#333; max-width:480px; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +a.syllabus_class_title{ font-size:14px; color:#333; max-width:520px; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } .syllabus_class_w{ width:650px;} .syllabus_class_property {font-size:12px; padding:0 5px; border-radius:3px; line-height:14px;} .syllabus_class_private {color:#ff4a1b; border:1px solid #ff4a1b;} From eeacd76aa9ff0d49a728cc87ba19c3533da96c7e Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 22 Nov 2016 10:27:56 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E5=BD=92=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/syllabuses_controller.rb | 2 +- app/controllers/users_controller.rb | 14 +++-- app/views/courses/archive_course.js.erb | 8 ++- app/views/layouts/base_users_new.html.erb | 12 ++-- app/views/layouts/new_base_user.html.erb | 10 ++-- app/views/users/_courses_list.html.erb | 23 ++++--- .../users/_syllabus_course_list.html.erb | 3 + .../users/_user_archive_course_list.html.erb | 60 +++++++++++++++++++ app/views/users/user_archive_courses.html.erb | 40 +++++++++++++ app/views/users/user_archive_courses.js.erb | 1 + app/views/users/user_courselist.html.erb | 2 +- 11 files changed, 149 insertions(+), 26 deletions(-) create mode 100644 app/views/users/_user_archive_course_list.html.erb create mode 100644 app/views/users/user_archive_courses.js.erb diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index cad65f88d..13bacbd4b 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -92,7 +92,7 @@ class SyllabusesController < ApplicationController def destroy if @syllabus && @syllabus.courses.not_deleted.empty? @syllabus.destroy - redirect_to user_courselist_user_path(User.current.id) + redirect_to user_courselist_user_path(User.current) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1a8c7f7f0..04a3df24a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3476,7 +3476,7 @@ class UsersController < ApplicationController #归档班级列表 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 + @order, @c_sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 #确定 sort_type if @order.to_i == @type.to_i @@ -3485,6 +3485,7 @@ class UsersController < ApplicationController @c_sort = 2 end + @user = User.current 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}") @@ -3503,13 +3504,14 @@ class UsersController < ApplicationController 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]}) + @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 else @type = 1 end respond_to do |format| - format.html + format.js + format.html {render :layout => 'new_base_user'} end end end @@ -3518,7 +3520,11 @@ class UsersController < ApplicationController def expand_courses @syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first 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| format.js end diff --git a/app/views/courses/archive_course.js.erb b/app/views/courses/archive_course.js.erb index c7cd0f729..a5ef39035 100644 --- a/app/views/courses/archive_course.js.erb +++ b/app/views/courses/archive_course.js.erb @@ -13,7 +13,11 @@ 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) %>"; + <% elsif params[:source] == "0" %> + <% if params[:type] == "0" %> + window.location.href = "<%=user_courselist_user_path(User.current) %>"; + <% else %> + window.location.href = "<%=user_archive_courses_users_path() %>"; + <% end %> <% end %> } \ No newline at end of file diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index 2f3ef2928..316d10c4c 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -140,25 +140,25 @@