-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathstudent_test_case.rb
More file actions
34 lines (29 loc) · 1.06 KB
/
student_test_case.rb
File metadata and controls
34 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class StudentTestCase < ActiveRecord::Base
# Relationships
belongs_to :coding_prompt_answer
has_one :student_test_case_result
def record_result(answer, test_results_array)
tcr = StudentTestCaseResult.new(
test_case_id: self.id,
coding_prompt_answer: answer,
pass: (test_results_array.length == 8 && test_results_array[7].to_i == 1)
)
if !test_results_array[5].blank?
exception_name = test_results_array[6] #.sub(/^.*\./, '')
if !(['AssertionFailedError',
'AssertionError',
'ComparisonFailure',
'ReflectionSupportError'].include?(exception_name) ||
(exception_name == 'Exception' &&
test_results_array[6].start_with?('test timed out'))) ||
test_results_array[6].blank? ||
"null" == test_results_array[6]
tcr.feedback = exception_name
end
end
tcr.save!
end
def display_description()
self.description
end
end