diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 98f6316a..ebefdf2b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -177,11 +177,13 @@ class ProjectsController < ApplicationController def course @project_type = params[:project_type] + @school_id = params[:school_id] per_page_option = 10 @projects_all = Project.active.visible. 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_pages = Paginator.new @project_count, per_page_option, params['page'] diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index ec991368..a2f6a348 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -1,4 +1,10 @@ class SchoolController < ApplicationController + + + def index + + end + def get_options @school = School.where("province = ?", params[:province]) p = params[:province] @@ -7,11 +13,22 @@ class SchoolController < ApplicationController @school.each do |s| #options << "" - options << "
  • #{s.name}
  • " + options << "
  • #{s.name}
  • " end render :text => options end + + def get_schoollist + @school = School.where("province = ?", params[:province]) + + options = "" + @school.each do |s| + options << "
  • #{s.name}
  • " + end + + render :text => options + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ad90f894..9d18f81c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1579,9 +1579,14 @@ module ApplicationHelper 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'} + + school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'} + + #@nav_dispaly_project_label nav_list = Array.new 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_teacher_all_link) if @nav_dispaly_teacher_all_label diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 9970ee9c..b622e681 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -56,12 +56,49 @@ module WelcomeHelper # # => 前7个项目为新课程,后面三个是参与人数最多的 # # Returns project&courses array - def find_miracle_course(sum=10, max_rate=7) - 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 + def find_miracle_course(sum=10, max_rate=7, school_id) + + if User.current.user_extensions.school.nil? and school_id.nil? + 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 +# 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) # c1 = find_new_course(sum).to_a.dup # c2 = find_all_hot_course(sum).to_a.dup diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 13a6ec43..bec07145 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -3,7 +3,7 @@ diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb index f55a80db..11da9077 100644 --- a/app/views/projects/_course.html.erb +++ b/app/views/projects/_course.html.erb @@ -16,7 +16,8 @@ <%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> <% @admin = @project.project_infos%> <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> - <%= @admin.first.user.user_extensions.occupation %> + + <%= @project.course_extra.school.name %> <% end %>

    diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb new file mode 100644 index 00000000..ad952302 --- /dev/null +++ b/app/views/school/index.html.erb @@ -0,0 +1,42 @@ + + + + + +

    +

    + 全部学校 +

    +

    + 请选择省份:<%= select_tag "province", + options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), + :onclick => "get_school(this.value)" %> +

    +
    +
    + +
    + diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 1f498fb5..03710844 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -1,223 +1,224 @@ -<%= stylesheet_link_tag 'welcome' %> - - - - -
    - -
    -
    - <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> , <%= l(:label_welcome_trustie_course_description) %> -
    - -
    -
    -
    - -
    - - -
    -

    新开课程

    - <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1} %> -
    - -
    -
    - - -
    -

    - 问题和反馈动态 - <%= 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 "更多>>", forums_path %> -
    - -
    -
    -
    - -
    -
    - - - - - - - -
    当前网站状态活跃课程: <%=@courseCount%>高校: 2个教师: <%=@teacherCount%> 名学生: <%=@studentCount%> 名 -
    -
    +<%= stylesheet_link_tag 'welcome' %> + + + + +
    + +
    +
    + <%= School.find(params[:school_id]).name %>
    + <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %>
    , <%= l(:label_welcome_trustie_course_description) %> +
    + +
    +
    +
    + +
    + + +
    +

    新开课程

    + <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %> +
    +
      + <% find_miracle_course(10, 7,params[:school_id]).map do |project| %> +
    • > +
      + <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> +
      + +
      + [<%= 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 "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) + <% 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) %>资料) +
      +
      + + <% course = Course.find_by_extra(project.identifier) %> + <%= course.teacher.user_extensions.occupation.try(:gsub, /(.+)$/, '\1:') %> + + + <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> + <%#=course.try(:teacher).try(:name)%> + +
      + + +
    • + <% end; reset_cycle %> +
    +
    +
    + + +
    +

    + 问题和反馈动态 + <%= 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 "更多>>", forums_path %> +
    +
      + <% find_new_forum_topics(10).each do |topic|%> +
    • +
      +       + <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> + +
      + <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 + + 由 <%= 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.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>) +
      +
    • + <% end %> +
    +
    +
    +
    + +
    +
    + + + + + + + +
    当前网站状态活跃课程: <%=@courseCount%>高校: 2个教师: <%=@teacherCount%> 名学生: <%=@studentCount%> 名 +
    +
    \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 079ad450..bb198335 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1759,6 +1759,10 @@ zh: label_has_been: 已经被 label_course_userd_by: 个课程引用 + + label_school_all: 学校列表 + + role_of_course: 课程角色 label_student: 学生 diff --git a/config/routes.rb b/config/routes.rb index bf6f3cee..50b38d33 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -582,7 +582,8 @@ RedmineApp::Application.routes.draw do post '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 match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 867f7624..6ac1966a 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -216,6 +216,95 @@ body { text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); 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; +} + + +/*********************************************************************************************************************/ /* 按钮