From 143f3f8f9aab4fe70dbfc4c96e5ef6a7f2a8f114 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 15 Apr 2016 11:26:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B2=BE=E5=93=81=E8=AF=BE=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=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 @@ +
+ +
\ 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