From 93905f2f325bec101e5f1b46928e3730da20349e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Jul 2015 17:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/student_work_test.rb | 36 +++++++++++++++++++ .../_programing_work_show.html.erb | 18 ++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index b9264191c..d9ac5e935 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -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 diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 80284dac0..2711ad172 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -26,6 +26,19 @@
@@ -34,10 +47,11 @@ | <%= test.output%> | -错误 | -0 | +<%= test.student_work_test.nil? ? "正在编译队列中" : test.student_work_test.status_to_s%> | +<%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%> |