Class: Course::Assessment::ProgrammingEvaluationService::Result

Inherits:
Struct
  • Object
show all
Defined in:
app/services/course/assessment/programming_evaluation_service.rb

Overview

Represents a result of evaluating a package.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#evaluation_idObject

Returns the value of attribute evaluation_id

Returns:

  • (Object)

    the current value of evaluation_id


13
14
15
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 13

def evaluation_id
  @evaluation_id
end

#exit_codeObject

Returns the value of attribute exit_code

Returns:

  • (Object)

    the current value of exit_code


13
14
15
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 13

def exit_code
  @exit_code
end

#stderrObject

Returns the value of attribute stderr

Returns:

  • (Object)

    the current value of stderr


13
14
15
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 13

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout

Returns:

  • (Object)

    the current value of stdout


13
14
15
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 13

def stdout
  @stdout
end

#test_reportsObject

Returns the value of attribute test_reports

Returns:

  • (Object)

    the current value of test_reports


13
14
15
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 13

def test_reports
  @test_reports
end

Instance Method Details

#error?Boolean

Checks if the evaluation errored.

This does not count failing test cases as an error, although the exit code is nonzero.

Returns:

  • (Boolean)

19
20
21
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 19

def error?
  test_reports.values.all?(&:nil?) && exit_code != 0
end

#exceptionObject

Obtains the exception suitable for this result.


36
37
38
39
40
41
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 36

def exception
  return nil unless error?

  exception_class = time_limit_exceeded? ? TimeLimitExceededError : Error
  exception_class.new(exception_class.name, stdout, stderr)
end

#time_limit_exceeded?Boolean

Checks if the evaluation exceeded its time limit.

This uses a Bash behaviour where the exit code of a process is 128 + signal number, if the process was terminated because of the signal.

The time limit is enforced using SIGKILL.

Returns:

  • (Boolean)

31
32
33
# File 'app/services/course/assessment/programming_evaluation_service.rb', line 31

def time_limit_exceeded?
  exit_code == 128 + Signal.list['KILL']
end