Custom function to populate a field with the number of records in a related list

Custom function to populate a field with the number of records in a related list

I would like a field on a custom module to show the number of records in a related module.  I would like a field "tests" on "custommodule1" to return the number of records in "custommodule3" These two modules are related by the lookup field "student" on custommodule3.

Any help would be appreciated!