Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
Conflicts: db/schema.rb
This commit is contained in:
commit
5abee0a06c
|
@ -75,8 +75,7 @@ class WelcomeController < ApplicationController
|
||||||
redirect_to projects_search_path(:name => search_condition,
|
redirect_to projects_search_path(:name => search_condition,
|
||||||
:project_type => Project::ProjectType_project)
|
:project_type => Project::ProjectType_project)
|
||||||
when :courses
|
when :courses
|
||||||
redirect_to projects_search_path(:name => search_condition,
|
redirect_to courses_search_path(:name => search_condition)
|
||||||
:project_type => Project::ProjectType_course)
|
|
||||||
when :users
|
when :users
|
||||||
redirect_to users_search_path(:name => search_condition)
|
redirect_to users_search_path(:name => search_condition)
|
||||||
when :users_teacher
|
when :users_teacher
|
||||||
|
|
|
@ -83,7 +83,8 @@ module WelcomeHelper
|
||||||
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
||||||
#
|
#
|
||||||
# Returns project&courses array
|
# 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?
|
if User.current.user_extensions.school.nil? and school_id.nil?
|
||||||
Project.active.visible.course_entities.
|
Project.active.visible.course_entities.
|
||||||
|
@ -133,6 +134,52 @@ module WelcomeHelper
|
||||||
# (c1.take(max)+c2).take(sum)
|
# (c1.take(max)+c2).take(sum)
|
||||||
end
|
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开始
|
#page 分页查询开始条数的编号,从0开始
|
||||||
#limit 分页查询的数量
|
#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 %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-bar" id="search-bar">
|
<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>
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
<h3><strong>新开课程</strong></h3>
|
<h3><strong>新开课程</strong></h3>
|
||||||
<% school_course = find_miracle_course(10, 7,params[:school_id]) %>
|
<% school_course = find_miracle_course(10, 7,params[:school_id]) %>
|
||||||
<% if(school_course.count == 0) %>
|
<% if(school_course.count == 0) %>
|
||||||
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'course', :project_type => 1, :school_id => nil} %></span>
|
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span>
|
||||||
<div class="d-p-projectlist-box">
|
<div class="d-p-projectlist-box">
|
||||||
<ul class="d-p-projectlist">
|
<ul class="d-p-projectlist">
|
||||||
|
|
||||||
|
@ -108,10 +108,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class='desc_item text_nowrap' style="width: 310px;">
|
<div class='desc_item text_nowrap' style="width: 310px;">
|
||||||
[<%= get_course_term project %>]
|
[<%= 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)}人" %>)
|
(<%= "#{studentCount(project)}人" %>)
|
||||||
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
|
<% 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>
|
||||||
<!-- <div class='desc_item' style="">
|
<!-- <div class='desc_item' style="">
|
||||||
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
|
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
|
||||||
|
@ -130,11 +130,11 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if school_course.count < 9 %>
|
<% if school_course.count < 9 %>
|
||||||
<span>
|
<span>
|
||||||
<%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => nil} %>
|
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span>
|
<span>
|
||||||
<%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %>
|
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => params[:school_id]} %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="d-p-projectlist-box">
|
<div class="d-p-projectlist-box">
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
<!-- 上左下右 -->
|
<!-- 上左下右 -->
|
||||||
<div class='desc_item' >
|
<div class='desc_item' >
|
||||||
<span class=''>
|
<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'} %>
|
<%=link_to course.school.name.try(:gsub, /(.+)$/, '\1:'),options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'} %>
|
||||||
</span>
|
</span>
|
||||||
<span class='font_bolder'>
|
<span class='font_bolder'>
|
||||||
|
@ -159,10 +159,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class='desc_item text_nowrap' style="width: 310px;">
|
<div class='desc_item text_nowrap' style="width: 310px;">
|
||||||
[<%= get_course_term project %>]
|
[<%= 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)}人" %>)
|
(<%= "#{studentCount(project)}人" %>)
|
||||||
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
|
<% 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>
|
||||||
|
|
||||||
<div class='join_course_link'>
|
<div class='join_course_link'>
|
||||||
|
|
|
@ -573,7 +573,8 @@ RedmineApp::Application.routes.draw do
|
||||||
end
|
end
|
||||||
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
|
# add by nwb
|
||||||
# 课程路由设置
|
# 课程路由设置
|
||||||
resources :courses do
|
resources :courses do
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140701031909) do
|
ActiveRecord::Schema.define(:version => 20140701075839) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -925,6 +925,7 @@ ActiveRecord::Schema.define(:version => 20140701031909) do
|
||||||
|
|
||||||
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
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_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|
|
create_table "tags", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
|
Loading…
Reference in New Issue