Class Grader

java.lang.Object
com.spertus.jacquard.common.Grader
Direct Known Subclasses:
CheckstyleGrader, PmdGrader, SyntaxGrader

public abstract class Grader extends Object
The superclass of all graders.
  • Constructor Details

    • Grader

      public Grader(String name)
      Creates a grader.
      Parameters:
      name - the name of the grader
      Throws:
      ClientException - if Autograder has not been initialized
  • Method Details

    • getCallableSingleTarget

      public abstract Callable<List<Result>> getCallableSingleTarget(Target target)
      Gets a Callable through which this grader can be called on a single target.
      Parameters:
      target - the target
      Returns:
      a Callable through which this grader can be called
    • getCallableMultiTarget

      public Callable<List<Result>> getCallableMultiTarget(Target... targets)
      Gets a Callable through which this grader can be called on multiple targets. The default implementation just appends the results of successive calls to getCallableSingleTarget(Target), but subclasses may provide their own implementations to handle multiple targets specially.
      Parameters:
      targets - the targets
      Returns:
      a Callable through which this grader can be called
    • grade

      public List<Result> grade(List<Target> targets)
      Grades the provided targets.
      Parameters:
      targets - the targets
      Returns:
      the results
      Throws:
      ClientException - if Autograder has not been initialized
    • grade

      public List<Result> grade(Target... targets)
      Grades the provided targets.
      Parameters:
      targets - the targets
      Returns:
      the results
      Throws:
      ClientException - if Autograder has not been initialized
    • gradeAll

      public static List<Result> gradeAll(Target target, Grader... graders)
      Runs all graders on the provided target.
      Parameters:
      target - the target for each of the graders
      graders - graders, in the order they should be run
      Returns:
      the collected results
      Throws:
      ClientException - if Autograder has not been initialized
    • makeSuccessResultList

      protected List<Result> makeSuccessResultList(double maxPoints, String message)
      Creates a one-element list holding a result indicating complete success.
      Parameters:
      maxPoints - the maximum number of points, all of which are earned
      message - any message to include
      Returns:
      the result
    • makeSuccessResult

      protected Result makeSuccessResult(double maxPoints, String message)
      Creates a result for a fully successful outcome.
      Parameters:
      maxPoints - the maximum number of points, all of which are awarded
      message - any message to include
      Returns:
      the result
    • makeFailureResultList

      protected List<Result> makeFailureResultList(double maxPoints, String message)
      Creates a one-element list holding the result of a completely unsuccessful outcome.
      Parameters:
      maxPoints - the maximum number of points, none of which are awarded
      message - any message to include
      Returns:
      the result
    • makeFailureResult

      protected Result makeFailureResult(double maxPoints, String message)
      Creates a result for a completely unsuccessful outcome.
      Parameters:
      maxPoints - the maximum number of points, none of which are earned
      message - any message to include
      Returns:
      the result
    • makeExceptionResultList

      protected List<Result> makeExceptionResultList(Throwable throwable)
      Creates a one-element list holding the result for a single unhandled throwable.
      Parameters:
      throwable - the unhandled throwable
      Returns:
      the result
    • makeExceptionResult

      protected Result makeExceptionResult(Throwable throwable)
      Creates a result when a grader threw an exception instead of returning a result.
      Parameters:
      throwable - the unhandled throwable
      Returns:
      the result
    • makePartialCreditResult

      protected Result makePartialCreditResult(double points, double maxPoints, String message)
      Creates a result indicating partial credit.
      Parameters:
      points - the number of points awarded
      maxPoints - the maximum possible points
      message - any message
      Returns:
      the result