已经实训过的跳转问题
This commit is contained in:
parent
af959a1260
commit
374323eb32
|
@ -870,7 +870,7 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TrainintTask.status 0:评测中 1:评测成功 2:评测惊醒中
|
# TrainintTask.status 0:评测中 1:评测成功 2:评测进行中
|
||||||
# 非项目成员、非实训子项目不允许执行该方法
|
# 非项目成员、非实训子项目不允许执行该方法
|
||||||
def task_execute
|
def task_execute
|
||||||
if !@project.is_child_training_project? || !User.current.member_of?(@project)
|
if !@project.is_child_training_project? || !User.current.member_of?(@project)
|
||||||
|
@ -943,22 +943,24 @@ class ProjectsController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
original_tasks_count = original_project.training_tasks.count
|
original_tasks_count = original_project.training_tasks.count
|
||||||
position = @training_task.try(:position) + 1
|
position = @training_task.try(:position)
|
||||||
# 测试,默认成功
|
# 测试,默认成功
|
||||||
if status == 0
|
if status == 0
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
if position <= original_tasks_count
|
if position <= original_tasks_count
|
||||||
# 继续发布下一个任务
|
# 继续发布下一个任务
|
||||||
publish_training_tasks original_project_id, @training_task.project_id, position
|
publish_training_tasks original_project_id, @training_task.project_id, position+1 if position < original_tasks_count
|
||||||
@training_task.update_attribute(:status, 1)
|
@training_task.update_attribute(:status, 1)
|
||||||
end
|
end
|
||||||
# 创建一条回复提醒
|
# 创建一条回复提醒
|
||||||
content = position == original_tasks_count ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务"
|
content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务"
|
||||||
add_training_task_journal(content, original_project.user_id)
|
add_training_task_journal(content, original_project.user_id)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
|
content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
|
||||||
add_training_task_journal(content, original_project.user_id)
|
add_training_task_journal(content, original_project.user_id)
|
||||||
|
# 失败的时候可以继续提交
|
||||||
|
@training_task.update_attribute(:status, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
TO
|
TO
|
||||||
<%= link_to activity.project.name.to_s+" | 实训任务", project_training_tasks_path(activity.project), :class => "newsBlue ml15"%>
|
<%= link_to activity.project.name.to_s+" | 实训任务", project_training_tasks_path(activity.project), :class => "newsBlue ml15"%>
|
||||||
</div>
|
</div>
|
||||||
<% if User.current.logged? && is_project_manager?(User.current.id, project_id) || activity.author_id == User.current.id %>
|
<% if !@project.is_child_training_project? && User.current.logged? && (is_project_manager?(User.current.id, project_id) || activity.author_id == User.current.id) %>
|
||||||
<div class="homepagePostSetting">
|
<div class="homepagePostSetting">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="homepagePostSettingIcon">
|
<li class="homepagePostSettingIcon">
|
||||||
|
|
|
@ -17,21 +17,28 @@
|
||||||
该项目还没有创建版本库,暂时不支持实训
|
该项目还没有创建版本库,暂时不支持实训
|
||||||
</li>
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% if has_forked_cur_project(@project) %>
|
||||||
<li class="center mb5" style="line-height:20px">
|
<li class="center mb5" style="line-height:20px">
|
||||||
<% if has_forked_cur_project(@project) %>
|
您已经实训过该项目,点击“确定”将会跳转到您的实训项目主页,请问您是否继续?
|
||||||
您已经实训过该项目,点击“确定”将会跳转到您的实训项目主页,请问您是否继续?
|
|
||||||
<% elsif @project.training_tasks.count == 0 %>
|
|
||||||
该项目还没有创建实训任务,暂时不支持开启实训
|
|
||||||
<% else %>
|
|
||||||
实训将在后台为您创建一个新的同名项目,并为您推送第一个任务,请问您是否继续?
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="mt10">
|
<li class="mt10">
|
||||||
<label class="mr27"> </label>
|
<label class="mr27"> </label>
|
||||||
<a href="javascript:void(0);" class="sy_btn_grey fl " onclick="hideModal()">取 消</a>
|
<a href="javascript:void(0);" class="sy_btn_grey fl " onclick="hideModal()">取 消</a>
|
||||||
<%= link_to "确 定", {:controller => 'projects', :action => 'training_project_extend'}, :class => "sy_btn_blue fl ml20", :onclick => "hideModal();", :target => "_blank" %>
|
<% project = Project.where(:forked_from_project_id => @project.id, :user_id => User.current.id).first %>
|
||||||
|
<%= link_to "确 定", project_path(project), :class => "sy_btn_blue fl ml20", :onclick => "hideModal();", :target => "_blank" %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<li class="center mb5" style="line-height:20px">
|
||||||
|
实训将在后台为您创建一个新的同名项目,并为您推送第一个任务,请问您是否继续?
|
||||||
|
</li>
|
||||||
|
<li class="mt10">
|
||||||
|
<label class="mr27"> </label>
|
||||||
|
<a href="javascript:void(0);" class="sy_btn_grey fl " onclick="hideModal()">取 消</a>
|
||||||
|
<%= link_to "确 定", {:controller => 'projects', :action => 'training_project_extend'}, :class => "sy_btn_blue fl ml20", :onclick => "hideModal();", :target => "_blank" %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue