Skip to content

Calculate averages and add tests to grades service

What does this MR do?

Here I am adding a function to calculate the simple average of a course array and a function for the weighted average of a course array.

I am also introducing two new interfaces :

  • CourseGradeBase : if someone want to use getGradesSimpleAverage or getGradesWeightedAverage function, he/she has to map the object to an object of that interface and create an Array<CourseGradeBase> by pushing items to the array
  • GradesAverageResult : the before-mentioned functions return objects of that type so that they can be used throughout the application without needing to calculate things like sum of ects,units, passed courses, average grade etc

I am also adding the basic tests for the grades service using the API Testing Controller in @universis/common to mock the API calls and flush the result. For the average calculation I am adding more thorough unit tests

Related issues and links

Fix #152 (closed)

Developer Checklist

  • I have successfully run the code of this merge request locally

  • I have verified locally that my changes work for all necessary screen sizes

  • I have tried out the changes of this MR with different users to identify bugs

  • Coding is in progress, and I have marked the MR as WIP

  • Coding is completed and the MR is ready for review

  • My branch is up-to-date with the upstream master branch

  • My MR follows the contribution guidelines

  • I have added a comment with screenshots of the code running locally

Tech review Checklist

Have you verified that what is supposed to happen, actually does, and what is not supposed to happen, indeed does not?

  • The MR accurately describes the changes and has a relevant title/description
  • The MR does what it is supposed to according to its title, description and related issues/links
  • I have successfully run the changes locally, and tried the new code

Overall review Checklist

  • The MR references related issues/MRs
  • The MR provides links to screens and screenshots
  • The commits of the MR describe the changes, have proper wording, and follow the guidelines
  • I have successfully run the changes locally, and tried the new code
  • The MR is ready for merge (rebased, commit squashed if needed, etc)
Edited by Pavlos Karakalidis

Merge request reports