线下作业
This commit is contained in:
parent
5a22e9a147
commit
3362ebe321
|
@ -27,6 +27,7 @@ class HomeworkCommonController < ApplicationController
|
|||
#@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
|
||||
@homework_commons = @course.homework_commons.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
|
||||
end
|
||||
#update_homework_time @homework_commons
|
||||
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
||||
@is_new = params[:is_new]
|
||||
|
||||
|
@ -409,8 +410,8 @@ class HomeworkCommonController < ApplicationController
|
|||
def update_homework_time homeworks
|
||||
unless homeworks.nil?
|
||||
homeworks.each do |h|
|
||||
if h.homework_type == 3
|
||||
student_works = h.student_work_projects.where("is_leader = 1")
|
||||
if h.homework_type == 3 && h.homework_detail_group.base_on_project == 1
|
||||
student_works = h.student_work_projects.where("is_leader = 1 && project_id != -1")
|
||||
time = h.updated_at
|
||||
unless student_works.nil?
|
||||
student_works.each do |s|
|
||||
|
@ -418,7 +419,7 @@ class HomeworkCommonController < ApplicationController
|
|||
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 format_time(time) < format_time(project_time)
|
||||
if time.strftime('%Y-%m-%d %H:%M:%S') < project_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
time = project_time
|
||||
end
|
||||
begin
|
||||
|
@ -428,21 +429,30 @@ class HomeworkCommonController < ApplicationController
|
|||
changesets = g.commits(project.gpid, :ref_name => default_branch)
|
||||
changesets_latest_coimmit = changesets[0]
|
||||
unless changesets[0].blank?
|
||||
if format_time(time) < format_time(changesets_latest_coimmit.created_at)
|
||||
if time.strftime('%Y-%m-%d %H:%M:%S') <changesets_latest_coimmit.created_at.strftime('%Y-%m-%d %H:%M:%S')
|
||||
time = changesets_latest_coimmit.created_at
|
||||
end
|
||||
end
|
||||
rescue
|
||||
logger.error("############## ==> update homework project time")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
puts h.updated_at
|
||||
puts time
|
||||
s_time = time
|
||||
if format_time(time) > format_time(h.updated_at)
|
||||
if time.strftime('%Y-%m-%d %H:%M:%S') > h.updated_at.strftime('%Y-%m-%d %H:%M:%S')
|
||||
h.update_column('updated_at', s_time)
|
||||
course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", 'HomeworkCommon', h.id).first
|
||||
if course_activity && (time.strftime('%Y-%m-%d %H:%M:%S') > course_activity.updated_at.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
course_activity.update_column('updated_at', s_time)
|
||||
end
|
||||
user_activity = UserActivity.where("act_type=? and act_id =?", 'HomeworkCommon', h.id).first
|
||||
if user_activity && (time.strftime('%Y-%m-%d %H:%M:%S') > user_activity.updated_at.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
user_activity.update_column('updated_at', s_time)
|
||||
end
|
||||
org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", 'HomeworkCommon', h.id).first
|
||||
if org_activity && (time.strftime('%Y-%m-%d %H:%M:%S') > org_activity.updated_at.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
org_activity.update_column('updated_at', s_time)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1048,9 +1048,18 @@ class UsersController < ApplicationController
|
|||
if homework.homework_type != 3
|
||||
unless homework.course.nil?
|
||||
name = homework.name
|
||||
name_str = name + "的作品提交"
|
||||
str = ""
|
||||
homework.course.student.each do |student|
|
||||
StudentWork.create(:name => "#{name}的作品提交", :homework_common_id => homework.id, :user_id => student.student_id)
|
||||
if str != ""
|
||||
str += ","
|
||||
end
|
||||
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
|
||||
end
|
||||
#('#{name}的作品提交',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')
|
||||
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
|
||||
#StudentWork.create(:name => "#{name}的作品提交", :homework_common_id => homework.id, :user_id => student.student_id)
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2681,8 +2681,8 @@ module ApplicationHelper
|
|||
|
||||
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
|
||||
def user_for_homework_common homework,is_teacher
|
||||
count = homework.student_works.has_committed.count
|
||||
if User.current.member_of_course?(homework.course)
|
||||
count = homework.student_works.has_committed.count
|
||||
if is_teacher #老师显示作品数量
|
||||
link_to "作品(#{count})", student_work_index_url_in_org(homework.id), :class => "c_blue"
|
||||
else #学生显示提交作品、修改作品等按钮
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<li >
|
||||
<span class="tit_fb ">编程代码:</span>
|
||||
<div class="showHworkP break_word"><pre id="work-src_<%= work.id%>" style="display: none;"><%= work.description if work.description%></pre><div class="fontGrey2 font_cus" id="work-code_<%= work.id%>">
|
||||
<div class="showHworkP break_word"><pre id="work-src_<%= work.id%>" style="display: none;"><%= work.description ? work.description : "该作品尚未提交相关内容。"%></pre><div class="fontGrey2 font_cus" id="work-code_<%= work.id%>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -195,8 +195,13 @@
|
|||
<% sort_projects = project_sort_update projects %>
|
||||
<div class="mt10 relatePWrap" id="relatePWrap_<%=user_activity_id %>">
|
||||
<div class="mr5 fontGrey2">
|
||||
<% 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"%>更新了项目,最近更新:
|
||||
<%# first_pro = sort_projects.first %>
|
||||
<% first_pro = Project.find sort_projects.first.project_id %>
|
||||
<% commit_time = first_pro.project_score.commit_time %>
|
||||
<% one_time = first_pro.updated_on %>
|
||||
<% one_forge_time=ForgeActivity.where("project_id=?",first_pro.id).last.updated_at if ForgeActivity.where("project_id=?",first_pro.id).last %>
|
||||
<% one_time= one_time > one_forge_time ? one_time : one_forge_time %>
|
||||
# <%=time_from_now !commit_time.nil? && format_time(commit_time) > format_time(one_time) ? commit_time : one_time %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% sort_projects.each_with_index do |pro, i| %>
|
||||
|
@ -219,7 +224,8 @@
|
|||
<% end %>
|
||||
<% com_time = project.project_score.commit_time %>
|
||||
<% time=project.updated_on %>
|
||||
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
|
||||
<% forge_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
|
||||
<% time= time > forge_time ? time : forge_time %>
|
||||
<p class="mh18"><span class="captainName" title="<%=(User.find project.user_id).show_name %>"><%=(User.find project.user_id).show_name %></span><span style="vertical-align: top;">(组长)</span></p>
|
||||
<p class="mh18"><%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %> <%= project.project_score.changeset_num %>提交</p>
|
||||
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
|
||||
|
|
|
@ -206,8 +206,12 @@
|
|||
<% sort_projects = project_sort_update projects %>
|
||||
<div class="mt10 relatePWrap" id="relatePWrap_<%=homework_common.id %>">
|
||||
<div class="mr5 fontGrey2">
|
||||
<% 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"%>更新了项目,最近更新:
|
||||
<% first_pro = Project.find sort_projects.first.project_id %>
|
||||
<% commit_time = first_pro.project_score.commit_time %>
|
||||
<% one_time = first_pro.updated_on %>
|
||||
<% one_forge_time=ForgeActivity.where("project_id=?",first_pro.id).last.updated_at if ForgeActivity.where("project_id=?",first_pro.id).last %>
|
||||
<% one_time= one_time > one_forge_time ? one_time : one_forge_time %>
|
||||
# <%=time_from_now !commit_time.nil? && format_time(commit_time) > format_time(one_time) ? commit_time : one_time %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% sort_projects.each_with_index do |pro, i| %>
|
||||
|
@ -230,7 +234,8 @@
|
|||
<% end %>
|
||||
<% com_time = project.project_score.commit_time %>
|
||||
<% time=project.updated_on %>
|
||||
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
|
||||
<% forge_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
|
||||
<% time= time > forge_time ? time : forge_time %>
|
||||
<p class="mh18"><span class="captainName" title="<%=(User.find project.user_id).show_name %>"><%=(User.find project.user_id).show_name %></span><span style="vertical-align: top;">(组长)</span></p>
|
||||
<p class="mh18"><%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %> <%= project.project_score.changeset_num %>提交</p>
|
||||
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=homework_common.id %>">
|
||||
|
|
Loading…
Reference in New Issue