Package com.gophers.services.helpers
Class GradeUtils
java.lang.Object
com.gophers.services.helpers.GradeUtils
Utility class for grading-related operations, including calculations and
formatting.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcalculateBonus(int totalScore, int bonus) Calculates the bonus breakdown based on the total score and bonus value.static intcalculateTotalGrade(Map<String, Integer> gradesMap) Calculates the total grade based on the provided grades map.static StringformatTestResult(String criterion, int marksEarned, int totalMarks) Formats a test result string.static StringgetComment(int totalScore) Retrieves a comment based on the total score.getFeedbackAsStatus(Map<String, Integer> feedback) Generates feedback statuses (Passed/Failed) for tests.static intgetTotalMarks(int index) Retrieves the total marks for a specific index.
-
Constructor Details
-
GradeUtils
public GradeUtils()
-
-
Method Details
-
calculateTotalGrade
Calculates the total grade based on the provided grades map. Caps the total grade at 100 if it reaches 90 or more.- Parameters:
gradesMap- aMapwith grade criteria as keys and scores as values- Returns:
- the total grade
-
calculateBonus
Calculates the bonus breakdown based on the total score and bonus value.- Parameters:
totalScore- the total score achievedbonus- the bonus points awarded- Returns:
- a
Stringrepresenting the bonus breakdown
-
getComment
Retrieves a comment based on the total score.- Parameters:
totalScore- the total score achieved- Returns:
- a
Stringcomment associated with the score range
-
getFeedbackAsStatus
Generates feedback statuses (Passed/Failed) for tests. -
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
Formats a test result string.- Parameters:
criterion- the test criterionmarksEarned- the marks earned for the testtotalMarks- the total marks for the test- Returns:
- a formatted string representing the test result
-