Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
abcaf33a17
|
@ -853,8 +853,10 @@ class ProjectsController < ApplicationController
|
||||||
params = {jobName: jobName, pipeLine: pipeLine}
|
params = {jobName: jobName, pipeLine: pipeLine}
|
||||||
res = uri_exec uri, params
|
res = uri_exec uri, params
|
||||||
training_project_notice res
|
training_project_notice res
|
||||||
|
if res['code'] == 0
|
||||||
@project.update_attribute(:training_status, 1)
|
@project.update_attribute(:training_status, 1)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def training_project_update
|
def training_project_update
|
||||||
jobName = "#{@project.id}"
|
jobName = "#{@project.id}"
|
||||||
|
@ -863,8 +865,10 @@ class ProjectsController < ApplicationController
|
||||||
params = {jobName: jobName, pipeLine: pipeLine}
|
params = {jobName: jobName, pipeLine: pipeLine}
|
||||||
res = uri_exec uri, params
|
res = uri_exec uri, params
|
||||||
training_project_notice res
|
training_project_notice res
|
||||||
|
if res['code'] == 0
|
||||||
@project.update_attribute(:training_status, 1)
|
@project.update_attribute(:training_status, 1)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def training_project_notice res
|
def training_project_notice res
|
||||||
if res['code'] == 0
|
if res['code'] == 0
|
||||||
|
@ -891,18 +895,30 @@ class ProjectsController < ApplicationController
|
||||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||||
gitUrl = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ rep_identify + "."+"git"
|
gitUrl = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ rep_identify + "."+"git"
|
||||||
gitUrl = Base64.encode64(gitUrl)
|
gitUrl = Base64.encode64(gitUrl)
|
||||||
|
|
||||||
if @training_task.status == 0
|
if @training_task.status == 0
|
||||||
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"}
|
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"}
|
||||||
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
|
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
|
||||||
begin
|
begin
|
||||||
res = uri_exec uri, params
|
res = uri_exec uri, params
|
||||||
# 任务开启成功后创建一条留言提示,并发布
|
# 轮询获取
|
||||||
@training_task.update_attribute(:status, 2)
|
for i in 0..60 do
|
||||||
return
|
sleep(1)
|
||||||
|
result = TrainingTask.where(:id => @training_task.id).first.try(:result)
|
||||||
|
if (result != 0)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# @training_task = TrainingTask.find(@training_task.id)
|
||||||
|
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||||
|
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'TrainingTask','Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts e
|
puts e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def uri_exec uri, params
|
def uri_exec uri, params
|
||||||
|
@ -931,7 +947,7 @@ class ProjectsController < ApplicationController
|
||||||
forked_count = @project.forked_count.to_i + 1
|
forked_count = @project.forked_count.to_i + 1
|
||||||
@project.update_attributes(:forked_count => forked_count)
|
@project.update_attributes(:forked_count => forked_count)
|
||||||
# 发布实训任务,只发布实训任务的第一个
|
# 发布实训任务,只发布实训任务的第一个
|
||||||
publish_training_tasks(@project.id, new_training_project.id, 1)
|
publish_training_tasks(@project.id, new_training_project.id, 1, @project.user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -944,7 +960,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 = Base64.decode64(params[:msg])
|
message = Base64.decode64(params[:msg]) unless params[:msg].blank?
|
||||||
begin
|
begin
|
||||||
@training_task = TrainingTask.find(task_id)
|
@training_task = TrainingTask.find(task_id)
|
||||||
# 如果已经执行成功过,则不重复执行
|
# 如果已经执行成功过,则不重复执行
|
||||||
|
@ -961,11 +977,12 @@ class ProjectsController < ApplicationController
|
||||||
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 + 1
|
publish_training_tasks original_project_id, @training_task.project_id, position + 1, original_project.user_id
|
||||||
end
|
end
|
||||||
@training_task.update_attribute(:status, 1)
|
@training_task.update_attribute(:status, 1)
|
||||||
|
@training_task.update_attribute(:result, 1)
|
||||||
# 创建一条回复提醒
|
# 创建一条回复提醒
|
||||||
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
|
||||||
|
@ -973,6 +990,7 @@ class ProjectsController < ApplicationController
|
||||||
add_training_task_journal(content, original_project.user_id)
|
add_training_task_journal(content, original_project.user_id)
|
||||||
# 失败的时候可以继续提交
|
# 失败的时候可以继续提交
|
||||||
@training_task.update_attribute(:status, 0)
|
@training_task.update_attribute(:status, 0)
|
||||||
|
@training_task.update_attribute(:result, 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -989,7 +1007,7 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
# 实训开启成功后,发布第一个任务
|
# 实训开启成功后,发布第一个任务
|
||||||
# REDO:失败后提醒用户,及相关处理
|
# REDO:失败后提醒用户,及相关处理
|
||||||
def publish_training_tasks original_project_id, new_training_project_id, position
|
def publish_training_tasks original_project_id, new_training_project_id, position, user_id
|
||||||
original_task = TrainingTask.where(:project_id => original_project_id, :position => position).first
|
original_task = TrainingTask.where(:project_id => original_project_id, :position => position).first
|
||||||
training_task = TrainingTask.new
|
training_task = TrainingTask.new
|
||||||
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]))
|
||||||
|
@ -998,13 +1016,12 @@ class ProjectsController < ApplicationController
|
||||||
training_task.position = original_task.position
|
training_task.position = original_task.position
|
||||||
training_task.project_id = new_training_project_id
|
training_task.project_id = new_training_project_id
|
||||||
training_task.author_id = User.current.id
|
training_task.author_id = User.current.id
|
||||||
if training_task.save
|
begin
|
||||||
respond_to do |format|
|
training_task.save
|
||||||
format.html{redirect_to project_url(new_training_project_id)}
|
rescue Exception => e
|
||||||
end
|
puts e
|
||||||
else
|
|
||||||
raise "create task failed"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# 复制项目
|
# 复制项目
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<% project = Project.find(project_id) %>
|
||||||
<% unless activity.author.nil? %>
|
<% unless activity.author.nil? %>
|
||||||
<div class="container-big mt10" id="user_activity_<%= user_activity_id%>">
|
<div class="container-big mt10" id="user_activity_<%= user_activity_id%>">
|
||||||
<div class="pr">
|
<div class="pr">
|
||||||
|
@ -11,7 +12,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 !@project.is_child_training_project? && 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">
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
<div class="mb10" style="font-weight:normal;">
|
<div class="mb10" style="font-weight:normal;">
|
||||||
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
|
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
|
||||||
</div>
|
</div>
|
||||||
<% if @project.is_child_training_project? %>
|
<% if project.is_child_training_project? %>
|
||||||
<div id="training_project_task_status_<%= activity.id %>">
|
<div id="training_project_task_status_<%= activity.id %>">
|
||||||
<%= render :partial => "training_tasks/action_status", :locals => {:activity => activity} %>
|
<%= render :partial => "training_tasks/action_status", :locals => {:activity => activity} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -42,14 +42,16 @@
|
||||||
<%= 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_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_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)) %>
|
||||||
|
<div id="project_show_training_task_<%= @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} %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--message-->
|
<!--message-->
|
||||||
<% when "Message" %>
|
<% when "Message" %>
|
||||||
<%= render :partial => 'projects/act_messages', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :is_course => 1, :is_board => 0} %>
|
<%= render :partial => 'projects/act_messages', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :is_course => 1, :is_board => 0} %>
|
||||||
<!--Attachment -->
|
<!--Attachment -->
|
||||||
<% when "Attachment" %>
|
<% when "Attachment" %>
|
||||||
<%= render :partial => 'projects/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %>
|
<%#= render :partial => 'projects/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %>
|
||||||
<% when "Commit" %>
|
<% when "Commit" %>
|
||||||
<%= render :partial => 'projects/project_commit', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :identifier => get_rep_identifier_by_project(@project) } %>
|
<%= render :partial => 'projects/project_commit', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :identifier => get_rep_identifier_by_project(@project) } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -34,8 +34,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="project_act_show_<%= @project.id %>">
|
||||||
<%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %>
|
<%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
autoUrl('project_description_code');
|
autoUrl('project_description_code');
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
$("#training_project_task_status_<%= @training_task.id %>").html('<%= escape_javascript( render :partial => 'training_tasks/action_status', :locals => {:activity => @training_task}) %>');
|
//$("#training_project_task_status_<%#= @training_task.id %>").html('<%#= escape_javascript( render :partial => 'training_tasks/action_status', :locals => {:activity => @training_task}) %>');
|
||||||
$("#training_task_details").html('<%= escape_javascript( render :partial => 'training_tasks/training_task_details', :locals => {:activity => @training_task, :project_id => @project.id}) %>');
|
//$("#training_task_details").html('<%#= escape_javascript( render :partial => 'training_tasks/training_task_details', :locals => {:activity => @training_task, :project_id => @project.id}) %>');
|
||||||
|
//$("#project_show_training_task_<%#= @training_task.project_id %>").html('<%#= escape_javascript( render :partial => 'projects/act_training_tasks', :locals => {:activity => @training_task, :user_activity_id => @training_task.id, :project_id => @training_task.project_id}) %>');
|
||||||
|
$("#project_act_show_<%= @project.id %>").html('<%= escape_javascript( render :partial => 'projects/project_activities', :locals => {:forge_acts => @events_pages, :page => 0, :type => @type}) %>');
|
|
@ -1 +1 @@
|
||||||
$("#task_action_status_<%= @training_task.id %>").html('<%= escape_javascript( render :partial => 'training_tasks/action_status', :locals => {:activity => @training_task}) %>');
|
alert("test");
|
|
@ -6,11 +6,19 @@
|
||||||
<span class="task-display-span alert-blue mt10">当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>
|
<span class="task-display-span alert-blue mt10">当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if User.current.member_of?(@project) && @project.is_child_training_project? %>
|
<% if User.current.member_of?(@project) && @project.is_child_training_project? %>
|
||||||
<%= link_to "提交评测", task_execute_project_path(@project, :training_task_id => activity.id), :class => "task-display-span bBlue mt10", :remote => true %>
|
<div id="training_tasl_commit">
|
||||||
|
<%= link_to "提交评测", task_execute_project_path(@project, :training_task_id => activity.id), :class => "task-display-span bBlue mt10", :onclick => "training_task_submmit();", :remote => true %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function training_task_submmit(){
|
||||||
|
$("#training_tasl_commit").html("<span class='task-display-span alert-blue mt10'>当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>")
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,7 @@
|
||||||
<%= render :partial => 'task_attachments', :locals => {:training_task => @training_task} %>
|
<%= render :partial => 'task_attachments', :locals => {:training_task => @training_task} %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div id="training_project_task_status_<%= @training_task.id %>">
|
|
||||||
<%= render :partial => "training_tasks/action_status", :locals => {:activity => @training_task} %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -1,43 +1,43 @@
|
||||||
class HomeworkBankMigration < ActiveRecord::Migration
|
class HomeworkBankMigration < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
add_column :homework_commons, :homework_bank_id, :integer
|
# add_column :homework_commons, :homework_bank_id, :integer
|
||||||
add_column :homework_commons, :is_update, :boolean, :default => false
|
# add_column :homework_commons, :is_update, :boolean, :default => false
|
||||||
|
#
|
||||||
count =Course.all.count / 30 + 2
|
# count =Course.all.count / 30 + 2
|
||||||
transaction do
|
# transaction do
|
||||||
for i in 1 ... count do i
|
# for i in 1 ... count do i
|
||||||
Course.page(i).per(30).each do |course|
|
# Course.page(i).per(30).each do |course|
|
||||||
if course.is_delete == 0
|
# if course.is_delete == 0
|
||||||
course.homework_commons.each do |homework|
|
# course.homework_commons.each do |homework|
|
||||||
unless homework.user.homework_banks.select("name").to_s.include?(homework.name)
|
# unless homework.user.homework_banks.select("name").to_s.include?(homework.name)
|
||||||
homework_bank = HomeworkBank.create(:user_id => homework.user_id, :name => homework.name, :description => homework.description, :homework_type => homework.homework_type,
|
# homework_bank = HomeworkBank.create(:user_id => homework.user_id, :name => homework.name, :description => homework.description, :homework_type => homework.homework_type,
|
||||||
:quotes => 1, :is_public => course.is_public, :applicable_syllabus => course.syllabus.title, :homework_common_id => homework.id, :created_at => homework.created_at)
|
# :quotes => 1, :is_public => course.is_public, :applicable_syllabus => course.syllabus.title, :homework_common_id => homework.id, :created_at => homework.created_at)
|
||||||
if homework.homework_type == 2 && homework.homework_detail_programing
|
# if homework.homework_type == 2 && homework.homework_detail_programing
|
||||||
homework_bank.update_attributes(:language => homework.homework_detail_programing.language, :standard_code => homework.homework_detail_programing.standard_code)
|
# homework_bank.update_attributes(:language => homework.homework_detail_programing.language, :standard_code => homework.homework_detail_programing.standard_code)
|
||||||
homework.homework_tests.each do |test|
|
# homework.homework_tests.each do |test|
|
||||||
homework_bank.homework_bank_tests << HomeworkBankTest.create(
|
# homework_bank.homework_bank_tests << HomeworkBankTest.create(
|
||||||
input: test.input,
|
# input: test.input,
|
||||||
output: test.output,
|
# output: test.output,
|
||||||
test_type: true
|
# test_type: true
|
||||||
)
|
# )
|
||||||
end
|
# end
|
||||||
homework.homework_samples.each do |test|
|
# homework.homework_samples.each do |test|
|
||||||
homework_bank.homework_bank_tests << HomeworkBankTest.create(
|
# homework_bank.homework_bank_tests << HomeworkBankTest.create(
|
||||||
input: test.input,
|
# input: test.input,
|
||||||
output: test.output,
|
# output: test.output,
|
||||||
test_type: false
|
# test_type: false
|
||||||
)
|
# )
|
||||||
end
|
# end
|
||||||
elsif homework.homework_type == 3 && homework.homework_detail_group
|
# elsif homework.homework_type == 3 && homework.homework_detail_group
|
||||||
homework_bank.update_attributes(:min_num => homework.homework_detail_group.min_num, :max_num => homework.homework_detail_group.max_num, :base_on_project => homework.homework_detail_group.base_on_project)
|
# homework_bank.update_attributes(:min_num => homework.homework_detail_group.min_num, :max_num => homework.homework_detail_group.max_num, :base_on_project => homework.homework_detail_group.base_on_project)
|
||||||
end
|
# end
|
||||||
homework.update_column('homework_bank_id', homework_bank.id)
|
# homework.update_column('homework_bank_id', homework_bank.id)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddResultToTrainingTask < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :training_tasks, :result, :integer, :default => 0
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue