From deda05b048fd5f5ec7a23e81377cf8225d98aa8b Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 13 Apr 2016 14:23:24 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/index.html.erb | 2 +- public/stylesheets/courses.css | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 6a3528e51..9a1497fa7 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -43,7 +43,7 @@ From 2d4f724e33fd582a5c3e878cd8e1e4cc9d28163d Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Apr 2016 15:01:18 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E7=9A=84=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=88=97=E8=A1=A8=E4=BD=9C=E5=93=81=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8C=89=E4=BD=9C=E4=B8=9A=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8D=87=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index af02829e0..af793ca31 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -334,7 +334,7 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") - @homeworks = @course.homework_commons.order("created_at desc") + @homeworks = @course.homework_commons.order("created_at asc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; respond_to do |format| From 96accf1e7a6a0dd57134a4fae234915d2fed9bc4 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Apr 2016 15:35:27 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=9C=AA=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=B8=8D=E5=BA=94=E8=BF=9B=E8=A1=8C=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=9A=84=E7=A7=AF=E5=88=86=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/member.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/member.rb b/app/models/member.rb index e19e1f0df..cc227cf31 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -145,7 +145,7 @@ class Member < ActiveRecord::Base #当前课程的作业列表 def homework_common_list - HomeworkCommon.where(:course_id => self.course_id) + HomeworkCommon.where("course_id = ? and publish_time is not null and publish_time <= '#{Date.today}'", self.course_id) end #当前学生在指定作业内的得分 From 143f3f8f9aab4fe70dbfc4c96e5ef6a7f2a8f114 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 15 Apr 2016 11:26:56 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=A2=9E=E5=8A=A0=E7=B2=BE=E5=93=81=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 27 +++++++ app/views/admin/_course_detail_tr.html.erb | 32 +++++++++ app/views/admin/_tab_excellent_courses.erb | 7 ++ app/views/admin/courses.html.erb | 4 +- .../admin/excellent_all_courses.html.erb | 71 +++++++++++++++++++ app/views/admin/excellent_courses.html.erb | 6 ++ app/views/admin/set_excellent_course.js.erb | 1 + config/routes.rb | 4 +- 8 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 app/views/admin/_course_detail_tr.html.erb create mode 100644 app/views/admin/_tab_excellent_courses.erb create mode 100644 app/views/admin/excellent_all_courses.html.erb create mode 100644 app/views/admin/set_excellent_course.js.erb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index e1e99447d..81407d95d 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -63,6 +63,33 @@ class AdminController < ApplicationController end end + #精品课程下的全部课程 + def excellent_all_courses + @name = params[:name] + @courses = Course.like(@name).order('created_at desc') + @courses = paginateHelper @courses,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end + end + + #设为精品 + def set_excellent_course + @course = Course.find params[:id] + unless @course.nil? + if @course.is_excellent == 1 || @course.excellent_option == 1 + @course.update_column('is_excellent', 0) + @course.update_column('excellent_option', 0) + else + @course.update_column('is_excellent', 1) + end + respond_to do |format| + format.js + end + end + end + #管理员界面课程资源列表 def course_resource_list diff --git a/app/views/admin/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb new file mode 100644 index 000000000..ca15a6696 --- /dev/null +++ b/app/views/admin/_course_detail_tr.html.erb @@ -0,0 +1,32 @@ + + <%= course.id %> + + + + <%= link_to(course.name, course_path(course.id)) %> + + + + <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> + + + <%= studentCount(course) %> + + + <%= course.homework_commons.count%> + + + <%= student_works_num(course) %> + + + <%= visable_attachemnts_incourse(course).count%> + + + <%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %> + + + <%= course.course_activities.count%> + + + <%= link_to( course.is_excellent == 1 || course.excellent_option == 1 ? "取消精品" : "设为精品", { :controller => 'admin', :action => 'set_excellent_course', :id => course.id },:remote=>true, :class => 'icon-del') %> + diff --git a/app/views/admin/_tab_excellent_courses.erb b/app/views/admin/_tab_excellent_courses.erb new file mode 100644 index 000000000..844648c0b --- /dev/null +++ b/app/views/admin/_tab_excellent_courses.erb @@ -0,0 +1,7 @@ +
+
    +
  • <%= link_to '精品课程', {:action => 'excellent_courses'}, class: "#{current_page?(excellent_courses_path)? 'selected' : nil }" %>
  • +
  • <%= link_to '全部课程', {:action => 'excellent_all_courses'}, class: "#{current_page?(excellent_all_courses_path)? 'selected' : nil }" %>
  • + +
+
\ No newline at end of file diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb index 2505b3d06..8e2f146a0 100644 --- a/app/views/admin/courses.html.erb +++ b/app/views/admin/courses.html.erb @@ -13,9 +13,7 @@ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %> <%= submit_tag l(:button_apply), :class => "small", :name => nil %> - - <%= l(:button_clear)%> - + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'courses'},:remote => true, :class => 'icon icon-reload' %> <% end %>   diff --git a/app/views/admin/excellent_all_courses.html.erb b/app/views/admin/excellent_all_courses.html.erb new file mode 100644 index 000000000..7554885a9 --- /dev/null +++ b/app/views/admin/excellent_all_courses.html.erb @@ -0,0 +1,71 @@ +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %> +

+ 精品课程列表 +

+<%= render 'tab_excellent_courses' %> + +

+ 全部课程列表 +

+ +<%= form_tag({}, :method => :get) do %> +
+ + <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %> + <%= submit_tag l(:button_apply), :class => "small", :name => nil %> + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'excellent_all_courses'}, :class => 'icon icon-reload' %> +
+<% end %> +  + +
+ + + + + + + + + + + + + + + + + <% @courses.each do |course| %> + " id="tr_<%= course.id %>"> + <%= render :partial => 'course_detail_tr', :locals => {:course => course} %> + + <% end %> + +
+ 序号 + + 课程名 + + 主讲老师 + + 学生数 + + 作业数 + + 作品数 + + 资源数 + + 帖子数 + + 动态数 + +
+
+ + +<% html_title(l(:label_excellent_courses_list)) -%> \ No newline at end of file diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb index 59426455a..fef6da84d 100644 --- a/app/views/admin/excellent_courses.html.erb +++ b/app/views/admin/excellent_courses.html.erb @@ -1,3 +1,9 @@ +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %> +

+ <%=l(:label_excellent_courses_list)%> +

+<%= render 'tab_excellent_courses' %> +

<%=l(:label_excellent_courses_list)%>

diff --git a/app/views/admin/set_excellent_course.js.erb b/app/views/admin/set_excellent_course.js.erb new file mode 100644 index 000000000..7b3ade139 --- /dev/null +++ b/app/views/admin/set_excellent_course.js.erb @@ -0,0 +1 @@ +$("#tr_<%=@course.id %>").html("<%=escape_javascript(render :partial => 'course_detail_tr', :locals => {:course => @course}) %>"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ea89bb57e..9cfb3126d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -950,7 +950,9 @@ RedmineApp::Application.routes.draw do match 'admin', :to => 'admin#index', :via => :get match 'admin/projects', :via => :get get 'admin/courses' - get 'admin/excellent_courses' + get 'admin/excellent_courses', as: :excellent_courses + get 'admin/excellent_all_courses', as: :excellent_all_courses + match 'admin/set_excellent_course/:id', :to => 'admin#set_excellent_course' get 'admin/course_resource_list' get 'admin/project_resource_list' match 'admin/users', :via => :get