实训版本库代码同步功能

This commit is contained in:
huang 2017-09-30 10:42:26 +08:00
parent 7738fe021a
commit 3c19e12081
8 changed files with 381 additions and 196 deletions

View File

@ -4,13 +4,57 @@ class GamesController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:file_update]
before_filter :find_myshixun, :only => [:index]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time,
:game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice]
:game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice, :sync_codes]
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code, :html_show]
before_filter :allowd_manager
before_filter :allowd_view, :only => [:show]
before_filter :find__shixun_language, :only => [:show, :entry]
include ApplicationHelper
require 'open3'
# 同步更新最新代码
# 同步完成后需要更新myshixun的commit_id为实训的commit最新值
# --------------------------
# 新思路有冲突则则重置没有冲突直接pull
# --------------------------
def sync_codes
g = Gitlab.client
script = 'cd files/temp/
git clone http://testbdgit.trustie.net/forge01/2958mnbo.git
cd 2958mnbo/
git remote set-url origin https://educoder:xinhu1ji2qu3@testbdgit.trustie.net/forge01/2958mnbo.git
git remote add remote_origin http://testbdgit.trustie.net/educoder/2958mnbo.git
#git pull
git pull remote_origin master
if [ "$?" -eq "0" ];then
echo -e "\e[1;42m git pull succssed \e[0m"
else
git reset --hard HEAD
git pull
echo -e "\e[1;42m git pull succssed \e[0m"
fi
git push origin master
if [ "$?" -eq "0" ];then
echo -e "succssed"
else
echo -e "-1"
fi'
stdin, stdout, stderr = Open3.popen3('cd files/temp')
# 获取某次提交后之后修改的文件路径
# 某个文件的修改记录,只需对比当前的文件有没有改动,有改动重置当前的文件
# 重置某一个文件的代码?
# 如果该文件改动了则重置该文件git reset没改动则直接拉取git pull
# path = `git #{git_tree} log #{ref} file_name --pretty=oneline -1`
# git checkout hash path
# 某次提交后的修改文件目录路径数
#----------------
# 冲突处理完成后更新commit_id
shixun_new_commit = g.commits(@myshixun.shixun.try(:gpid)).first.try(:id)
@myshixun.update_column(:commit_id, shixun_new_commit)
end
def index
@games = @myshixun.games.includes(:challenge)
@games_count = @games.count
@ -28,6 +72,49 @@ class GamesController < ApplicationController
# git_repository_url @myshixun, "Myshixun"
# @st 0 实践任务 1 多选任务 2 单选任务
def show
# -----------------------------------
myshixun_user_login = User.where(:id => @myshixun.user_id).first.try(:login)
myshixun_rep_identifier = Repository.where(:myshixun_id => @myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
gitlab_address = Redmine::Configuration['gitlab_address']
gitlab_myshixun_url = git_myshixun_url(@myshixun, @myshixun.try(:user_id))
shixun = @myshixun.shixun
gitlab_shixun_url = git_shixun_url(shixun, (shixun.try(:fork_from).blank? ? "educoder" : "eduforge"))
script = "cd files/temp/
git clone #{gitlab_address.to_s+'/'+myshixun_user_login+'/'+ myshixun_rep_identifier}.git
cd 2958mnbo/
git remote set-url origin https://educoder:xinhu1ji2qu3@testbdgit.trustie.net/#{myshixun_user_login}/#{myshixun_rep_identifier}.git
git remote add remote_origin #{gitlab_shixun_url}
#git pull
git pull remote_origin master
if [ '$?' -eq '0' ];then
echo -e '\e[1;42m git pull succssed \e[0m'
else
git reset --hard HEAD
git pull
echo -e '\e[1;42m git pull succssed \e[0m'
fi
git push origin master
if [ '$?' -eq '0' ];then
echo -e 'succssed'
else
echo -e '-1'
fi"
aFile =File.new(File.join("files/temp/","#{@myshixun.identifier}.sh"), "w+")
# aFile = File.new("files/temp/#{@myshixun.identifier}.sh", "rw+")
if aFile
aFile.syswrite(script)
else
logger.error "Unable to open file!"
end
# stdin, stdout, stderr = Open3.popen3("../files/test.sh")
# ("files/test.sh").execute
# stdin, stdout, stderr = Open3.popen3('cd files/temp')
# stdin, stdout, stderr = Open3.popen3('touch test.txt')
# -----------------------------------
# 展示全部实训
@is_subject = params[:is_subject]
if @game.status == 1
@ -39,6 +126,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, @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
@ -166,7 +256,7 @@ class GamesController < ApplicationController
raise("实训云平台繁忙繁忙等级94")
end
render :json => {:result => "success", :onRun => res['onRun'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :resubmit => resubmit }
#render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 }
#render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 }
rescue Exception => e
render :json => {:result => "failed"}
end

View File

@ -16,7 +16,7 @@ class ShixunsController < ApplicationController
def statistics_students
@statistics = @shixun.myshixuns.order("created_at desc")
@statistics = @shixun.myshixuns.where("").order("created_at desc")
@statistics_count = @statistics.count
@limit = 10
@is_remote = true
@ -24,7 +24,6 @@ class ShixunsController < ApplicationController
@offset ||= @statistic_pages.offset
@statistics = paginateHelper @statistics, @limit
end
# push代码的时候会触发gitlab hook
@ -116,7 +115,7 @@ class ShixunsController < ApplicationController
@content = params[:content]
code_file = g.edit_file(@shixun.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "shixun entry")
# if @shixun.try(:status).to_i < 2
shixun_modify_status_without_publish(@shixun, 1)
shixun_modify_status_without_publish(@shixun, 1)
# end
respond_to do |format|
format.js
@ -282,7 +281,7 @@ class ShixunsController < ApplicationController
@courses = CourseList.where(:support_shixuns_search => 1)
#if !@course.blank? && (@major.blank? || MajorCourse.where(:major_id => @major, :course_list_id => @course).count == 1)
if !@course.blank?
@shixuns = @shixuns.where(:id => ShixunMajorCourse.where(:course_list_id => @course).map(&:shixun_id))
@shixuns = @shixuns.where(:id => ShixunMajorCourse.where(:course_list_id => @course).map(&:shixun_id))
end
# if !@major.blank? && MajorCourse.where(:major_id => @major, :course_list_id => @course).count == 0
# @course = nil
@ -417,7 +416,9 @@ class ShixunsController < ApplicationController
end
gshixun = g.fork(@shixun.gpid, User.current.gid)
if !gshixun.try(:id).blank?
myshixun.update_column(:gpid, gshixun.id) if myshixun.try(:gpid).blank? # 为了防止多次fork
myshixun.update_column(:gpid, gshixun.id) if myshixun.try(:gpid).blank?
commit_id = g.commits(@shixun.gpid).first.try(:id)
myshixun.update_column(:commit_id, commit_id)
rep = Repository.create!(:myshixun_id => myshixun.id, :identifier => gshixun.name,:project_id => -1, :shixun_id => -2)
rep.update_column(:type, "Repository::Gitlab")
rep_url = Base64.urlsafe_encode64(git_shixun_url_ip @shixun, (@shixun.try(:fork_from).blank? ? "educoder" : "eduforge")) # 注意educoder为默认给实训创建版本库的用户如果换成别的用户名字要相应的修改
@ -589,7 +590,7 @@ class ShixunsController < ApplicationController
@shixun.shixun_members.each do |shixun_member|
if ShixunMember.where(:shixun_id => new_shixun.try(:id), :user_id => shixun_member.user_id).blank?
ShixunMember.create!(:user_id => shixun_member.try(:user_id), :shixun_id => new_shixun.try(:id),
:role => (shixun_member.try(:user_id) == User.current.id ? 1 : 2))
:role => (shixun_member.try(:user_id) == User.current.id ? 1 : 2))
end
s = Trustie::Gitlab::Sync.new
gid = User.find(shixun_member.user_id).try(:gid)

View File

@ -33,6 +33,19 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
# 判断TPM的代码是否被修改了
def tpm_is_modified myshixun, shixun_gpid
g = Gitlab.client
myshixun_commit_id = myshixun.commit_id
if myshixun_commit_id.blank?
myshixun_commit_id = g.commits(myshixun.gpid).last.try(:id)
myshixun.update_column(:commit_id, myshixun_commit_id)
end
shixun_commit_id = g.commits(shixun_gpid).first.try(:id)
result = myshixun_commit_id != shixun_commit_id ? true :false
return result
end
# 定义当前关卡是否有权开启下一关
# :实训若发布了,必须通过当前关卡才能查看下一关
# :未发布的实训,除了最后一关,其它的关卡都可以进入下一关
@ -44,7 +57,6 @@ module ApplicationHelper
end
end
# 适用与已经用url_safe编码后回调字符串形式
def tran_base64_decode64 str
if str.blank?
@ -474,6 +486,14 @@ module ApplicationHelper
gitUrl = gitlab_address.to_s+"/"+login+"/"+ rep_identify + "."+"git"
end
# myshixun git url by domain
def git_myshixun_url myshixun, user_id
login = User.where(:id => user_id).first.try(:login)
rep_identify = Repository.where(:myshixun_id => myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
gitlab_address = Redmine::Configuration['gitlab_address']
gitUrl = gitlab_address.to_s+"/"+login+"/"+ rep_identify + "."+"git"
end
def uri_exec uri, params
begin
logger.error("@parmas is #{params}, url is #{uri}")
@ -512,22 +532,22 @@ module ApplicationHelper
# homework_common状态
# 0挂起1提交中2匿评中3评阅中
def new_homework_common_status status
case status
when 0
"未发布"
when 1
"提交中"
when 2
"补交中"
when 3
"匿评中"
when 4
"申诉中"
when 5
"评阅中"
when 6
"已结束"
end
case status
when 0
"未发布"
when 1
"提交中"
when 2
"补交中"
when 3
"匿评中"
when 4
"申诉中"
when 5
"评阅中"
when 6
"已结束"
end
end
# 作业不同状态的不同样式
@ -955,7 +975,7 @@ module ApplicationHelper
score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.attach_num * 5
end
# 获取组织成员中文名字
# 获取组织成员中文名字
def get_org_member_role_name member
unless member.roles[0].nil?
case member.roles[0].name
@ -1165,7 +1185,7 @@ module ApplicationHelper
name = h(user.name(options[:format]))
else
name = h(user.show_name)
end
end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "pro_info_p"
else
h(user.to_s)
@ -1772,7 +1792,7 @@ module ApplicationHelper
def authority_pubilic_for_files(project, file)
@result = false
if (is_project_manager?(User.current.id, @project.id) && User.current.allowed_to?(:manage_files, project)) || file.author_id == User.current.id || User.current.admin &&
project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
@result = true
end
return @result
@ -2065,7 +2085,7 @@ module ApplicationHelper
title << @user.show_name
end
elsif @syllabus
title << (@syllabus.title.nil? ? "在线课堂" : @syllabus.title)
title << (@syllabus.title.nil? ? "在线课堂" : @syllabus.title)
else
title << (User.current.id == 2 ? "未登录" : User.current.show_name)
end
@ -2789,7 +2809,7 @@ module ApplicationHelper
def check_all_links(form_name)
link_to_function_none(l(:button_check_all), "checkAll('#{form_name}', true)") + "&nbsp;".html_safe + " | "+ "&nbsp;".html_safe +
link_to_function_none(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
link_to_function_none(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
end
# 本次修改,修改为只显示关闭的所占%比
@ -2803,8 +2823,8 @@ module ApplicationHelper
content_tag('span',
content_tag('tr',
(pcts[0] > 0 ? content_tag('span', '', :style => "width: #{pcts[0]}%;", :class => 'roadmap_progressbar_inner', :title => "已关闭:#{pcts[0]}%") : ''.html_safe) #+
# (pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done', :title => "开发中:#{pcts[1]}%") : ''.html_safe) +
#(pcts[1] > 0 ? content_tag('span', '', :style => "width: #{pcts[1]}%;", :class => 'roadmap_progressbar ml5', :title => "未完成:#{pcts[1]}%") : ''.html_safe), :style => "width: #{width}"
# (pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done', :title => "开发中:#{pcts[1]}%") : ''.html_safe) +
#(pcts[1] > 0 ? content_tag('span', '', :style => "width: #{pcts[1]}%;", :class => 'roadmap_progressbar ml5', :title => "未完成:#{pcts[1]}%") : ''.html_safe), :style => "width: #{width}"
), :class => 'roadmap_progressbar ml5').html_safe
# + content_tag('p', legend, :class => 'percent').html_safe
end
@ -2943,11 +2963,11 @@ module ApplicationHelper
end
end
if sources && !sources.empty?
super(sources, options)
else
''
end
if sources && !sources.empty?
super(sources, options)
else
''
end
end
def content_for(name, content = nil, &block)
@ -3237,17 +3257,17 @@ module ApplicationHelper
# 课程某个班级的成员
def syllabus_course_member user, course
result = false
syllabus = course.syllabus
if syllabus
syllabus.courses.each do |course|
if user.member_of_course?(course)
result = true
return result
result = false
syllabus = course.syllabus
if syllabus
syllabus.courses.each do |course|
if user.member_of_course?(course)
result = true
return result
end
end
end
end
result
result
end
def attachment_candown attachment
@ -3667,48 +3687,48 @@ module ApplicationHelper
def anonymous_comment_link(bid, course)
link = case bid.comment_status
when 0
confirm_info = "开启匿评后学生将不能对作品进行提交、修改、删除等操作\n"
confirm_info += anonymous_comment_notice(bid,course)
confirm_info += '是否确定开启匿评?'
link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
when 1
confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作品列表\n"
confirm_info += anonymous_comment_notice(bid,course)
confirm_info += '是否确定关闭匿评?'
link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
when 2
'匿评结束'
end
when 0
confirm_info = "开启匿评后学生将不能对作品进行提交、修改、删除等操作\n"
confirm_info += anonymous_comment_notice(bid,course)
confirm_info += '是否确定开启匿评?'
link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...'
when 1
confirm_info = "关闭匿评后所有同学将不能继续进行匿评,且将公开已提交作品列表\n"
confirm_info += anonymous_comment_notice(bid,course)
confirm_info += '是否确定关闭匿评?'
link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info
when 2
'匿评结束'
end
content_tag('span', link, id: "#{bid.id}_anonymous_comment")
end
def anonymous_comment_notice(bid, course)
case bid.comment_status
when 0
@student_size ||= searchStudent(course).size
@homework_size = bid.homeworks.size
percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
when 1
@homework_evaluations = 0
bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
teachers = "("
teacher_members = searchTeacherAndAssistant(course)
teacher_members.each do |member|
if member == teacher_members.last
teachers += member.user_id.to_s + ")"
else
teachers += member.user_id.to_s + ","
end
end
@has_evaluations = 0
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
case bid.comment_status
when 0
@student_size ||= searchStudent(course).size
@homework_size = bid.homeworks.size
percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
when 1
@homework_evaluations = 0
bid.homeworks.map { |homework| @homework_evaluations += homework.homework_evaluations.count}
teachers = "("
teacher_members = searchTeacherAndAssistant(course)
teacher_members.each do |member|
if member == teacher_members.last
teachers += member.user_id.to_s + ")"
else
teachers += member.user_id.to_s + ","
end
end
@has_evaluations = 0
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作品,已评价#{@has_evaluations}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
end
confirm_info
percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作品,已评价#{@has_evaluations}份作品,占#{number_to_percentage(percent * 100, precision: 1)}\n"
end
confirm_info
end
def get_technical_title user
@ -3844,12 +3864,12 @@ module ApplicationHelper
link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2
case homework.homework_detail_manual.comment_status
when 1
link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'wpostOptionLink'
when 2
link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'wpostOptionLink'
when 3
# link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
when 1
link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'wpostOptionLink'
when 2
link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'wpostOptionLink'
when 3
# link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end
else
link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "学生提交作业数大于等于2时才可以启动匿评"
@ -3991,33 +4011,33 @@ module ApplicationHelper
if User.current.allowed_to?(:as_teacher, homework.course)
link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "查看作品", :target => '_blank'
else User.current.member_of_course?(homework.course)
work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework
if work.nil? && homework.end_time >= Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
end
elsif work.nil? && homework.end_time < Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'btn_orange_big fr mt5', :target => '_blank'
end
work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework
if work.nil? && homework.end_time >= Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "匿评已结束", :target => '_blank'
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
elsif homework.end_time >= Time.now && work.user_id == User.current.id
link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
else
link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
end
link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
end
elsif work.nil? && homework.end_time < Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "关联项目", student_work_index_url_in_org(homework.id, 1), :class => 'hw_btn_green fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'btn_orange_big fr mt5', :target => '_blank'
end
else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品",student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "匿评已结束", :target => '_blank'
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
elsif homework.end_time >= Time.now && work.user_id == User.current.id
link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green fr mt5', :target => '_blank'
else
link_to "查看作品", student_work_index_url_in_org(homework.id, 2), :class => 'hw_btn_green fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
end
end
end
end
@ -4625,47 +4645,47 @@ def sortby_time_countcommon_hassticky topics,sortstr
tmpIndex = 0
tmpTopics.each_with_index do |topic,index|
if topic.sticky == 0
if tStart == -1
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
tStart = index
end
if topic.sticky == 0
if tStart == -1
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
tStart = index
end
else
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
tEnd = index
else
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
if (topic[:infocount] == tmpTopics[index-1][:infocount])
tEnd = index
else
if (topic[:infocount] == tmpTopics[index-1][:infocount])
tEnd = index
end
if tEnd > tStart
for i in tStart..tEnd
tmpTopics_1[tmpIndex] = tmpTopics[i]
tmpIndex = tmpIndex + 1
end
if sortstr == "created_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
elsif sortstr == "created_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
elsif sortstr == "updated_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
elsif sortstr == "updated_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
end
tmpIndex = 0
for i in tStart..tEnd
tmpTopics[i] = tmpTopics_1[tmpIndex]
tmpIndex = tmpIndex + 1
end
end
tStart = -1
tEnd = -1
tmpTopics_1 = []
tmpIndex = 0
end
if tEnd > tStart
for i in tStart..tEnd
tmpTopics_1[tmpIndex] = tmpTopics[i]
tmpIndex = tmpIndex + 1
end
if sortstr == "created_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
elsif sortstr == "created_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
elsif sortstr == "updated_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
elsif sortstr == "updated_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
end
tmpIndex = 0
for i in tStart..tEnd
tmpTopics[i] = tmpTopics_1[tmpIndex]
tmpIndex = tmpIndex + 1
end
end
tStart = -1
tEnd = -1
tmpTopics_1 = []
tmpIndex = 0
end
end
end
end
return tmpTopics
end
@ -4906,17 +4926,17 @@ def create_works_list homework
unless homework.course.nil?
students = homework.course.student
if !students.empty? && homework.student_works.empty?
name = homework.name
name_str = name + "的作品提交"
str = ""
students.each do |student|
if str != ""
str += ","
name = homework.name
name_str = name + "的作品提交"
str = ""
students.each do |student|
if str != ""
str += ","
end
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
end
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
end
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
@ -5294,10 +5314,10 @@ def quote_homework_bank homework, course
)
end
homework.homework_bank_samples.each_with_index do |homework_test|
new_homework.homework_samples << HomeworkSample.new(
input: homework_test.input,
output: homework_test.output
)
new_homework.homework_samples << HomeworkSample.new(
input: homework_test.input,
output: homework_test.output
)
end
end

View File

@ -1,12 +1,12 @@
<style>
.editormd-preview-container, .editormd-html-preview{
text-align: left;
font-size: 16px;
line-height: 1.8;
}
.-task-ml80 .CodeMirror pre{
font-size: 16px;
}
.editormd-preview-container, .editormd-html-preview{
text-align: left;
font-size: 16px;
line-height: 1.8;
}
.-task-ml80 .CodeMirror pre{
font-size: 16px;
}
</style>
<!--inner-left-->
<div class="split-panel--first -layout -vertical -flex -relative -flex-basic40" id="game_left_contents" >
@ -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>
@ -81,12 +81,12 @@
<div class="-layout-h -padding-h-16 -horizontal -footer-left" id="bottom_points" style = "position:relative;">
<ul class="-task-ml80 -layout" style="overflow:hidden;align-items:flex-end;flex-wrap:wrap;">
<%= render :partial => "games/shixun_comment_block" %>
<li class="fl mt10 ml20 " style="width:54px;margin-bottom:10px;"><a href="javascript:void(0);" onclick="send_dis_to_shixun()" class="course-bth-blue color_white" id = "sendNews">发送</a></li>
<li class="fl mt10 ml20 " style="width:54px;margin-bottom:10px;"><a href="javascript:void(0);" onclick="send_dis_to_shixun()" class="course-bth-blue color_white">发送</a></li>
<li class="fl ml20 mt15" style="width:85px;margin-bottom:10px;">
<span data-tip-top="<%= @praise.nil? ? "点赞" : "取消点赞" %>" onclick="game_praise('<%= @game_challenge.id %>', '<%= @game_challenge.class %>')" id="game_praise_tread" class="pt5 color-grey mr20">
<span data-tip-left="<%= @praise.nil? ? "点赞" : "取消点赞" %>" onclick="game_praise('<%= @game_challenge.id %>', '<%= @game_challenge.class %>')" id="game_praise_tread" class="pt5 color-grey mr20">
<i class="fa fa-thumbs-up font-20 mr3 <%= @praise.nil? ? "" : "color-light-green" %>" alt="赞" ></i><span class="font-12 font-bd" id="game_praise_count"><%= @praise_count %></span>
</span>
<span data-tip-top="<%= @tread.nil? ? "踩" : "取消踩" %>" onclick="game_tread('<%= @game_challenge.id %>')" id="game_tread" class="color-grey" style="padding-top:7px;">
<span data-tip-right="<%= @tread.nil? ? "踩" : "取消踩" %>" onclick="game_tread('<%= @game_challenge.id %>')" id="game_tread" class="color-grey" style="padding-top:7px;">
<i class="fa fa-thumbs-down font-20 mr3 <%= @tread.nil? ? "" : "color-orange" %>" ></i><span class="font-12 font-bd" id="game_tread_count"><%= @tread_count %></span>
</span>
</li>
@ -101,6 +101,33 @@
<!--------------------------->
<!--inner-right-->
<div class="split-panel--second -layout -vertical -flex -relative -flex-basic50" id="game_right_contents">
<!--更新提示块-->
<% if @tpm_modified %>
<div class="tip-panel-animate clearfix user_bg_shadow bor-grey-e">
<div class="fl tip-img">
<img src="/images/bigdata/bigdata-logo.png"/>
</div>
<div class="fl pr tip-right-con">
<p class="mb5 ml5 color-grey3 font-16">更新通知</p>
<% if false%>
<!--测试集更新提示-->
<p class="ml5 color-dark-grey" style="line-height: 20px">本关的测试集已更新,你的代码可能无法通过新的测试集,重新评测试试!</p>
<div class="tip-operator-btn">
<a href="javascript:void(0)" class="fl color-orange03">立即评测</a>
<a href="javascript:void(0)" class="fl color-grey">稍后再说</a>
</div>
<% end %>
<!--代码更新提示-->
<p class="ml5 color-dark-grey" style="line-height: 20px">关卡任务的代码文件有更新,点击立即更新获取最新代码!</p>
<div class="tip-operator-btn">
<%= link_to "立即更新", sync_codes_myshixun_game_path(@game, :myshixun_id => @myshixun), :remote => true, :class => "fl color-orange03", :onclick => "hide_tip_content();" %>
<a href="javascript:void(0)" class="fl color-grey" onclick="hide_tip_content();">稍后再说</a>
</div>
</div>
</div>
<% end %>
<div class="-layout-v -flex">
<div class="-flex -relative">
<div class="split-panel -fit -vertical" id="games_repository_valuation">
@ -143,6 +170,9 @@
};
$(document).ready(function() {
//显示更新提示
show_tip_content();
//以下两行代码用来解决兼容问题,切莫删除。
$("#games_repository_contents").css("height",$("#games_repository_valuation").height()*0.7);
$("#games_valuation_contents").css("height",$("#games_repository_valuation").height()*0.3);
@ -169,4 +199,14 @@
var praiseStatus = <%= @praise.nil? ? false : true %>; // 是否点赞
var treadStatus = <%= @tread.nil? ? false : true %>; // 是否踩
//显示更新提示方法
function show_tip_content(){
$(".tip-panel-animate").addClass("animate-tip");
$(".tip-panel-animate").show();
}
//隐藏更新提示方法
function hide_tip_content(){
$(".tip-panel-animate").addClass("animate-tip-hide");
setTimeout('$(".tip-panel-animate").hide();', 700);
}
</script>

View File

@ -36,7 +36,7 @@ RedmineApp::Application.routes.draw do
end
resources :mark_down do
end
resources :subjects, :path => "paths" do
@ -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
@ -248,11 +249,6 @@ RedmineApp::Application.routes.draw do
get 'add_departments_part'
post 'save_school'
post 'update_user_message'
post 'add_auto_users_trial'
post 'create_auto_users_trial'
match 'update_auto_users_trial', :via => [:get, :post]
match 'account', :via => [:get, :post]
post 'shixun_can_copy'
end
end
# Enable Grack support
@ -728,7 +724,7 @@ RedmineApp::Application.routes.draw do
post 'create_memo'
post 'create_feedback'
post 'mail_feedback'
post 'update_memo_description'
post 'update_memo_description'
match 'search_memo', :via => [:get, :post]
match 'delete_forum_tag',:via =>[:get]
match 'add_forum_tag',:via=>[:get]
@ -739,16 +735,10 @@ RedmineApp::Application.routes.draw do
end
member do
get "change_sticky"
post "reply"
match "message_replies", :via => [:get, :post]
end
end
end
resources :debates do
end
resources :cooperation do
collection do

View File

@ -0,0 +1,5 @@
class AddCommitIdToMyshixuns < ActiveRecord::Migration
def change
add_column :myshixuns, :commit_id, :string
end
end

View File

@ -0,0 +1,16 @@
class SyncCommitIdForMyshixuns < ActiveRecord::Migration
def up
g = Gitlab.client
Myshixun.where("gpid is not null").each do |myshixun|
begin
commit_id = g.commits(myshixun.gpid).last.try(:id)
myshixun.update_column(:commit_id, commit_id)
rescue Exception => e
puts e
end
end
end
def down
end
end

View File

@ -70,7 +70,7 @@ a.rightbar-pause{ color:#29bd8b; font-size: 18px; margin-right:15px; margin-top:
.panel-inner-title{ font-size: 14px; color: #666; max-width:85%; line-height:30px;word-wrap: break-word; margin-bottom: 10px}
.panel-footer{ min-width:1000px; height: 210px!important;}
/* 弹框 */
.task-popup-text-center{ text-align: center; color: #333;}
.task-popup-text-center{ text-align: center; color: #666;}
.task-popup-title{ border-bottom: 1px solid #eee; padding:10px 15px; }
.task-popup-content{ padding:0px 15px 15px 15px;}
.task-popup-submit{ margin: 0 auto 15px; width: 120px;}
@ -420,11 +420,11 @@ html>body #ajax-indicator-base { position: fixed; }
/*二次回复的提示语的样式*/
.points-data-tip-top{position:absolute;left:100px;top:-30px;opacity:.7;width:150px;height:30px;z-index:9999;display:none;}
.data-tip-top1{position:relative;box-shadow:0px 0px 8px #000;background:#000;color:#fff;word-wrap: break-word;
text-align:center;border-radius:4px;padding:0 10px;border:1px solid #000;}
.data-tip-top1:after,.data-tip-top1:before{position: absolute;content:'';width:0;height:0;left: 45%;bottom:-10px;border-left: 5px solid transparent;
border-right: 5px solid transparent;border-top: 10px solid #000;}
.data-tip-top1:before{bottom:-11px;}
.data-tip-top{position:relative;box-shadow:0px 0px 8px #000;backgund:#000;color:#fff;word-wrap: break-word;
text-align:center;border-radius:4px;padding:0 10px;border:1px solid #000;}
.data-tip-top:after,.data-tip-top:before{position: absolute;content:'';width:0;height:0;left: 45%;bottom:-10px;border-left: 5px solid transparent;
border-right: 5px solid transparent;border-top: 10px solid #000;}
.data-tip-top:before{bottom:-11px;}
/*选择题tab切换*/
.nav_option li{overflow: hidden;width: 110px; text-align: center;cursor: pointer;height: 38px;line-height: 38px;border-top-right-radius: 5px;border-top-left-radius: 5px;border:1px solid #e2e2e2;border-bottom: 0px;color: #FF7500;border-right: none;}
.nav_option li:last-child{border-right: 1px solid #e2e2e2;}
@ -434,4 +434,27 @@ html>body #ajax-indicator-base { position: fixed; }
.question_item_con{font-weight: normal!important;border:1px solid #EEEEEE!important;color: #333!important;background: #FFFFff!important;position: relative}
.exam_operator{cursor: pointer;position: absolute;right: 15px;top: 11px;}
.question_item_con .write_answer{border:1px solid #EEEEEE;background:#EFF9FD;padding: 10px 15px;text-align:justify;}
.add_item_part{width: auto;padding: 2px 20px;border: 1px solid #CCCCCC;border-radius: 3px;margin-left: 15px;cursor: pointer;}
.add_item_part{width: auto;padding: 2px 20px;border: 1px solid #CCCCCC;border-radius: 3px;margin-left: 15px;cursor: pointer;}
/*更新提示*/
.tip-panel-animate{position: absolute;z-index: 999;right: 2px;top:42px;background: #FFFFff;width: 400px;height: 130px;border-radius: 3px;display: none}
.tip-panel-animate .tip-img{width: 130px;text-align: center;background-color: #E8E9ED;height: 100%;}
.tip-panel-animate .tip-img img{width: 60px;height: 60px;margin: 35px 35px;}
.tip-right-con{width: 67.5%;height: 100%;}
.tip-operator-btn{width:100%;border-top: 1px solid #eee;height: 40px;position: absolute;right: 0px;bottom: 0px}
.tip-operator-btn a{height: 100%;text-align: center;line-height: 40px;width: 50%}
.tip-operator-btn a:hover{background-color:#f9f9f9}
.tip-operator-btn a:first-child{border-right: 1px solid #eee;width: 49.6%}
.animate-tip{animation:rightToleft 1s;}
.animate-tip-hide{animation:leftToright 1s;}
@keyframes rightToleft
{
from {right: -400px;}
to {right: 2px;}
}
@keyframes leftToright
{
from {right: 2px;}
to {right: -420px;}
}