修正课程首页错误
This commit is contained in:
parent
2d9e0d507e
commit
2a6cbe28f0
|
@ -75,8 +75,7 @@ class WelcomeController < ApplicationController
|
|||
redirect_to projects_search_path(:name => search_condition,
|
||||
:project_type => Project::ProjectType_project)
|
||||
when :courses
|
||||
redirect_to projects_search_path(:name => search_condition,
|
||||
:project_type => Project::ProjectType_course)
|
||||
redirect_to courses_search_path(:name => search_condition)
|
||||
when :users
|
||||
redirect_to users_search_path(:name => search_condition)
|
||||
when :users_teacher
|
||||
|
|
|
@ -83,7 +83,8 @@ module WelcomeHelper
|
|||
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
||||
#
|
||||
# Returns project&courses array
|
||||
def find_miracle_course(sum=10, max_rate=7, school_id)
|
||||
# 原来的取课程逻辑
|
||||
def find_miracle_course_base(sum=10, max_rate=7, school_id)
|
||||
|
||||
if User.current.user_extensions.school.nil? and school_id.nil?
|
||||
Project.active.visible.course_entities.
|
||||
|
@ -133,6 +134,52 @@ module WelcomeHelper
|
|||
# (c1.take(max)+c2).take(sum)
|
||||
end
|
||||
|
||||
#获取课程列表
|
||||
# add by nwb
|
||||
def find_miracle_course(sum=10, max_rate=7, school_id)
|
||||
if User.current.user_extensions.school.nil? and school_id.nil?
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
group('members.course_id').
|
||||
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum
|
||||
|
||||
else
|
||||
if school_id.nil?
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id).
|
||||
group('members.course_id').
|
||||
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum
|
||||
else
|
||||
if school_id == "0"
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
group('members.course_id').
|
||||
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum
|
||||
else
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
where("#{Course.table_name}.school_id = ?", school_id).
|
||||
group('members.course_id').
|
||||
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum
|
||||
end
|
||||
end
|
||||
end
|
||||
# else
|
||||
# Project.active.visible.course_entities.
|
||||
# joins(:course_extra).
|
||||
# joins(:memberships).
|
||||
# where("#{Course.table_name}.school_id = ?", school_id).
|
||||
# group('members.project_id').
|
||||
# reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
||||
# end
|
||||
# max = sum*(max_rate.to_f/10)
|
||||
# c1 = find_new_course(sum).to_a.dup
|
||||
# c2 = find_all_hot_course(sum).to_a.dup
|
||||
# c2 = c2 - c1
|
||||
# (c1.take(max)+c2).take(sum)
|
||||
end
|
||||
|
||||
#查找所有学校按每个学校开设课程数量降序排序
|
||||
#page 分页查询开始条数的编号,从0开始
|
||||
#limit 分页查询的数量
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<%
|
||||
select_option = []
|
||||
(select_option << ['项目', 'projects']) if project_type == Project::ProjectType_project
|
||||
(select_option << ['课程', 'courses']) if project_type == Project::ProjectType_course
|
||||
select_option << ['用户', 'users']
|
||||
#select_option << ['教师', 'users_teacher'],
|
||||
#select_option << ['学生', 'users_student']
|
||||
%>
|
||||
<style type="text/css">
|
||||
form #q, form #search_type{
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
margin: 0px;
|
||||
padding: 5px;
|
||||
height: 33px;
|
||||
}
|
||||
form #q{
|
||||
font-size: 13px;
|
||||
border-top-left-radius: 5px;
|
||||
border-bottom-left-radius: 5px;
|
||||
border-right: none;
|
||||
|
||||
}
|
||||
form #search_type{
|
||||
font-size: 13px;
|
||||
color: #363739;
|
||||
border-top-right-radius: 5px;
|
||||
border-bottom-right-radius: 5px;
|
||||
border-bottom-left-radius: 0px;
|
||||
border-top-left-radius: 0px;
|
||||
border-left: 1px outset #83A9A9;
|
||||
margin-left: -4px;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
text-indent: 0.01px;
|
||||
text-overflow: '';
|
||||
}
|
||||
.search_widget{
|
||||
display:inline-block;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.search_widget:hover{
|
||||
box-shadow: 0px 0px 3px #56B4EF;
|
||||
}
|
||||
<%#完了把上面东西放到 .css 里%>
|
||||
</style>
|
||||
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %>
|
||||
<div class="project-search" style="float: right">
|
||||
<div class='search_widget'>
|
||||
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', :size => 27 %>
|
||||
<%= select_tag(:search_type, options_for_select(select_option) ) %>
|
||||
</div>
|
||||
<%#= hidden_field_tag 'project_type', project_type %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -62,7 +62,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="search-bar" id="search-bar">
|
||||
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
|
||||
<%= render :partial => "search_course", :locals => {:project_type => Project::ProjectType_course}%>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
@ -108,10 +108,10 @@
|
|||
</div>
|
||||
<div class='desc_item text_nowrap' style="width: 310px;">
|
||||
[<%= get_course_term project %>]
|
||||
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
|
||||
<%= link_to( project.name, course_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
|
||||
(<%= "#{studentCount(project)}人" %>)
|
||||
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
|
||||
(<%=link_to "#{files_count}份", project_files_path(project) %>资料)
|
||||
(<%=link_to "#{files_count}份", course_files_path(project) %>资料)
|
||||
</div>
|
||||
<!-- <div class='desc_item' style="">
|
||||
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
|
||||
|
@ -130,11 +130,11 @@
|
|||
<% else %>
|
||||
<% if school_course.count < 9 %>
|
||||
<span>
|
||||
<%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => nil} %>
|
||||
<%= link_to "更多>>", {:controller => 'courses', :action => 'course', :school_id => nil} %>
|
||||
</span>
|
||||
<% else %>
|
||||
<span>
|
||||
<%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %>
|
||||
<%= link_to "更多>>", {:controller => 'courses', :action => 'course', :school_id => params[:school_id]} %>
|
||||
</span>
|
||||
<% end %>
|
||||
<div class="d-p-projectlist-box">
|
||||
|
@ -150,7 +150,7 @@
|
|||
<!-- 上左下右 -->
|
||||
<div class='desc_item' >
|
||||
<span class=''>
|
||||
<% course = Course.find_by_extra(project.identifier) %>
|
||||
<% course = project %>
|
||||
<%=link_to course.school.name.try(:gsub, /(.+)$/, '\1:'),options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'} %>
|
||||
</span>
|
||||
<span class='font_bolder'>
|
||||
|
@ -159,10 +159,10 @@
|
|||
</div>
|
||||
<div class='desc_item text_nowrap' style="width: 310px;">
|
||||
[<%= get_course_term project %>]
|
||||
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
|
||||
<%= link_to( project.name, course_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
|
||||
(<%= "#{studentCount(project)}人" %>)
|
||||
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
|
||||
(<%=link_to "#{files_count}份", project_files_path(project) %>资料)
|
||||
(<%=link_to "#{files_count}份", course_files_path(project) %>资料)
|
||||
</div>
|
||||
|
||||
<div class='join_course_link'>
|
||||
|
|
|
@ -573,7 +573,8 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
match 'projects/course', :to => 'courses#course', :as => 'course'
|
||||
match 'projects/course', :to => 'courses#course', :as => 'courses_course'
|
||||
match 'courses/search', :to => 'courses#search'
|
||||
# add by nwb
|
||||
# 课程路由设置
|
||||
resources :courses do
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140626012511) do
|
||||
ActiveRecord::Schema.define(:version => 20140701075839) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -924,6 +924,7 @@ ActiveRecord::Schema.define(:version => 20140626012511) do
|
|||
|
||||
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
||||
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
||||
add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type"
|
||||
|
||||
create_table "tags", :force => true do |t|
|
||||
t.string "name"
|
||||
|
|
Loading…
Reference in New Issue