老师布置作业界面增加错误信息的提示

This commit is contained in:
sw 2015-08-04 15:25:05 +08:00
parent c176122c00
commit 3f51368bb2
5 changed files with 52 additions and 1 deletions

View File

@ -367,6 +367,7 @@ class HomeworkCommonController < ApplicationController
client.request(request)
end
result = JSON.parse(res.body)
@err_msg = result["compile_error_msg"]
result["results"].each do |re|
@result = re["status"]
end

View File

@ -66,4 +66,32 @@ module HomeworkCommonHelper
link
end
#将状态转换为错误信息
def status_to_err_msg status
case status.to_i
when -1
'编译出错'
when -2
'输出错误'
when -3
'输出错误'
when 1
'运行出错'
when 2
'超时'
when 3
'内存超出'
when 4
'输出超出'
when 5
'禁用函数'
when 6
'其他错误'
when 0
'成功'
else
'未知错误'
end
end
end

View File

@ -129,6 +129,18 @@
<div class="cl"></div>
</div>
<% end %>
<table class="border_ce" cellpadding="0" cellspacing="0" id="homework_work_test_show" style="display: <%= homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg ? "block" : "none"%>">
<tbody>
<tr class="border_t" >
<td class="td_end fb c_red w60 td_board_left">
错误信息:
</td>
<td class="td_end wl" id="homework_work_test_desc">
<%= 123123123%>
</td>
</tr>
</tbody>
</table>
</ul>
</div>

View File

@ -1,2 +1,8 @@
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
$("#test_result_<%= @index%>").val("<%= @result%>");
<% if @err_msg || @result != 0%>
$("#homework_work_test_show").show();
$("#homework_work_test_desc").text("<%= escape_javascript(@err_msg || status_to_err_msg(@result))%>");
<% else%>
$("#homework_work_test_show").hide();
<% end%>

View File

@ -694,6 +694,9 @@ a.work_list_tit{width:580px; display:block; overflow:hidden; font-size:14px; f
.border_l{border-left:1px solid #e4e4e4;}
.border_t{ border-top:1px solid #e4e4e4;}
.td_end{border-top:1px solid #e4e4e4; height:auto; padding:5px; }
.wl{text-align: left;}
.vt{vertical-align: top;}
.td_board_left{border-right: 1px solid #e4e4e4;}
.c_w{ color:#fff;}
.filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;}
@ -709,6 +712,7 @@ a:hover.about_me{ color:#0781b4;}
.mb5 li{width:200px;word-wrap: break-word;
word-break: normal;
}
#homework_work_test_show{margin-left: 35px;width: 94%;}