Class Result

java.lang.Object
com.spertus.jacquard.common.Result
Direct Known Subclasses:
ExceptionResult

public class Result extends Object
The result of an evaluation of student code.
  • Constructor Details

    • Result

      public Result(String name, double score, double maxScore, String message, Visibility visibility)
      Creates a result with the specified properties.
      Parameters:
      name - the name of the checker
      score - the actual score
      maxScore - the maximum possible score
      message - an explanation of the result or the empty string
      visibility - the visibility of the result to the student
    • Result

      public Result(String name, double score, double maxScore, String message)
      Creates a result with the visibility level specified in Autograder.visibility.
      Parameters:
      name - the name of the checker
      score - the actual score
      maxScore - the maximum possible score
      message - an explanation of the result or the empty string
  • Method Details

    • getName

      public String getName()
      Gets the name of this result.
      Returns:
      the name
    • getScore

      public double getScore()
      Gets the score (points earned) of this result.
      Returns:
      the score
    • getMaxScore

      public double getMaxScore()
      Gets the maximum possible score of the test associated with this result.
      Returns:
      the maximum score
    • getMessage

      public String getMessage()
      Gets the message with any additional information about this result.
      Returns:
      the message, possibly the empty string
    • getVisibility

      public Visibility getVisibility()
      Gets the visibility level of this result.
      Returns:
      the visibility
    • setVisibility

      public void setVisibility(Visibility visibility)
      Sets the visibility of this result.
      Parameters:
      visibility - the visibility
    • changeVisibility

      public Result changeVisibility(Visibility visibility)
      Changes the visibility of this result and returns it.
      Parameters:
      visibility - the visibility
      Returns:
      this result with the new visibility
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • makeError

      public static Result makeError(String name, Throwable throwable)
      Makes a result indicating an exceptional event occurred
      Parameters:
      name - the name
      throwable - the underlying Error or Exception
      Returns:
      a result
    • makeResult

      public static Result makeResult(String name, double actualScore, double maxScore, String message)
      Makes a result with the provided score and message with the visibility level specified in Autograder.visibility.
      Parameters:
      name - the name
      actualScore - the number of points earned
      maxScore - the number of points possible
      message - any message
      Returns:
      a result
    • makeResult

      public static Result makeResult(String name, double actualScore, double maxScore, String message, Visibility visibility)
      Makes a result with the provided characteristics.
      Parameters:
      name - the name
      actualScore - the number of points earned
      maxScore - the number of points possible
      message - any message
      visibility - the visibility
      Returns:
      a result
    • makeSuccess

      public static Result makeSuccess(String name, double score, String message)
      Makes a result indicating a total success.
      Parameters:
      name - the name
      score - the number of points earned
      message - any message
      Returns:
      a result
    • makeSuccess

      public static Result makeSuccess(String name, double score, String message, Visibility visibility)
      Makes a result indicating a total success.
      Parameters:
      name - the name
      score - the number of points earned
      message - any message
      visibility - the visibility level
      Returns:
      a result
    • makeFailure

      public static Result makeFailure(String name, double maxScore, String message)
      Makes a result indicating a total failure.
      Parameters:
      name - the name
      maxScore - the number of points not earned
      message - any message
      Returns:
      a result
    • makeFailure

      public static Result makeFailure(String name, double maxScore, String message, Visibility visibility)
      Makes a result with the specified visibility level indicating a total failure.
      Parameters:
      name - the name
      maxScore - the number of points not earned
      message - any message
      visibility - the visibility level
      Returns:
      a result
    • makeAllOrNothing

      public static Result makeAllOrNothing(List<Result> results, String name, String allMessage, String nothingMessage, double maxScore, boolean includeMessages)
      Creates a single result summarizing a list of results, giving credit only if all the results indicate complete success (having a score equal to the maximum score}. Otherwise, the returned result has a score of 0.

      The message of the new result begins with either allMessage (for all successful) or nothingMessage. If includeMessages is true, the messages of the individual results will be appended to the message of the produced result.

      All of the passed results must have the same visibility level, which will be used for the created result.

      Parameters:
      results - the results to summarize
      name - the name of the created result
      allMessage - the message to include if all results are successful
      nothingMessage - the message to include if any results are not successful
      maxScore - the score if all results are successful
      includeMessages - whether to include the messages of the results
      Returns:
      a new result
      Throws:
      IllegalArgumentException - if all the passed results do not have the same visibility level or if there are no passed results
    • changeVisibility

      public static void changeVisibility(List<Result> results, Visibility visibility)
      Changes the visibility of all the results.
      Parameters:
      results - the results
      visibility - the new visibility
    • reorderResults

      public static List<Result> reorderResults(List<Result> results, Result.Order order)
      Produces a sorted copy of the results.
      Parameters:
      results - the results
      order - the ordering
      Returns:
      the sorted result list