Class GradeUtils

java.lang.Object
com.gophers.services.helpers.GradeUtils

public class GradeUtils extends Object
Utility class for grading-related operations, including calculations and formatting.
  • Constructor Details

    • GradeUtils

      public GradeUtils()
  • Method Details

    • calculateTotalGrade

      public static int calculateTotalGrade(Map<String,Integer> gradesMap)
      Calculates the total grade based on the provided grades map. Caps the total grade at 100 if it reaches 90 or more.
      Parameters:
      gradesMap - a Map with grade criteria as keys and scores as values
      Returns:
      the total grade
    • calculateBonus

      public static String calculateBonus(int totalScore, int bonus)
      Calculates the bonus breakdown based on the total score and bonus value.
      Parameters:
      totalScore - the total score achieved
      bonus - the bonus points awarded
      Returns:
      a String representing the bonus breakdown
    • getComment

      public static String getComment(int totalScore)
      Retrieves a comment based on the total score.
      Parameters:
      totalScore - the total score achieved
      Returns:
      a String comment associated with the score range
    • getFeedbackAsStatus

      public static Map<String,String> getFeedbackAsStatus(Map<String,Integer> feedback)
      Generates feedback statuses (Passed/Failed) for tests.
      Parameters:
      feedback - a Map with test names as keys and pass status as values
      Returns:
      a Map with test names as keys and "Passed"/"Failed" as values
    • getTotalMarks

      public static int getTotalMarks(int index)
      Retrieves the total marks for a specific index.
      Parameters:
      index - the index representing a grading component
      Returns:
      the total marks for the component
      Throws:
      IllegalArgumentException - if the index is invalid
    • formatTestResult

      public static String formatTestResult(String criterion, int marksEarned, int totalMarks)
      Formats a test result string.
      Parameters:
      criterion - the test criterion
      marksEarned - the marks earned for the test
      totalMarks - the total marks for the test
      Returns:
      a formatted string representing the test result