Compare commits

...

9 Commits

5 changed files with 48 additions and 1 deletions

View File

@ -39,6 +39,9 @@ class GamesController < ApplicationController
@game_challenge = @game.challenge
@challenges = Challenge.where(:shixun_id => @myshixun.shixun_id)
@shixun = @myshixun.shixun
# 判断tpm是否修改了
@tpm_modified = tpm_is_modified(@myshixun.try(:gpid), @shixun.try(:gpid))
# end
@praise_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "Challenge").count
@tread_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "ChallengeTread").count
# @games_count = @games.count
@ -142,6 +145,38 @@ class GamesController < ApplicationController
=end
end
# 同步更新最新代码
def sync_codes
# 获取某次提交后之后修改的文件路径
get ":id/repository/get_after_paths" do
# 某个文件的修改记录,只需对比当前的文件有没有改动,有改动重置当前的文件
# 重置某一个文件的代码?
# 如果该文件改动了则重置该文件git reset没改动则直接拉取git pull
path = `git #{git_tree} log #{ref} file_name --pretty=oneline -1`
git checkout hash path
# 某次提交后的修改文件目录路径数
git_tree = params[:git_tree]
ref = params[:ref_name]
commit_id = `git #{git_tree} log #{ref} --pretty=oneline -1`
commit_id2 = `--git #{git_tree} rev-parse #{ref}`
{commit_id: commit_id.rstrip, commit_id2: commit_id2}
end
# end
# gitlab版本
get ":id/repository/get_branch_commit_id" do
git_tree = params[:git_tree]
ref = params[:ref_name]
commit_id = `git #{git_tree} log #{ref} --pretty=oneline -1`
commit_id2 = `--git #{git_tree} rev-parse #{ref}`
{commit_id: commit_id.rstrip, commit_id2: commit_id2}
end
# end
end
# json调用显示左边的隐藏具体详情@game 字段 msg
# 刷新右边的输出结果 @game out_put
def outputs_show

View File

@ -33,6 +33,16 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
# 判断TPM的代码是否被修改了
def tpm_is_modified myshixun_gpid, shixun_gpid
g = Gitlab.client
# myshixun取最后一天shixun取最新一条
myshixun_commit_id = g.commits(myshixun_gpid).first.try(:id)
shixun_commit_id = g.commits(shixun_gpid).first.try(:id)
result = myshixun_commit_id == shixun_commit_id ? true :false
return result
end
# 定义当前关卡是否有权开启下一关
# :实训若发布了,必须通过当前关卡才能查看下一关
# :未发布的实训,除了最后一关,其它的关卡都可以进入下一关

View File

@ -1,2 +1,3 @@
# encoding: utf-8
module GamesHelper
end

View File

@ -34,7 +34,7 @@
<% end %>
<li id="tab_nav_4">
<a href="<%= shixun_discuss_shixun_path(@myshixun.shixun, :challenge_id => @game_challenge.id) %>" class="tab_type" style="font-size: 16px" data-remote="true">
评论<span id="discusses_count" class="edu-cir-grey1" style="line-height: 18px!important;"><%= @discusses_count if @discusses_count > 0%></span>
评论<span id="discusses_count" class="edu-cir-grey1" style="line-height: 18px!important;"><%= @discusses_count if @discusses_count.to_i > 0%></span>
</a>
<%#= link_to '', shixun_discuss_shixun_path(@myshixun.shixun), :class => "tab_type", :style => "font-size: 16px", :remote => true %>
</li>

View File

@ -164,6 +164,7 @@ RedmineApp::Application.routes.draw do
get 'minus_score'
get 'refresh_game_list'
get 'waiting_info'
get 'sync_codes'
end
end
end