管理员界面增加精品课程的设置

This commit is contained in:
cxt 2016-04-15 11:26:56 +08:00
parent 96accf1e7a
commit 143f3f8f9a
8 changed files with 148 additions and 4 deletions

View File

@ -63,6 +63,33 @@ class AdminController < ApplicationController
end end
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 def course_resource_list

View File

@ -0,0 +1,32 @@
<td style="text-align: center;">
<%= course.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=course.name%>'>
<span>
<%= link_to(course.name, course_path(course.id)) %>
</span>
</td>
<td align="center">
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
</td>
<td align="center">
<%= studentCount(course) %>
</td>
<td class="center">
<%= course.homework_commons.count%>
</td>
<td class="center">
<%= student_works_num(course) %>
</td>
<td class="center">
<%= visable_attachemnts_incourse(course).count%>
</td>
<td class="center">
<%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %>
</td>
<td class="center">
<%= course.course_activities.count%>
</td>
<td class="buttons">
<%= link_to( course.is_excellent == 1 || course.excellent_option == 1 ? "取消精品" : "设为精品", { :controller => 'admin', :action => 'set_excellent_course', :id => course.id },:remote=>true, :class => 'icon-del') %>
</td>

View File

@ -0,0 +1,7 @@
<div class="tabs">
<ul>
<li><%= link_to '精品课程', {:action => 'excellent_courses'}, class: "#{current_page?(excellent_courses_path)? 'selected' : nil }" %></li>
<li><%= link_to '全部课程', {:action => 'excellent_all_courses'}, class: "#{current_page?(excellent_all_courses_path)? 'selected' : nil }" %></li>
</ul>
</div>

View File

@ -13,9 +13,7 @@
</label> </label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %> <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %> <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<a class="icon icon-reload" onclick="$('#name').val('')" style="cursor: pointer;text-decoration: none;"> <%= link_to l(:button_clear), {:controller => 'admin', :action => 'courses'},:remote => true, :class => 'icon icon-reload' %>
<%= l(:button_clear)%>
</a>
</fieldset> </fieldset>
<% end %> <% end %>
&nbsp; &nbsp;

View File

@ -0,0 +1,71 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
<h3>
精品课程列表
</h3>
<%= render 'tab_excellent_courses' %>
<h3>
全部课程列表
</h3>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<label for='name'>
课程:
</label>
<%= 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' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 25px;">
序号
</th>
<th style="width: 120px;">
课程名
</th>
<th style="width: 50px;">
主讲老师
</th>
<th style="width: 30px;">
学生数
</th>
<th style="width: 25px;">
作业数
</th>
<th style="width: 25px;">
作品数
</th>
<th style="width: 25px;">
资源数
</th>
<th style="width: 50px;">
帖子数
</th>
<th style="width: 50px;">
动态数
</th>
<th style="width: 40px;">
</tr>
</tr>
</thead>
<tbody>
<% @courses.each do |course| %>
<tr class="<%= cycle("odd", "even") %>" id="tr_<%= course.id %>">
<%= render :partial => 'course_detail_tr', :locals => {:course => course} %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_excellent_courses_list)) -%>

View File

@ -1,3 +1,9 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
<h3>
<%=l(:label_excellent_courses_list)%>
</h3>
<%= render 'tab_excellent_courses' %>
<h3> <h3>
<%=l(:label_excellent_courses_list)%> <%=l(:label_excellent_courses_list)%>
</h3> </h3>

View File

@ -0,0 +1 @@
$("#tr_<%=@course.id %>").html("<%=escape_javascript(render :partial => 'course_detail_tr', :locals => {:course => @course}) %>");

View File

@ -950,7 +950,9 @@ RedmineApp::Application.routes.draw do
match 'admin', :to => 'admin#index', :via => :get match 'admin', :to => 'admin#index', :via => :get
match 'admin/projects', :via => :get match 'admin/projects', :via => :get
get 'admin/courses' 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/course_resource_list'
get 'admin/project_resource_list' get 'admin/project_resource_list'
match 'admin/users', :via => :get match 'admin/users', :via => :get