Class GradeTemplate

java.lang.Object
com.gophers.structures.grades.GradeTemplate
All Implemented Interfaces:
Grade
Direct Known Subclasses:
ChatBotGeneratorGrade, ChatBotGrade, ChatBotPlatformGrade, ChatBotSimulationGrade, ProgramGrade

public abstract class GradeTemplate extends Object implements Grade
An abstract class that implements the Grade interface and provides a template for grading assignments or tests based on results. This class processes the outcome of tests, allocates marks based on test weightings, adjusts for failures, and provides feedback on each test method.
  • Field Details

    • testMarks

      protected Map<String,Integer> testMarks
      A map that stores the marks assigned to each test method. The key is the test method name, and the value is the marks for that test.
    • feedbackMap

      protected Map<String,Integer> feedbackMap
      A map that stores feedback for each test method. The key is the test method name, and the value is the feedback score for that test.
  • Constructor Details

    • GradeTemplate

      public GradeTemplate(org.junit.runner.Result result, int totalMarks)
      Constructs a new GradeTemplate instance with the given test result and total available marks. This constructor initializes the weightings and feedback maps, and calculates the marks earned based on the result of the test.
      Parameters:
      result - The result of running the test, including any failures.
      totalMarks - The total marks possible for the test or assignment.
  • Method Details

    • getMarks

      public int getMarks()
      Returns the marks earned by the student for the test or assignment. This is the total marks available minus any deductions for failed tests.
      Specified by:
      getMarks in interface Grade
      Returns:
      The marks earned by the student.
    • getTotalMarks

      public int getTotalMarks()
      Returns the total marks available for the assignment or test.
      Specified by:
      getTotalMarks in interface Grade
      Returns:
      The total marks available.
    • getTestFeedback

      public Map<String,Integer> getTestFeedback()
      Returns a map containing feedback for each test method. The map contains test names as keys and feedback scores as values.
      Specified by:
      getTestFeedback in interface Grade
      Returns:
      A map of test names to feedback scores.
    • allocateWeightings

      protected abstract void allocateWeightings()
      Allocates weightings for each test. Subclasses should implement this method to define how marks are distributed across different test methods.
    • allocateFeedback

      protected abstract void allocateFeedback()
      Allocates feedback for each test. Subclasses should implement this method to define the feedback for each test method based on the result.