How to make average with zoho deluge

How to make average with zoho deluge

Hi, i have two modules
A. Courses
B. Grades

Grades module are related list in module Courses his API Key his "Reatedlist2"

in module grades i have 10 records that associate to one record of course.
In the grades module, there is a number of data on which the grade of that student is measured
like for instance:
Attendance score
Homework grading
midterm test score
Final exam grade
Final project grade

i have one field in module grades thats caculate everybody and giving each grade his final score.

I have a field in the courses module, the purpose of which is to get me a general class average of the grades

I want to create a function that knows how to take all the final grades that exist in the grades module
And let me calculate the number of records that are associated with that course and know how to make an average for me
How is it possible to do that?