添加课程排序方法

This commit is contained in:
nwb 2014-06-03 09:56:54 +08:00
parent e490f7979d
commit 9f948c971f
3 changed files with 60 additions and 32 deletions

View File

@ -122,6 +122,40 @@ module CoursesHelper
members members
end end
def sort_course(state, school_id)
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2')))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id)))
when 1
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected")
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2')))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id)))
when 2
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id)))
#gcm
when 3
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2')))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected")
end
#gcmend
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
def findCourseTime project def findCourseTime project
str = "" str = ""
begin begin

View File

@ -15,8 +15,8 @@
<p > <p >
<%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> <%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%>
<% @admin = @project.project_infos%> <% @admin = @project.project_infos%>
<%if @admin&&@adadminmin.first&&@admin.first.user&&@admin.first.user.user_extensions%> <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
<!-- <%= @.first.user.user_extensions.occupation %> --> <!-- <%= @admin.first.user.user_extensions.occupation %> -->
<%# unless @project.course_extra.school.nil? %> <%# unless @project.course_extra.school.nil? %>
<%= @project.course_extra.teacher.user_extensions.school.try(:name) %> <%= @project.course_extra.teacher.user_extensions.school.try(:name) %>
<%# end %> <%# end %>

View File

@ -6,49 +6,44 @@
<%= form_tag(courses_search_path, :method => :get) do %> <%= form_tag(courses_search_path, :method => :get) do %>
<table width="940px"> <table width="940px">
<tr> <tr>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_all) %></td> <td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td> <td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
<td rowspan="2"> <td rowspan="2">
<% if User.current.logged?%> <% if User.current.logged?%>
<%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type => (@course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> <% if User.current.user_extensions.identity == 0 %>
<%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 1}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %></td>
<% end %>
<% end %> <% end %>
</td> </td>
<td rowspan="2" > <td rowspan="2" >
<div class="course-search" style="float: right"> <div class="course-search" style="float: right">
<%= text_field_tag 'name', params[:name], :size => 30 %> <%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'course_type', params[:course_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="padding-left: 8px"> <td style="padding-left: 8px"><a><%= link_to request.host()+"/course", :controller => 'courses', :action => 'course', :course_type => 1 %> </a></td>
<a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> </a> <td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'course', :course_type => 1 %></td>
</td>
<td><%= link_to l(:field_homepage), home_path %>
> <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index', :course_type => 0 %></td>
</tr> </tr>
</table> </table>
<% end %> <% end %>
</div> </div>
<%= sort_courses(@s_type) %> <%= sort_course(@s_type, @course_type, @school_id)%>
<div id="courses-index">
<% if @courses %> <div id="projects-index">
<%= render_course_hierarchy(@courses) %> <%= render_project_hierarchy(@projects)%>
<% end %>
</div> </div>
<div class="pagination"> <div class="pagination">
<ul> <ul>
<% if @course_pages %> <%= pagination_links_full @project_pages, @project_count %>
<%= pagination_links_full @course_pages, @course_count %>
<% end %>
</ul> </ul>
</div> </div>
<% if User.current.logged? %> <% if User.current.logged? %>
<p style="text-align:right;"> <p style="text-align:right;">
<span class="my-course"><%= l(:label_my_courses) %></span> <span class="my-project"><%= l(:label_my_course) %></span>
</p> </p>
<% end %> <% end %>
@ -57,14 +52,13 @@
<% end %> <% end %>
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= form_tag({}, :method => :get) do %> <%= form_tag({}, :method => :get) do %>
<h3><%= l(:label_course_all) %></h3> <h3><%= l(:label_project_plural) %></h3>
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_courses) %></label> <label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label>
<p> <p>
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
</p> </p>
<% end %> <% end %>
<% end %> <% end %>
<% html_title(l(:label_course_all)) -%> <% html_title(l(:label_new_course)) -%>