Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-04-15 17:21:07 +08:00
commit 51478bd232
23 changed files with 422 additions and 58 deletions

View File

@ -319,9 +319,25 @@ class ProjectsController < ApplicationController
else
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10);
end
g = Gitlab.client
# g = Gitlab.client
unless @project.gpid.nil? || @project.project_score.changeset_num == 0
@static_total_per_user = g.rep_stats(@project.gpid)
# rep_statics_commit = @project.rep_statics.order("commits_num desc")
rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10")
rep_statics_code = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by changeset desc limit 10")
# rep_statics_code = @project.rep_statics.sort_by {|u| u.changeset}.reverse
@a_uname = rep_statics_commit.map {|s| s.uname }
@a_uname_code = rep_statics_code.map {|s| s.uname }
@a_commits_num = rep_statics_commit.map {|s| s.commits_num.to_i }
@a_commits_add = rep_statics_code.map {|s| s.add.to_i }
@a_commits_del = rep_statics_code.map {|s| s.del.to_i }
@a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i }
g = Gitlab.client
begin
g_branch = g.project(@project.gpid).default_branch.to_s
rescue
logger.error("get gitlab project failed!")
end
@rev = g_branch.nil? ? "master" : g_branch
end
# 根据对应的请求,返回对应的数据
respond_to do |format|

View File

@ -348,8 +348,10 @@ update
# (show_error_not_found; return) unless @entries
g = Gitlab.client
@changesets = g.commits(@project.gpid, :ref_name => @rev)
g_project = g.project(@project.gpid)
# 总的提交数
@changesets_all_count = @project.gpid.nil? ? 0 : g.project(@project.gpid).commit_count
@changesets_all_count = @project.gpid.nil? ? 0 : g_project.commit_count
@g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch
# 访问该页面的是会后则刷新
if @project.project_score.nil?
ProjectScore.create(:project_id => @project.id, :score => false)
@ -573,7 +575,17 @@ update
g = Gitlab.client
begin
@static_total_per_user = g.rep_stats(project_id, :rev => rev)
@static_total_per_user
# 更新rep_statics统计数
@static_total_per_user.each do |static|
rep_static = RepStatics.where("project_id =? and email =?", @project.id, static.email.to_s).first
if rep_static.nil?
RepStatics.create(:project_id => @project.id, :uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
else
if @rev == params[:default_branch]
rep_static.update_attributes(:uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
end
end
end
# @static_month__per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 2)
# @static_week_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 3)
rescue

View File

@ -5,7 +5,7 @@ class StudentWorkController < ApplicationController
include ApplicationHelper
require 'bigdecimal'
require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:code_repeattest,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:code_repeattest,:work_canrepeat,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
@ -188,7 +188,7 @@ class StudentWorkController < ApplicationController
#找出该作业的所有提交作业
def find_all_student_work_by_homeid()
all_studentwork = StudentWork.where("homework_common_id =?", @homework.id)
all_studentwork = StudentWork.where("homework_common_id =#{@homework.id} and is_test = 0 ")
all_studentwork
end
@ -222,6 +222,15 @@ class StudentWorkController < ApplicationController
JSON.parse(res.body)
end
def work_canrepeat
@homework_id = params[:homework]
@course_id = params[:course_id]
all_studentwork = find_all_student_work_by_homeid()
@work_count = all_studentwork.count
end
#代码查重 status: 0完成 -2不需要查重 -1查重失败不支持该语言
def code_repeattest
tStarttime = Time.now

View File

@ -115,6 +115,7 @@ class Project < ActiveRecord::Base
has_many :org_projects,:dependent => :destroy
has_many :organization,:through => :org_projects
has_many :rep_statics, :class_name => 'RepStatics'
# has_many :journals

View File

@ -0,0 +1,4 @@
class RepStatics < ActiveRecord::Base
belongs_to :project
attr_accessible :add, :commits_num, :del, :email, :project_id, :uname, :changeset
end

View File

@ -37,11 +37,12 @@
console.log(data);
if (data.status == 0) {
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成,是否立即查看结果?",:status=>1, :homework=> homework,:courseid=> courseid})%>');
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成,是否立即查看结果?",:status=>1, :homework=> homework,:courseid=> courseid})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 560px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
//$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
@ -54,8 +55,8 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> homework,:courseid=> courseid})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 560px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
@ -69,8 +70,8 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> homework,:courseid=> courseid})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 560px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
@ -85,8 +86,8 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> homework,:courseid=> courseid})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 560px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","30%").css("left","50%").css("padding-top","10px").css("position","fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -12,7 +12,7 @@
<% if @simi_value.to_i >= 90 %>
<h6 style="color:red;float:left; width:6%; text-align:center;">相似度<%=@simi_value.to_i%>%</h3>
<% else %>
<h6 style="float:left; width:6%; text-align:center;">相似度<%=@simi_valu.to_i%>%</h3>
<h6 style="float:left; width:6%; text-align:center;">相似度<%=@simi_value.to_i%>%</h3>
<% end %>
<h3 style="float:left; width:47%; text-align:center;"><%=dst_name%></h3><div class="cl"></div>
<pre id = "program-src_1" style = "display: none" ><%= src_code if src_code%></pre>

View File

@ -48,7 +48,7 @@
<%= link_to("查看", show_comparecode_course_path(:homework_id => @homework.id,:src_id => student_work.id,:dst_id => student_work.simi_id.to_i),:class => "cha-btn",:remote => true ) %>
</li>
<%else%>
<li class="chabox-w-401"></li>
<li class="chabox-w-401">--</li>
<li>--</li>
<li>--</li>
<li class="chabox-r-line">--</li>

View File

@ -10,14 +10,18 @@
type: 'line'
},
title: {
text: '版本库代码提交量'
text: '版本库代码提交行数',
style:{
fontSize: '14px'
}
},
subtitle: {
// text: 'Source: WorldClimate.com'
},
xAxis: {
// categories: ["Jan", "Jan", "Jan", 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
categories: <%= raw(@a_uname_code) %>
},
yAxis: {
title: {
@ -34,6 +38,12 @@
}
},
plotOptions: {
series: {
marker: {
radius: 3, //曲线点半径默认是4
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
}
},
line: {
dataLabels: {
enabled: true
@ -41,21 +51,55 @@
enableMouseTracking: false
}
},
series: [{
name: '改动或增加',
color: '#fd9e04',
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
data: <%= @static_total_per_user.map{|c| c.add.to_i} %>
series: [
{
name: '<b style="font-weight:normal ">总变更</b>',
color: '#d05d5a',
fontWeight: 'normal',
data: <%= @a_commits_changeset %>,
dataLabels: {
enabled: false,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
},
{
name: '<b style="font-weight:normal ">改动或增加</b>',
color: '#5b6b76',
data: <%= @a_commits_add %>,
dataLabels: {
enabled: false,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
},
{
name: '删除',
color: '#46baed ',
data: <%= @static_total_per_user.map{|c| c.del.to_i} %>
},{
name: '总变更',
color: '#d397d5',
data: <%= @static_total_per_user.map{|c| c.changes.to_i} %>
name: '<b style="font-weight:normal ">删除</b>',
color: '#84b5bb',
data: <%= @a_commits_del %>,
dataLabels: {
enabled: false,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
}]
});
@ -68,14 +112,18 @@
enabled: false
},
title: {
text: '版本库代码提交次数'
text: '版本库代码提交次数',
style:{
fontSize: '14px'
}
},
subtitle: {
// text: 'Source: WorldClimate.com'
},
xAxis: {
// categories: ["Jan", "Jan", "Jan", 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
categories: <%= raw(@a_uname) %>
},
yAxis: {
title: {
@ -89,6 +137,12 @@
}
},
plotOptions: {
series: {
marker: {
radius: 3, //曲线点半径默认是4
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
}
},
line: {
dataLabels: {
enabled: true
@ -97,9 +151,24 @@
}
},
series: [{
name: '提交次数',
name: '<b style="font-weight:normal ">提交次数</b>',
fontWeight: 'normal',
color: '#d05d5a',
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
data: <%= @static_total_per_user.map{|c| c.commits_num.to_i} %>
data: <%= @a_commits_num %>,
dataLabels: {
enabled: false,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
}
// {
// name: 'London',
@ -108,4 +177,5 @@
]
});
});
</script>
</script>
<div class="button-rep">当前分支:<%= @rev %></div>

View File

@ -25,7 +25,7 @@
<textarea id="copy_rep_content" class="cloneUrl mt5 fl" type="input" ><%= @repository.type.to_s=="Repository::Gitlab" ? @repos_url.to_s.lstrip : @repository.url %></textarea>
<a href="javascript:void(0);" class="clone_btn mt5" onclick="jsCopy()"><span class="vl_copy" title="点击复制版本库地址"></span></a>
<div class="fl mt5 ml15">
<%=link_to "统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator ), :class => "fl vl_zip" %>
<%=link_to "统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %>
</div>
<%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
<% if User.current.id != @project.user_id %>

View File

@ -14,6 +14,7 @@
</div>
<div id = "container_code" class="mt30">
</div>
<script>
$(function () {
$('#container_code').highcharts({
@ -21,7 +22,11 @@
type: 'line'
},
title: {
text: '代码提交量'
text: '版本库代码提交行数',
style:{
fontSize: '14px'
}
},
subtitle: {
// text: 'Source: WorldClimate.com'
@ -45,6 +50,12 @@
}
},
plotOptions: {
series: {
marker: {
radius: 3, //曲线点半径默认是4
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
}
},
line: {
dataLabels: {
enabled: true
@ -52,18 +63,55 @@
enableMouseTracking: false
}
},
series: [{
name: '改动或增加',
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
data: <%= @static_total_per_user.map{|c| c.add.to_i} %>
},
{
name: '删除',
data: <%= @static_total_per_user.map{|c| c.del.to_i} %>
},{
name: '总变更',
data: <%= @static_total_per_user.map{|c| c.changes.to_i} %>
series: [
{
name: '<b style="font-weight:normal ">总变更</b>',
color: '#d05d5a',
fontWeight: 'normal',
data: <%= @static_total_per_user.map{|c| c.changes.to_i} %>,
dataLabels: {
enabled: true,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
},
{
name: '<b style="font-weight:normal ">改动或增加</b>',
color: '#5b6b76',
data: <%= @static_total_per_user.map{|c| c.add.to_i} %>,
dataLabels: {
enabled: true,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
},
{
name: '<b style="font-weight:normal ">删除</b>',
color: '#84b5bb',
data: <%= @static_total_per_user.map{|c| c.del.to_i} %>,
dataLabels: {
enabled: true,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
}]
});
@ -76,14 +124,18 @@
enabled: false
},
title: {
text: '代码提交次数'
text: '版本库代码提交次数',
style:{
fontSize: '14px'
}
},
subtitle: {
// text: 'Source: WorldClimate.com'
},
xAxis: {
// categories: ["Jan", "Jan", "Jan", 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
},
yAxis: {
title: {
@ -97,6 +149,12 @@
}
},
plotOptions: {
series: {
marker: {
radius: 3, //曲线点半径默认是4
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
}
},
line: {
dataLabels: {
enabled: true
@ -105,9 +163,23 @@
}
},
series: [{
name: '提交次数',
name: '<b style="font-weight:normal ">提交次数</b>',
fontWeight: 'normal',
color: '#d05d5a',
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
data: <%= @static_total_per_user.map{|c| c.commits_num.to_i} %>
data: <%= @static_total_per_user.map{|c| c.commits_num.to_i} %>,
dataLabels: {
enabled: true,
style: {
fontSize: '13px',
color: '#aaa',
fontFamily: 'Arial',
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
fontWeight: 'normal'
}
},
lineWidth: 1.5
}
// {
// name: 'London',

View File

@ -19,7 +19,7 @@
<a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a>
</div>
<%if @homework.homework_type == 2 %>
<a href="javascript:void(0);" class="BlueCirBtn fr" data-course-id="<%=@course.id%>" data-homework-simi-time="<%=@homework.simi_time%>" data-homework-id="<%=@homework.id%>" id="test-program-repeat-btn" onclick = "code_repeat()">代码查重</a>
<%= link_to "代码查重", work_canrepeat_student_work_index_path(homework:@homework.id, course_id:@course.id), class: 'BlueCirBtn fr',:remote => true %>
<% end %>
<%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %>
<% end%>

View File

@ -0,0 +1,101 @@
//代码查重
var homework_id = <%=@homework.id%>;
<% if @work_count <= 1 %>
//弹框
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function closeModal() {
hideModal($(".blue-border-box"));
}
<% else %>
<% if !@homework.simi_time %>
test_repeat();
<% else%>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>');
$('#compare-tips-1').html('您上次查重的时间为<%= Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H-%M-%S")%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function closeModal() {
hideModal($(".blue-border-box"));
}
<% end %>
//请求查重
var test_repeat = function () {
$.post(
'/student_work/code_repeattest',
{homework: homework_id},
function (data, status) {
if (data.status == 0) {
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> @homework,:courseid=> @course_id})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function closeModal() {
hideModal($(".blue-border-box"));
}
}
else if (data.status == -1) {
// confirm("对不起只支持java/c/c++的代码查重!");
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function closeModal() {
hideModal($(".blue-border-box"));
}
}
else if (data.status == -2) {
// confirm("对不起该作业的作品过少不能查重!");
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function closeModal() {
hideModal($(".blue-border-box"));
}
}
}
).fail(function (xhr, status) {
// confirm("对不起,服务器繁忙请稍后再试!");
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
showModal('ajax-modal', '580px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function closeModal() {
hideModal($(".blue-border-box"));
}
});
};
<% end %>

View File

@ -45,6 +45,7 @@
<span class="green_homework_btn_cir ml5" title="目前教师和教辅正在评阅">教师评阅中</span>
<% end%>
<% end%>
<div class="cl"></div>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%>
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
@ -75,7 +76,10 @@
<div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
</div>
<% end %>
<div class="homepagePostSubmit">
<%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: activity.id, course_id: activity.course.id), class: 'c_blue test-program-btn',:remote => true %>
</div>
<% end %>
<% if activity.homework_type == 2%>
<div class="homepagePostDeadline mr15">
语言:

View File

@ -268,6 +268,7 @@ RedmineApp::Application.routes.draw do
get 'retry_work'
get 'praise_student_work'
get 'forbidden_anonymous_comment'
get 'work_canrepeat'
end
collection do
post 'add_score_reply'
@ -286,6 +287,7 @@ RedmineApp::Application.routes.draw do
post 'code_repeattest'
post 'last_codecomparetime'
post 'set_score_rule'
get 'work_canrepeat'
end
end

View File

@ -0,0 +1,14 @@
class CreateRepStatics < ActiveRecord::Migration
def change
create_table :rep_statics do |t|
t.integer :project_id
t.integer :commits_num
t.string :uname
t.string :email
t.integer :add
t.integer :del
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
class AddChangesetToRepStatics < ActiveRecord::Migration
def change
add_column :rep_statics, :changeset, :integer
end
end

View File

@ -0,0 +1,26 @@
class SyncRepStatics < ActiveRecord::Migration
def up
g = Gitlab.client
# projects = Project.find_by_sql("SELECT p.* FROM projects p, project_scores ps where p.id = ps.project_id and p.gpid is not null and ps.changeset_num > 0")
projects = Project.where("gpid is not null")
count = projects.count / 30 + 2
transaction do
for i in 1 ... count do i
projects.page(i).per(30).each do |project|
begin
puts project.id
g.rep_stats(project.gpid).each do |static|
puts static.uname
RepStatics.create(:project_id => project.id, :uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
end
rescue
logger.error("Sync rep failed!")
end
end
end
end
end
def down
end
end

View File

@ -1296,7 +1296,7 @@ a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: no
/*20160310分班样式*/
.select-class-option {width:125px;}
/* 弹框 */
/* 代码查重弹框 */
a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.Blue-btn{ background:#3598db; color:#fff;}
.fl{ float:left;}

View File

@ -1487,3 +1487,13 @@ a.choose-active {background-color:#269ac9; color:#ffffff;}
a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;}
a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
a.st_img { display:block;width:32px; height:32px; border:1px solid #CCC; padding:1px;}
/* 代码查重弹框 */
a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.Blue-btn{ background:#3598db; color:#fff;}
.fl{ float:left;}
.fr{ float:right;}
.blue-border-box{ width:500px; padding:20px; margin:0 auto; background:#fff;}
.box-con h4{ font-size:14px; font-weight: bold; width:450px; text-align:center;}
.box-con{ width:450px; margin:0 auto; text-align:center;}
.box-con-a{ width:170px; margin:0 auto; margin-top:10px;}

View File

@ -1200,3 +1200,4 @@ a.chooseActive {background-color:#269ac9; color:#ffffff;}
.popupClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:10px; top:5px;}
.subjectType {width:70px; text-align:center;}
.subjectCount {width:65px; text-align:center;}
.button-rep { color: #888;display: inline-block;background: #eee;padding: 2px 5px;}

View File

@ -0,0 +1,11 @@
FactoryGirl.define do
factory :rep_static, :class => 'RepStatics' do
project_id 1
commits_num 1
uname "MyString"
email "MyString"
add 1
del 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe RepStatics, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end