学校-课程模式!
This commit is contained in:
parent
735f920e9d
commit
473a44d11a
|
@ -177,11 +177,13 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
def course
|
def course
|
||||||
@project_type = params[:project_type]
|
@project_type = params[:project_type]
|
||||||
|
@school_id = params[:school_id]
|
||||||
per_page_option = 10
|
per_page_option = 10
|
||||||
|
|
||||||
@projects_all = Project.active.visible.
|
@projects_all = Project.active.visible.
|
||||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
||||||
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course)
|
joins(:course_extra).
|
||||||
|
where("#{Project.table_name}.project_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id)
|
||||||
|
|
||||||
@project_count = @projects_all.count
|
@project_count = @projects_all.count
|
||||||
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
class SchoolController < ApplicationController
|
class SchoolController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def get_options
|
def get_options
|
||||||
@school = School.where("province = ?", params[:province])
|
@school = School.where("province = ?", params[:province])
|
||||||
p = params[:province]
|
p = params[:province]
|
||||||
|
@ -7,11 +13,22 @@ class SchoolController < ApplicationController
|
||||||
|
|
||||||
@school.each do |s|
|
@school.each do |s|
|
||||||
#options << "<option value=#{s.id}>#{s.name}</option>"
|
#options << "<option value=#{s.id}>#{s.name}</option>"
|
||||||
options << "<li><a id=#{s.id} onclick='test(this.id, this.text)'>#{s.name}</a></li>"
|
options << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id, this.text)'>#{s.name}</a></li>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
render :text => options
|
render :text => options
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_schoollist
|
||||||
|
@school = School.where("province = ?", params[:province])
|
||||||
|
|
||||||
|
options = ""
|
||||||
|
@school.each do |s|
|
||||||
|
options << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
|
||||||
|
end
|
||||||
|
|
||||||
|
render :text => options
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1579,9 +1579,14 @@ module ApplicationHelper
|
||||||
forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"}
|
forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"}
|
||||||
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
|
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
|
||||||
|
|
||||||
|
|
||||||
|
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
|
||||||
|
|
||||||
|
|
||||||
#@nav_dispaly_project_label
|
#@nav_dispaly_project_label
|
||||||
nav_list = Array.new
|
nav_list = Array.new
|
||||||
nav_list.push(home_link) if !@nav_dispaly_home_path_label
|
nav_list.push(home_link) if !@nav_dispaly_home_path_label
|
||||||
|
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label
|
||||||
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
|
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
|
||||||
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label
|
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,49 @@ module WelcomeHelper
|
||||||
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
||||||
#
|
#
|
||||||
# Returns project&courses array
|
# Returns project&courses array
|
||||||
def find_miracle_course(sum=10, max_rate=7)
|
def find_miracle_course(sum=10, max_rate=7, school_id)
|
||||||
Project.active.visible.course_entities.
|
|
||||||
joins(:course_extra).
|
if User.current.user_extensions.school.nil? and school_id.nil?
|
||||||
joins(:memberships).
|
Project.active.visible.course_entities.
|
||||||
group('members.project_id').
|
joins(:course_extra).
|
||||||
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
joins(:memberships).
|
||||||
|
group('members.project_id').
|
||||||
|
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
||||||
|
# elseif school_id.nil?
|
||||||
|
|
||||||
|
else
|
||||||
|
if school_id.nil?
|
||||||
|
Project.active.visible.course_entities.
|
||||||
|
joins(:course_extra).
|
||||||
|
joins(:memberships).
|
||||||
|
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id).
|
||||||
|
group('members.project_id').
|
||||||
|
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
||||||
|
else
|
||||||
|
if school_id == "0"
|
||||||
|
Project.active.visible.course_entities.
|
||||||
|
joins(:course_extra).
|
||||||
|
joins(:memberships).
|
||||||
|
group('members.project_id').
|
||||||
|
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
||||||
|
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
|
||||||
|
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)
|
# max = sum*(max_rate.to_f/10)
|
||||||
# c1 = find_new_course(sum).to_a.dup
|
# c1 = find_new_course(sum).to_a.dup
|
||||||
# c2 = find_all_hot_course(sum).to_a.dup
|
# c2 = find_all_hot_course(sum).to_a.dup
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(
|
$(document).ready(
|
||||||
function(){
|
function(){
|
||||||
$("#province").attr("href", "#OpenWindow")
|
$("#province").attr("href", "#WOpenWindow")
|
||||||
$("#province").leanModal({top: 100, closeButton: ".modal_close"});
|
$("#province").leanModal({top: 100, closeButton: ".modal_close"});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -128,11 +128,11 @@
|
||||||
<!-- <input id="occupation" readonly />-->
|
<!-- <input id="occupation" readonly />-->
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="OpenWindow">
|
<div id="WOpenWindow">
|
||||||
<a class="modal_close" href="#"></a>
|
<a class="modal_close" href="#"></a>
|
||||||
<h2>学校列表</h2>
|
<h2>学校列表</h2>
|
||||||
<div class="content" style="font-size: 13px">
|
<div class="content" style="font-size: 13px">
|
||||||
<ul id="schoollist">
|
<ul id="schoollist" class="school_list">
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
$("#occupation").val(id);
|
$("#occupation").val(id);
|
||||||
$("#occupation_name").val(name);
|
$("#occupation_name").val(name);
|
||||||
$("#lean_overlay").hide();
|
$("#lean_overlay").hide();
|
||||||
$("#OpenWindow").hide();
|
$("#WOpenWindow").hide();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
<%= 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&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
||||||
<%= @admin.first.user.user_extensions.occupation %>
|
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
||||||
|
<%= @project.course_extra.school.name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<p >
|
<p >
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
function get_school(value){
|
||||||
|
$.ajax({
|
||||||
|
type :"POST",
|
||||||
|
url :'/school/get_schoollist/'+encodeURIComponent(value),
|
||||||
|
data :'text',
|
||||||
|
success: function(data){
|
||||||
|
$("#schoollist").html(data);
|
||||||
|
|
||||||
|
//$("#schoollist").html(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function test(id){
|
||||||
|
location.href = "welcome/index?course.trustie.net&school_id="+id;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<a href="welcome/index?course.trustie.net&school_id=0">全部学校</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
请选择省份:<%= select_tag "province",
|
||||||
|
options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province),
|
||||||
|
:onclick => "get_school(this.value)" %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<ul id="schoollist" style="line-height: 25px">
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
|
@ -98,7 +98,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="main-content-bar">
|
<div class="main-content-bar">
|
||||||
<div class="welcome_left" >
|
<div class="welcome_left" >
|
||||||
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span><span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
|
<span class="font_welcome_trustie"><%= School.find(params[:school_id]).name %><br />
|
||||||
|
<%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span><span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
|
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
|
||||||
|
@ -112,10 +113,10 @@
|
||||||
|
|
||||||
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
|
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
|
||||||
<h3><strong>新开课程</strong></h3>
|
<h3><strong>新开课程</strong></h3>
|
||||||
<span><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1} %></span>
|
<span><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %></span>
|
||||||
<div class="d-p-projectlist-box">
|
<div class="d-p-projectlist-box">
|
||||||
<ul class="d-p-projectlist">
|
<ul class="d-p-projectlist">
|
||||||
<% find_miracle_course(10, 7).map do |project| %>
|
<% find_miracle_course(10, 7,params[:school_id]).map do |project| %>
|
||||||
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
|
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
|
||||||
<div class='avatar'>
|
<div class='avatar'>
|
||||||
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
|
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
|
||||||
|
|
|
@ -1759,6 +1759,10 @@ zh:
|
||||||
label_has_been: 已经被
|
label_has_been: 已经被
|
||||||
label_course_userd_by: 个课程引用
|
label_course_userd_by: 个课程引用
|
||||||
|
|
||||||
|
|
||||||
|
label_school_all: 学校列表
|
||||||
|
|
||||||
|
|
||||||
role_of_course: 课程角色
|
role_of_course: 课程角色
|
||||||
label_student: 学生
|
label_student: 学生
|
||||||
|
|
||||||
|
|
|
@ -582,7 +582,8 @@ RedmineApp::Application.routes.draw do
|
||||||
post 'school/get_options/:province', :to => 'school#get_options'
|
post 'school/get_options/:province', :to => 'school#get_options'
|
||||||
get 'school/get_options/:province', :to => 'school#get_options'
|
get 'school/get_options/:province', :to => 'school#get_options'
|
||||||
|
|
||||||
|
post 'school/get_schoollist/:province', :to => 'school#get_schoollist'
|
||||||
|
get 'school/get_schoollist/:province', :to => 'school#get_schoollist'
|
||||||
|
|
||||||
######added by nie
|
######added by nie
|
||||||
match 'tags/show_projects_tags',:to => 'tags#show_projects_tags'
|
match 'tags/show_projects_tags',:to => 'tags#show_projects_tags'
|
||||||
|
|
|
@ -216,6 +216,95 @@ body {
|
||||||
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
|
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
/*********************************************************************************************************************
|
||||||
|
* Wen的OpenWindow
|
||||||
|
*********************************************************************************************************************/
|
||||||
|
|
||||||
|
#WOpenWindow {
|
||||||
|
background: none repeat scroll 0 0 #FFFFFF;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
box-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
|
||||||
|
display: none;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
width: 1000px;
|
||||||
|
z-index: 100;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -202px;
|
||||||
|
opacity: 1;
|
||||||
|
position: fixed;
|
||||||
|
top: 200px;
|
||||||
|
}
|
||||||
|
#WOpenWindow .school_list{
|
||||||
|
width:1000px;
|
||||||
|
line-height: 20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
#WOpenWindow-header {
|
||||||
|
background: url("/images/showmodal/hd-bg.png") repeat scroll 0 0 transparent;
|
||||||
|
border-bottom: 1px solid #CCCCCC;
|
||||||
|
border-top-left-radius: 5px;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
padding: 18px 18px 14px;
|
||||||
|
}
|
||||||
|
#WOpenWindow-content{
|
||||||
|
-webkit-transition: all 0.2s linear 1s;
|
||||||
|
-o-transition: all 0.2s linear 1s;
|
||||||
|
-moz-transition: all 0.2s linear 1s;
|
||||||
|
transition: all 0.2s linear 1s;
|
||||||
|
border-top-left-radius: 5px;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
padding: 18px 18px 14px;
|
||||||
|
}
|
||||||
|
#WOpenWindow .content{
|
||||||
|
width: 1000px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#WOpenWindow .txt-fld {
|
||||||
|
border-bottom: 1px solid #EEEEEE;
|
||||||
|
padding: 14px 20px;
|
||||||
|
position: relative;
|
||||||
|
text-align: right;
|
||||||
|
width: 364px;
|
||||||
|
}
|
||||||
|
#WOpenWindow .txt-fld input {
|
||||||
|
background: none repeat scroll 0 0 #F7F7F7;
|
||||||
|
border-color: #CCCCCC #E7E6E6 #E7E6E6 #CCCCCC;
|
||||||
|
border-radius: 4px 4px 4px 4px;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
color: #222222;
|
||||||
|
font-family: "Helvetica Neue";
|
||||||
|
font-size: 1.2em;
|
||||||
|
outline: medium none;
|
||||||
|
padding: 8px;
|
||||||
|
width: 244px;
|
||||||
|
}
|
||||||
|
#WOpenWindow .txt-fld input.good_input {
|
||||||
|
background: url("/images/showmodal/good.png") no-repeat scroll 236px center #DEF5E1;
|
||||||
|
}
|
||||||
|
#WOpenWindow .btn-fld {
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 12px 20px 12px 130px;
|
||||||
|
width: 254px;
|
||||||
|
}
|
||||||
|
#WOpenWindow button {
|
||||||
|
background: none repeat scroll 0 0 #3F9D4A;
|
||||||
|
border: medium none;
|
||||||
|
border-radius: 4px 4px 4px 4px;
|
||||||
|
color: #FFFFFF;
|
||||||
|
float: right;
|
||||||
|
font-family: Verdana;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
overflow: visible;
|
||||||
|
padding: 7px 10px;
|
||||||
|
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* 按钮
|
/* 按钮
|
||||||
|
|
Loading…
Reference in New Issue