Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
1c7bbbf88d
|
@ -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)
|
||||||
|
@ -932,7 +932,7 @@ class ProjectsController < ApplicationController
|
||||||
def training_task_status
|
def training_task_status
|
||||||
status = params[:status].to_i
|
status = params[:status].to_i
|
||||||
task_id = params[:taskId]
|
task_id = params[:taskId]
|
||||||
message = params[:msg].to_i
|
message = params[:msg]
|
||||||
begin
|
begin
|
||||||
@training_task = TrainingTask.find(task_id)
|
@training_task = TrainingTask.find(task_id)
|
||||||
# 如果已经执行成功过,则不重复执行
|
# 如果已经执行成功过,则不重复执行
|
||||||
|
@ -943,22 +943,25 @@ 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
|
||||||
# 继续发布下一个任务
|
# 继续发布下一个任务
|
||||||
|
position = position + 1
|
||||||
publish_training_tasks original_project_id, @training_task.project_id, position
|
publish_training_tasks original_project_id, @training_task.project_id, position
|
||||||
@training_task.update_attribute(:status, 1)
|
|
||||||
end
|
end
|
||||||
|
@training_task.update_attribute(:status, 1)
|
||||||
# 创建一条回复提醒
|
# 创建一条回复提醒
|
||||||
content = "恭喜您通过测评"
|
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 = "很遗憾,您没有通过该步"
|
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
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
class TrainingTasksController < ApplicationController
|
class TrainingTasksController < ApplicationController
|
||||||
|
|
||||||
layout 'base_projects'
|
layout 'base_projects'
|
||||||
|
before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task]
|
||||||
before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete, :destroy]
|
before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete, :destroy]
|
||||||
before_filter :allow_manager, :only => [:index, :show]
|
before_filter :allow_manager, :only => [:index, :show]
|
||||||
before_filter :allow_members, :only => [:new, :create]
|
before_filter :allow_members, :only => [:new, :create]
|
||||||
before_filter :build_new_task_from_params, :only => [:new, :create, :update_form]
|
before_filter :build_new_task_from_params, :only => [:new, :create, :update_form]
|
||||||
before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task]
|
|
||||||
|
|
||||||
# before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
# before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
|
|
||||||
|
@ -95,6 +96,9 @@ class TrainingTasksController < ApplicationController
|
||||||
# Add a new issue
|
# Add a new issue
|
||||||
# The new issue will be created from an existing one if copy_from parameter is given
|
# The new issue will be created from an existing one if copy_from parameter is given
|
||||||
def new
|
def new
|
||||||
|
if @project.is_child_training_project?
|
||||||
|
return render_404
|
||||||
|
end
|
||||||
# 顶部导航
|
# 顶部导航
|
||||||
@project_menu_type = 11
|
@project_menu_type = 11
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -104,6 +108,9 @@ class TrainingTasksController < ApplicationController
|
||||||
|
|
||||||
# 用户发布新任务
|
# 用户发布新任务
|
||||||
def create
|
def create
|
||||||
|
if @project.is_child_training_project?
|
||||||
|
return render_404
|
||||||
|
end
|
||||||
@training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
|
@training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
|
||||||
@training_task.subject = params[:training_task][:subject]
|
@training_task.subject = params[:training_task][:subject]
|
||||||
@training_task.description = params[:training_task][:description]
|
@training_task.description = params[:training_task][:description]
|
||||||
|
@ -312,6 +319,10 @@ class TrainingTasksController < ApplicationController
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_training_task
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def allow_members
|
def allow_members
|
||||||
if !(User.current.member_of?(@project) || User.current.admin?)
|
if !(User.current.member_of?(@project) || User.current.admin?)
|
||||||
render_403
|
render_403
|
||||||
|
@ -319,7 +330,7 @@ class TrainingTasksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def allow_manager
|
def allow_manager
|
||||||
if !(User.current.admin? || is_project_member?(User.current.id, @project.id))
|
if !(User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) )
|
||||||
return render_403
|
return render_403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<a href="http://www.xtu.edu.cn/" target="_blank"><img src="images/footer_logo/p-xtu.png" width="210" height="40" alt="湘潭大学"></a>
|
<a href="http://www.xtu.edu.cn/" target="_blank"><img src="images/footer_logo/p-xtu.png" width="210" height="40" alt="湘潭大学"></a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:void(0)" target="_blank"><img src="images/footer_logo/p-zgkyrj.png" width="210" height="40" alt="中国开源软件推进联盟"></a>
|
<a href="javascript:void(0)"><img src="images/footer_logo/p-zgkyrj.png" width="210" height="40" alt="中国开源软件推进联盟"></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--实训任务-->
|
<!--实训任务-->
|
||||||
<% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %>
|
<% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %>
|
||||||
<% if User.current.admin? || is_project_member?(User.current.id, @project.id) %>
|
<% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %>
|
||||||
<li id="project_menu_011">
|
<li id="project_menu_011">
|
||||||
<%= link_to training_tasks_count > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k training_tasks_count}</span>".html_safe : "#{l(:project_module_training_tasks)}", project_training_tasks_url(@project), :class => "pro_new_proname", :title => "#{training_tasks_count}" %>
|
<%= link_to training_tasks_count > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k training_tasks_count}</span>".html_safe : "#{l(:project_module_training_tasks)}", project_training_tasks_url(@project), :class => "pro_new_proname", :title => "#{training_tasks_count}" %>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="keywords" content="issue,bug,tracker" />
|
<meta name="keywords" content="issue,bug,tracker" />
|
||||||
<%= csrf_meta_tag %>
|
<%= csrf_meta_tag %>
|
||||||
<%= favicon %>
|
<%= favicon %>
|
||||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','csws/syllabus','css/moduel', 'css/user', :media => 'all' %>
|
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','css/syllabus','css/moduel', 'css/user', :media => 'all' %>
|
||||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||||
<%= javascript_heads %>
|
<%= javascript_heads %>
|
||||||
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>
|
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>
|
||||||
|
|
|
@ -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">
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<% when "Issue" %>
|
<% when "Issue" %>
|
||||||
<%= render :partial => 'projects/act_issues', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
|
<%= render :partial => 'projects/act_issues', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
|
||||||
<% when "TrainingTask" %>
|
<% when "TrainingTask" %>
|
||||||
<% if User.current.admin? || is_project_member?(User.current.id, @project.id) %>
|
<% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %>
|
||||||
<%= render :partial => 'projects/act_training_tasks', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
|
<%= render :partial => 'projects/act_training_tasks', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--message-->
|
<!--message-->
|
||||||
|
|
|
@ -17,14 +17,20 @@
|
||||||
该项目还没有创建版本库,暂时不支持实训
|
该项目还没有创建版本库,暂时不支持实训
|
||||||
</li>
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li class="center mb5" style="line-height:20px">
|
|
||||||
<% if has_forked_cur_project(@project) %>
|
<% if has_forked_cur_project(@project) %>
|
||||||
|
<li class="center mb5" style="line-height:20px">
|
||||||
您已经实训过该项目,点击“确定”将会跳转到您的实训项目主页,请问您是否继续?
|
您已经实训过该项目,点击“确定”将会跳转到您的实训项目主页,请问您是否继续?
|
||||||
<% elsif @project.training_tasks.count == 0 %>
|
</li>
|
||||||
该项目还没有创建实训任务,暂时不支持开启实训
|
<li class="mt10">
|
||||||
|
<label class="mr27"> </label>
|
||||||
|
<a href="javascript:void(0);" class="sy_btn_grey fl " onclick="hideModal()">取 消</a>
|
||||||
|
<% 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>
|
||||||
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<li class="center mb5" style="line-height:20px">
|
||||||
实训将在后台为您创建一个新的同名项目,并为您推送第一个任务,请问您是否继续?
|
实训将在后台为您创建一个新的同名项目,并为您推送第一个任务,请问您是否继续?
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="mt10">
|
<li class="mt10">
|
||||||
<label class="mr27"> </label>
|
<label class="mr27"> </label>
|
||||||
|
@ -34,6 +40,7 @@
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -8,7 +8,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class=" fl ml5">
|
<div class=" fl ml5">
|
||||||
<div class="issues_list_titlebox clear">
|
<div class="issues_list_titlebox clear">
|
||||||
<a href="<%= training_task_path(activity)%>" class="issues_list_title fl task-list-title" target="_blank" title="<%= activity.subject.to_s %>" >
|
<a href="<%= training_task_path(activity, :project_id => @project.id) %>" class="issues_list_title fl task-list-title" target="_blank" title="<%= activity.subject.to_s %>" >
|
||||||
<span class="task-step mr5">step<%= activity.position %></span>
|
<span class="task-step mr5">step<%= activity.position %></span>
|
||||||
<%= activity.subject.to_s %>
|
<%= activity.subject.to_s %>
|
||||||
</a>
|
</a>
|
||||||
|
@ -31,13 +31,6 @@
|
||||||
<a href="javascript:void(0);" class="fl mt2"><%= activity.journals.count %></a>
|
<a href="javascript:void(0);" class="fl mt2"><%= activity.journals.count %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% if @project.is_child_training_project? %>
|
|
||||||
<td>
|
|
||||||
<div id="task_action_status_<%= activity.id %>">
|
|
||||||
<%= render :partial => 'action_status', :locals => {:activity => activity} %>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li class="clear">
|
<li class="clear">
|
||||||
<label class="label"><span class="c_red f12">*</span> 序号 : </label>
|
<label class="label"><span class="c_red f12">*</span> 序号 : </label>
|
||||||
<%= f.text_field :position, :no_label => true, :placeholder => "请输入序号(整数)", :onkeyup => "this.value=this.value.replace(/\D/g,'')", :onafterpaste => "this.value=this.value.replace(/\D/g,'')" %>
|
<%= f.text_field :position, :no_label => true, :placeholder => "请输入序号(整数)" %>
|
||||||
</li>
|
</li>
|
||||||
<li class="clear">
|
<li class="clear">
|
||||||
<label class="label"><span class="c_red f12">*</span> 标题 : </label>
|
<label class="label"><span class="c_red f12">*</span> 标题 : </label>
|
||||||
|
@ -41,9 +41,17 @@
|
||||||
<input onclick="issue_create();" class="sy_btn_blue mr5 fr" onfocus="this.blur()" id="issue_confirm" style="width: 28px;color: #FFF" value="保存">
|
<input onclick="issue_create();" class="sy_btn_blue mr5 fr" onfocus="this.blur()" id="issue_confirm" style="width: 28px;color: #FFF" value="保存">
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
function issue_create(){
|
function issue_create(){
|
||||||
training_task_desc_editor.sync();
|
training_task_desc_editor.sync();
|
||||||
$('#project_training_form').submit();
|
$('#project_training_form').submit();
|
||||||
}
|
}
|
||||||
|
$(function(){
|
||||||
|
$("#training_task_position").bind('keyup', function (){
|
||||||
|
this.value=this.value.replace(/\D/g,'')
|
||||||
|
});
|
||||||
|
$("#training_task_position").bind('afterpaste',function(){
|
||||||
|
this.value=this.value.replace(/\D/g,'')
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -222,9 +222,6 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th><p class="text-left">所有<span class="issues_nav_tag ml5" style=" font-weight: normal;"><%= @training_tasks_count %></span></p></th>
|
<th><p class="text-left">所有<span class="issues_nav_tag ml5" style=" font-weight: normal;"><%= @training_tasks_count %></span></p></th>
|
||||||
<th class="w50"> </th>
|
<th class="w50"> </th>
|
||||||
<% if @project.is_child_training_project? %>
|
|
||||||
<th class="w100"> </th>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="issue_list">
|
<tbody id="issue_list">
|
||||||
|
|
Loading…
Reference in New Issue