diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 8da82afd3..57fa7ada5 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -391,12 +391,17 @@ class HomeworkCommonController < ApplicationController
unless homeworks.nil?
homeworks.each do |h|
if h.homework_type == 3
- student_works = h.student_works.where("project_id != 0")
+ student_works = h.student_work_projects.where("is_leader = 1")
time = h.updated_at
unless student_works.nil?
student_works.each do |s|
project = Project.find s.project_id
unless project.nil? && project.gpid.nil?
+ project_time=project.updated_on
+ project_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last
+ if time < project_time
+ time = project_time
+ end
begin
# gitlab端获取默认分支
g = Gitlab.client
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index fc0cf99e1..ca81ac1c1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2960,6 +2960,14 @@ int main(int argc, char** argv){
return sort_projects
end
end
+
+ def project_sort_first projects
+ unless projects.empty?
+ project_ids = '('+projects.map{|pro|pro.project_id}.join(',')+')'
+ sort_projects = ForgeActivity.find_by_sql("SELECT updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} ORDER BY updated_at DESC limit 1")
+ return sort_projects
+ end
+ end
end
def user_url_in_org(user_id)
diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb
index 33e2835dd..068d50437 100644
--- a/app/views/organizations/_org_course_homework.html.erb
+++ b/app/views/organizations/_org_course_homework.html.erb
@@ -182,7 +182,8 @@
<% sort_projects = project_sort_update projects %>
- # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_url_in_org(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
+ <% first_pro = project_sort_first(projects).first %>
+ # <%=time_from_now first_pro.first.updated_at %><%= link_to User.find(first_pro.first.user_id).show_name, user_activities_url_in_org(first_pro.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% sort_projects.each_with_index do |pro, i| %>
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb
index f598c7404..2d2b53779 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -191,7 +191,8 @@
<% sort_projects = project_sort_update projects %>
- # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
+ <% first_pro = project_sort_first(projects).first %>
+ # <%=time_from_now first_pro.first.updated_at %><%= link_to User.find(first_pro.first.user_id).show_name, user_activities_path(first_pro.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% sort_projects.each_with_index do |pro, i| %>
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index 2c632b0df..30bec6685 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -196,7 +196,8 @@
<% sort_projects = project_sort_update projects %>
- # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
+ <% first_pro = project_sort_first(projects).first %>
+ # <%=time_from_now first_pro.updated_at %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% sort_projects.each_with_index do |pro, i| %>