//代码查重
<% 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("");
$('#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 %>
//请求查重
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("");
$('#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("");
$('#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("");
$('#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("");
$('#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"));
}
});
};
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("");
$('#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 %>
<% end %>