parent
0fc3e0077a
commit
93905f2f32
@ -1,6 +1,42 @@
|
|||||||
|
# encoding: utf-8
|
||||||
class StudentWorkTest < ActiveRecord::Base
|
class StudentWorkTest < ActiveRecord::Base
|
||||||
attr_accessible :student_work_id, :homework_test_id
|
attr_accessible :student_work_id, :homework_test_id
|
||||||
|
|
||||||
belongs_to :homework_test
|
belongs_to :homework_test
|
||||||
belongs_to :student_work
|
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
|
end
|
||||||
|
Loading…
Reference in new issue