diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 09124f79..cf976f6d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -182,9 +182,9 @@ class ProjectsController < ApplicationController @s_type = 2 end else - @projects = sort_project_demo 1, "course_ac_para desc", @project_pages.offset, @limit - @s_type = 1 - # @projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all + # @projects = sort_project_demo 1, "course_ac_para desc", @project_pages.offset, @limit + @s_type = 0 + @projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all # @s_type = 0 end respond_to do |format| diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 6e92631a..1394180e 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -66,18 +66,18 @@ module ProjectsHelper content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") end @@ -243,7 +243,7 @@ module ProjectsHelper end end - def eventToLanguageCourse event_type, project + def eventToLanguageCourse event_type, project case event_type when "issue-note" l :label_issue @@ -286,7 +286,17 @@ module ProjectsHelper WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ") end - def method_name - + # 判断课程是否结束 + def course_timeout? project + return true if (project.nil? && project.course_extra.nil?) + courses_year = project.course_extra.time + current_year = Time.now.year + if(courses_year >= current_year) + return false + elsif( (courses_year < current_year) && (Time.now.month < 3) ) + return false + else + return true + end end end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 7d93d0cd..519803a9 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -21,6 +21,10 @@ module WelcomeHelper include CoursesHelper + def find_new_course limit=15 + Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 1).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all + end + def find_all_hot_project limit=15 sort_project_by_hot limit end diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 53b05742..9f39d376 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -34,7 +34,7 @@ <%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%>

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(@bid.courses.first.name, homework_project_path(@bid.courses.first)) %> > + <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > <%=link_to(@bid.name, respond_path(@bid)) %>

@@ -49,7 +49,7 @@ 课程名: - <%= link_to @bid.courses.first.name, homework_project_path(@bid.courses.first) %> + <%= link_to @bid.courses.first.name.to_s, homework_project_path(@bid.courses.first) if @bid.courses.first %> @@ -149,7 +149,7 @@ <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show' },:class => link_class(:respond)%>
  • - <% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %> + <% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %> <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%> <% else %> <%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%> diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb index ccee1bc2..df73b75e 100644 --- a/app/views/projects/_course.html.erb +++ b/app/views/projects/_course.html.erb @@ -47,7 +47,13 @@

    +<% if(!course_timeout? @project) %> <%= join_in_course_for_list(@project, User.current,['regular'])%> +<% else %> + + 课程学期已结束 + +<% end -%>
    diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index affbc5f8..1f34be97 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -249,3 +249,8 @@ <% end %> + \ No newline at end of file diff --git a/app/views/users/user_courses.html.erb b/app/views/users/user_courses.html.erb index eb3635cb..aa4a366f 100644 --- a/app/views/users/user_courses.html.erb +++ b/app/views/users/user_courses.html.erb @@ -3,3 +3,12 @@ <% else %> <%= render :partial => 'my_joinedcourse' %> <% end %> + diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index bdfc53a1..9d6c7e64 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -48,3 +48,9 @@ <% end %> <%= call_hook :view_account_left_bottom, :user => @user %> + diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 438d66fc..69636a71 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -106,11 +106,11 @@ <%= stylesheet_link_tag 'welcome' %>
    -

    热门课程

    +

    新开课程

    <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}, :target => "_blank" %>
      - <% find_all_hot_course.map do |project| break if(project == find_all_hot_course[5]) %> + <% find_new_course(10).map do |project| %>
    • <% if get_avatar?(project)%> @@ -125,7 +125,8 @@ 学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1', :target => "_blank" %>

      - <%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %> + <%= content_tag "div", " ".html_safe< "d-p-project-intro", :style => 'display:inline-block; position:relative;float:right;color:#ff4800;' %> + <%= content_tag "span", " ".html_safe+project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description.to_s %>

    • @@ -160,7 +161,7 @@
    -

    +

    问题和反馈动态 <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> @@ -168,8 +169,8 @@ <%= link_to "更多>>", forums_path %>
      - <% find_new_forum_topics(4).each do |topic|%> -
    • + <% find_new_forum_topics(11).each do |topic|%> +
    •       <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>