界面显示

This commit is contained in:
sw 2015-07-16 17:33:15 +08:00
parent 0fc3e0077a
commit 93905f2f32
2 changed files with 52 additions and 2 deletions

View File

@ -1,6 +1,42 @@
# encoding: utf-8
class StudentWorkTest < ActiveRecord::Base
attr_accessible :student_work_id, :homework_test_id
belongs_to :homework_test
belongs_to :student_work
def status_to_s
case self.result
when -1
'编译出错'
when -2
'答题错误'
when -3
'答案错误'
when 1
'运行出错'
when 2
'超时'
when 3
'内存超出'
when 4
'输出超出'
when 5
'禁用函数'
when 6
'其他错误'
when 0
'成功'
else
'未知错误'
end
end
def test_score
if self.result == 0
format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count)
else
0
end
end
end

View File

@ -26,6 +26,19 @@
<li ><span class="tit_fb ">测试结果:</span>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<!--<%#@work.student_work_test.each do |test|%>-->
<!--<tr class="<%#= cycle("", "b_grey") %>">-->
<!--<td class="td_tit">-->
<!--<%#= test.homework_test.input%>-->
<!--</td>-->
<!--<td class="td_tit">-->
<!--<%#= test.homework_test.output%>-->
<!--</td>-->
<!--<td class="td_50 c_red"><%#= test.status_to_s%></td>-->
<!--<td class="td_50 "><%#= test.test_score%></td>-->
<!--</tr>-->
<!--<%# end%>-->
<%@homework.homework_tests.each do |test|%>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
@ -34,10 +47,11 @@
<td class="td_tit">
<%= test.output%>
</td>
<td class="td_50 c_red">错误</td>
<td class="td_50 ">0</td>
<td class="td_50 c_red"><%= test.student_work_test.nil? ? "正在编译队列中" : test.student_work_test.status_to_s%></td>
<td class="td_50 "><%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%></td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>