From 374323eb32694ca364370d4c36cb2eac3fe96e11 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 24 Feb 2017 17:43:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E8=BF=87=E7=9A=84=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 10 ++++---- .../projects/_act_training_tasks.html.erb | 2 +- .../_training_child_project_exec.html.erb | 23 ++++++++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 4eb7bddac..0f42be28e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -870,7 +870,7 @@ class ProjectsController < ApplicationController end end - # TrainintTask.status 0:评测中 1:评测成功 2:评测惊醒中 + # TrainintTask.status 0:评测中 1:评测成功 2:评测进行中 # 非项目成员、非实训子项目不允许执行该方法 def task_execute if !@project.is_child_training_project? || !User.current.member_of?(@project) @@ -943,22 +943,24 @@ class ProjectsController < ApplicationController return end original_tasks_count = original_project.training_tasks.count - position = @training_task.try(:position) + 1 + position = @training_task.try(:position) # 测试,默认成功 if status == 0 ActiveRecord::Base.transaction do 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) end # 创建一条回复提醒 - content = position == original_tasks_count ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务" + content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务" add_training_task_journal(content, original_project.user_id) end else content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}" add_training_task_journal(content, original_project.user_id) + # 失败的时候可以继续提交 + @training_task.update_attribute(:status, 0) end end diff --git a/app/views/projects/_act_training_tasks.html.erb b/app/views/projects/_act_training_tasks.html.erb index cc89984e2..a0251c144 100644 --- a/app/views/projects/_act_training_tasks.html.erb +++ b/app/views/projects/_act_training_tasks.html.erb @@ -11,7 +11,7 @@ TO <%= link_to activity.project.name.to_s+" | 实训任务", project_training_tasks_path(activity.project), :class => "newsBlue ml15"%> - <% 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) %>
From c33ab7735fcb366c2ed15a4d90243fdd79b3875c Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 24 Feb 2017 19:16:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=91=E9=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0f42be28e..0230e562a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -947,11 +947,12 @@ class ProjectsController < ApplicationController # 测试,默认成功 if status == 0 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+1 if position < original_tasks_count - @training_task.update_attribute(:status, 1) + position = position + 1 + publish_training_tasks original_project_id, @training_task.project_id, position end + @training_task.update_attribute(:status, 1) # 创建一条回复提醒 content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务" add_training_task_journal(content, original_project.user_id)