|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.codescore.exe.Grader
public class Grader
This class compiles, executes and generates a diff file for a given submission.
| Field Summary | |
|---|---|
private CompetitionManager |
compMan
|
private org.apache.commons.logging.Log |
log
|
int |
MAX_RUNTIME
The maximum runtime for a program in milliseconds |
protected GradingMode |
mode
The mode of this grader |
private ProcessBuilder |
pb
|
static String |
PRB_NAME_VAR
This is the place-holder for the Unix problem name. |
static String |
SRC_FILE_VAR
This is the place-holder for the source file name. |
private Submission |
submission
|
| Constructor Summary | |
|---|---|
Grader(Submission s,
CompetitionManager cm,
GradingMode mode)
Create a new Grader |
|
| Method Summary | |
|---|---|
private void |
commitChanges()
|
CompileResult |
compile()
Compile the submission to machine/byte code |
ExecutionResult |
execute()
Execute the program. |
private ObjectContext |
getOC()
|
Submission |
getSubmission()
|
private ExecutionResult |
returnER(ExecutionResult er)
A helper method for cleaning up after execution |
private void |
scoreSub()
|
static void |
scoreSubmission(TeamSubmission ts,
CompetitionManager cm)
Score a submission |
private void |
setCompileError()
|
private void |
setCorrect()
|
private void |
setRunError()
|
private void |
setTimeError()
|
private int |
watchTime(ExecutionResult er)
This method watches an execution and if it exceeds MAX_RUNTIME
it will kill the process and set the status of the submission to indicate
that it exceeded the maximum allowable runtime. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PRB_NAME_VAR
_Problem.getUnixName(),
Constant Field Valuespublic static final String SRC_FILE_VAR
File.getAbsoluteFile(),
TeamSubmission.getSrcFile(),
Constant Field Valuespublic final int MAX_RUNTIME
private final CompetitionManager compMan
private org.apache.commons.logging.Log log
private ProcessBuilder pb
private final Submission submission
protected final GradingMode mode
GradingMode| Constructor Detail |
|---|
public Grader(Submission s,
CompetitionManager cm,
GradingMode mode)
s - The submission to be gradedcm - The competition manager to pull settings frommode - The mode for this grader| Method Detail |
|---|
public static void scoreSubmission(TeamSubmission ts,
CompetitionManager cm)
ts - The submission to scorecm - Needed to get the scoring mode and the competition start time
if using a time based scoring method. ScoringMode for details on each mode.
public CompileResult compile()
throws IOException
CompileResult that holds references to the
input/output/error streams of the compiler process
IOException - If the source file cannot be written to disk, or the process
fails to start.
public ExecutionResult execute()
throws IOException
compile() method
at the start of execution.
ExecutionResult which holds references to the exit
code of the process and its input/output/error streams.
IOException - see compile()compile()public Submission getSubmission()
private void commitChanges()
private ObjectContext getOC()
private ExecutionResult returnER(ExecutionResult er)
throws IOException
er - The ExecutionResult to be cleaned up and returned
IOException - see ExecutionResult.cleanup()private void scoreSub()
private void setCompileError()
private void setCorrect()
private void setRunError()
private void setTimeError()
private int watchTime(ExecutionResult er)
throws InterruptedException
MAX_RUNTIME
it will kill the process and set the status of the submission to indicate
that it exceeded the maximum allowable runtime.
er - The ExecutionResult to watch.
InterruptedException - If this thread is interrupted while waiting for the execution
finish.TeamSubmission#setStatus(net.launchpad.codescore.dbo.ProblemStatus)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||