修改查重有时候失败的问题

This commit is contained in:
yuanke 2016-04-15 18:48:39 +08:00
parent 5efd55de2d
commit 5aba3fb11b
3 changed files with 66 additions and 68 deletions

View File

@ -956,6 +956,7 @@ class CoursesController < ApplicationController
@student_works.each do |tmpwork|
@works_hash[tmpwork.id] = tmpwork
puts tmpwork.id
end
#respond_to do |format|

View File

@ -1,5 +1,4 @@
//代码查重
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})%>');
@ -14,7 +13,71 @@ var homework_id = <%=@homework.id%>;
hideModal($(".blue-border-box"));
}
<% else %>
<% if !@homework.simi_time %>
<% 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("<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"));
}
});
};
test_repeat();
<% else%>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>');
@ -30,71 +93,6 @@ var homework_id = <%=@homework.id%>;
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

@ -268,7 +268,6 @@ 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'