parent
9f1d0d3437
commit
74a9aa14d6
|
@ -28,6 +28,11 @@ class SchoolController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取制定学校开设的课程数
|
||||||
|
def course_count school_id
|
||||||
|
School.find(school_id).courses.count
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,30 @@ module WelcomeHelper
|
||||||
# (c1.take(max)+c2).take(sum)
|
# (c1.take(max)+c2).take(sum)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#查找所有学校按每个学校开设课程数量降序排序
|
||||||
|
#page 分页查询开始条数的编号,从0开始
|
||||||
|
#limit 分页查询的数量
|
||||||
|
def find_maxmin_course_school page,limit
|
||||||
|
School.find_by_sql("SELECT *,(SELECT COUNT(*) FROM courses WHERE school_id = schools.id) AS a
|
||||||
|
FROM schools
|
||||||
|
ORDER BY a DESC LIMIT #{page},#{limit}")
|
||||||
|
#School.where(" id IN (SELECT school_id FROM courses GROUP BY school_id)").limit limit;
|
||||||
|
#School.order("#{School.course_count}").limit(limit).all
|
||||||
|
#@school = School.all.sort
|
||||||
|
#@school.each do |s|
|
||||||
|
# s.courses.count
|
||||||
|
#end
|
||||||
|
#result = []
|
||||||
|
#@school = School.all.to_ary
|
||||||
|
#i = 1
|
||||||
|
#for i in i < School.count
|
||||||
|
# j = i - 1
|
||||||
|
# for j in j > 0
|
||||||
|
# if @school[j].courses.count >
|
||||||
|
# end
|
||||||
|
#end
|
||||||
|
end
|
||||||
|
|
||||||
def find_miracle_project(sum, max_rate)
|
def find_miracle_project(sum, max_rate)
|
||||||
max = sum*(max_rate.to_f/10)
|
max = sum*(max_rate.to_f/10)
|
||||||
c1 = find_new_project(sum).to_a.dup
|
c1 = find_new_project(sum).to_a.dup
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= stylesheet_link_tag 'welcome' %>
|
<%= stylesheet_link_tag 'welcome' %>
|
||||||
<%= javascript_include_tag 'welcome' %>
|
<%= javascript_include_tag 'welcome' %>
|
||||||
<script type="text/javascript" language="javascript">
|
<script type="text/javascript" language="javascript" xmlns="http://www.w3.org/1999/html">
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$("#main").find("a").attr("target", "_blank");
|
$("#main").find("a").attr("target", "_blank");
|
||||||
|
@ -62,6 +62,36 @@
|
||||||
<span><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %></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">
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul class="d-p-projectlist">
|
||||||
|
<% if(find_miracle_course(10, 7,params[:school_id]).map.count == 0) %>
|
||||||
|
<h1></h1>
|
||||||
|
<p id="errorExplanation">
|
||||||
|
未开设任何课程,您可以查看其他学校课程
|
||||||
|
<br/>
|
||||||
|
</p>
|
||||||
|
<h1></h1>
|
||||||
|
<% find_maxmin_course_school(0,9).each do |school| %>
|
||||||
|
<li class='<%= cycle("odd", "even") %>' title=<%=school.name.to_s %>>
|
||||||
|
<div class='avatar'>
|
||||||
|
<img src="<%=school.logo_link %>" width="65" height="65">
|
||||||
|
</div>
|
||||||
|
<div class='text_nowrap' style="padding-left: 15px; padding-top: 8px">
|
||||||
|
[<%=school.province %>]
|
||||||
|
<%= link_to( "#{school.name}", :school_id =>"#{school.id}")%>
|
||||||
|
</div>
|
||||||
|
<div class='text_nowrap' style="padding-left: 15px; padding-top: 8px">
|
||||||
|
<span class=''>
|
||||||
|
<a href="/project/course?project_type=1">课程</a> 数: <%=school.courses.count %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class='join_course_link'>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
<% find_miracle_course(10, 7,params[:school_id]).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'>
|
||||||
|
@ -85,7 +115,7 @@
|
||||||
<%#=course.try(:teacher).try(:name)%>
|
<%#=course.try(:teacher).try(:name)%>
|
||||||
</span>
|
</span>
|
||||||
</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>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class='join_course_link'>
|
<div class='join_course_link'>
|
||||||
|
@ -97,12 +127,13 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<% end; reset_cycle %>
|
<% end; reset_cycle %>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
|
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
|
||||||
<h3 style="padding-bottom:px ;margin-left: 5px; color: #e8770d;">
|
<h3 style="padding-bottom:0px ;margin-left: 5px; color: #e8770d;">
|
||||||
<strong>问题和反馈动态</strong>
|
<strong>问题和反馈动态</strong>
|
||||||
<%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
|
<%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
|
||||||
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
|
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
|
||||||
|
@ -117,11 +148,11 @@
|
||||||
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>
|
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;"><%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前</span>
|
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size:9pt !important;;"><%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前</span>
|
||||||
<span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;">
|
<span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;">
|
||||||
由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %> 发表
|
由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %> 发表
|
||||||
</span>
|
</span>
|
||||||
<span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;">回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)</span>
|
<span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size:9pt !important;;">回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in New Issue