The function uses the following logic to maximize the number of courses assigned to compulsory categories (i.e. categories that are not 99 - Optional):
- For each student course for which the StoredGrade record containing the credit has a value defined for [S_ON_SGR_X]Diploma_Category, the credit for the course is used to fulfill the indicated category. Note that the credit for a course can be always be used to fulfill the 99 - Optional category.
- For each remaining student course, determine the number of compulsory diploma categories the course COULD be used to fulfill. This is a number between 0 (if the credit type(s) for the course do not appear in the credit type list for any compulsory category) and the number of compulsory categories (if the credit type(s) for the course appear in the credit type list for all compulsory categories). This is called the number of potential categories for the student course. If the only compulsory categories a course can be used to fulfill have already been fulfilled because of explicit category assignment, the number of potential categories is 0.
- Order the student courses ascending by the number of potential categories, ignoring courses where the number of potential categories is 0. If more than one course has the same number of potential categories order them, generally, by the order in which credit is earned. That is, ascending by:
- Course grade level (4th character of [Courses]Alt_Course_Number) according to the table below: Note: Do not include course grade level in the sort key at this time – this may be done later if deemed necessary.
- Term Id ([StoredGrades]TermId).
- Completion Date ([StoredGrades]ON_Credit_Date). If undefined, the completion date is the earlier of the day immediately prior to the student's class exit date ([CC]DateLeft) and the end date for the term associated with Term Id ([Terms]LastDay).
Stored Grade Internal Id ([StoredGrades]DCID).
- Process the compulsory diploma categories ascending by category code. For each category, assign the course with the lowest sort key (as described above) which applies to the category and which has not already been assigned. Mark the course as assigned. If the diploma category requires more credit than that for the course just assigned, also assign the next applicable course in the ordered course list. Keep assigning courses until the category is 'full'. If the credit for the course just assigned exceeds the credit remaining to be assigned for the category, mark the course as 'partially assigned' keeping track of how much credit is still available to assign to another category.
- The credit for any course that is not assigned to a diploma category by steps 1-4 is assigned to the 99 - Optional category.
If a credit course is repeated - i.e. more than StoredGrades record containing a final mark for a course (based on local course number) is present - only one instance of the course is returned by the function:
- If non-zero credit is earned, the one with the highest earned credit is returned.
- If more than one class has the 'highest' credit value, then the one with the highest mark is returned.
- If more than one class has the same 'highest' credit and 'highest' mark, then the earliest (based on completion date) is returned.
Most reports (e.g. Status Sheet, OCAS/OUAC, OnSIS) also need to assign diploma categories to in-progress courses, often to determine whether such a course should be considered compulsory. The function therefore accepts a parameter indicating that diploma categories are also to be assigned to classes (i.e. [CC] records) the student has not yet completed.In this case, the function assigns categories to in-progress courses, using the process described above, after the credit for all completed courses has been assigned. The category assignments done for completed courses reduce the number of credits available in each category for assignment to in-progress courses.