# 4. Create Set of School Terms - Ready

### Purpose

<span style="font-weight: 400;">For every academic year, there needs to be a user-specified number of term records, so when a new academic year record is added, the program should automatically create the associated term records for that year. The program knows how many term records to make, and how they should be configured from the records in the term label table. </span>

#### ***Term Labels***

The user adds one “term label” record to represent each term in a general school year. The number of records in the term label table equals the number of terms in a year. There are start days and start months fields in the term label records, but there are no actual years since the term label is general in nature and applies to any year. The **Terms** records are created using the information in the term label records.

Term labels records can not be associated with a year since, so there can not be a date field in the term label records.

The term label sequence shows the order of the terms as the academic year progresses.

#### ***Terms (or School Terms)***

Terms are a list of actual terms the school is/was/will be in operation. They have a start date and an end date, and are associated with an Academic Year and a **term label.**

The term sequence, the **<span style="text-decoration: underline;">ordinate</span>** field, continues from 1, the very first term in the system, continuously through all terms of operation. These will follow the term start dates as the start dates will also indicate the order of the terms.

#### Setting the default term start and end dates

Information in the term label record and the academic years are used to set the default term start and end dates. The user may manually adjust these dates year to year, as the same date may fall on a Monday one year but a Tuesday the next year. Setting the default term dates helps the user to pick an appropriate date for each term.

<span style="font-weight: 400;">While the term record must contain the actual start and end dates, the term label record only contains a general start day and start month. </span>

##### **<span style="color: #e03e2d;">Academic Years generally cross over a calendar year, so the actual year of the term is difficult to figure out.</span>**

<span style="text-decoration: underline; background-color: #fbeeb8;"><span style="font-weight: 400; color: #000000; text-decoration: underline;">For this reason the following two fields must be added to the ***Term label*** record:</span></span>

<p class="callout warning"><span style="color: #000000;"><span style="font-weight: 400;">Add the fields "Term Starts" &amp; "</span><span style="font-weight: 400;">Term Ends" to the term label table</span></span></p>

<p class="callout warning"><span style="font-weight: 400; color: #000000;">For each of the fields above, menu options are the same: <span style="text-decoration: underline;">in academic start year,</span> <span style="text-decoration: underline;">in academic end year</span></span></p>

The user selects academic start year if the term begins in the same year as the academic start year or selects academic end year if the term starts in the same year as the academic end year. The same applies to the end year.

#####   


#### Create (School) Terms

Based on the information in the Term Label table, Terms are automatically made for each academic year added to the school. The term label records contain the sequence of terms, the names of terms, and the number of records indicated the total number terms.

For every new academic year record, PEMS makes a number of term records equal to the number of Term Label records and updates the ordinate of the terms to match the sequence of the term label records.


***Make a new set of term records when an academic year is created***

<p class="callout info"><span style="font-weight: 400;">Key trigger is the creation of a new academic year record.</span></p>

<p class="callout info"><span style="font-weight: 400;">Create a term record and associate it to the academic year record and the term label record with flag = ***official start*** and status = ***active***. If no record is found, stop.</span></p>

<p class="callout info"><span style="font-weight: 400;">Set the (school) term ***ordinate*** to maximum term ordinate value + 1</span></p>

<p class="callout info"><span style="font-weight: 400;">If the ***term label*** start year field is set to 'academic start year' then use the academic year's start year field for the ***term*** start year. If the ***term label*** start year field is set to 'academic end year' then use the academic year's end year field for the ***term*** end year. </span></p>

<p class="callout info"><span style="font-weight: 400;">If the ***term label*** end year field is set to 'academic start year' then use the academic year's start year field for the ***term*** end year. If the ***term label*** end year field is set to 'academic end year' then use the academic year's end year field for the ***term*** end year. </span></p>

<p class="callout info">Calc<span style="font-weight: 400;">ulate the term record's start date from the term label record “start day” and term label record “start month” and the start year found above. </span></p>

<p class="callout info"><span style="font-weight: 400;">Calculate the term record's end date from the term label record “end day” and term label record “end month” and the end year found above.</span></p>

<p class="callout info"><span style="font-weight: 400; color: #e03e2d;">Calendar days - TBD</span></p>

<p class="callout info"><span style="font-weight: 400; color: #e03e2d;">School days - TBD</span></p>

<p class="callout info"><span style="font-weight: 400;">Term Name = concatenate Term Label name and Term Start Year.</span></p>

<p class="callout info"><span style="font-weight: 400;">Set the Term Flag = Term Label Flag</span></p>

<p class="callout info"><span style="font-weight: 400;">Set the term status = the status of the associated academic year. *note: if the user tiggers this automation mid year, all terms will be set to current, regardless of actual status, the user will need to manually update them.*</span></p>

<p class="callout info"><span style="font-weight: 400;">Find the next ***active*** term label record with sequence equal to the last term label record sequence + 1. If there are no records that meet this criteria, add 1 to the sequence value. Repeat.</span></p>

<p class="callout info"><span style="font-weight: 400;">If the term label record flag value is "***Offical End***" and status = "***active***", then this is the last term record to be made. </span></p>

*<span style="font-weight: 400;">Note: Add an additional exit criteria as a back-up in case this loop goes on for ever, for example, if the user did not configure the term label records properly.</span>*

##### <span style="font-weight: 400;">Checking for student terms already created</span>

<span style="font-weight: 400;">There is a case where some terms may have been created for the grade span but not all terms. This may happen when data is migrated into PEMS but the information is incomplete or not properly related to other records. </span>

<span style="font-weight: 400;">Student term records should not be created automatically if there are any student term records in that grade span already. Student term records exist in a grade span based on their at\_grade field. If the at\_grade field is equal within the start and end grades of the grade span, then there are existing records, the automation should not run.</span>

<span style="font-weight: 400;">The user will have to manually add the student terms or delete the existing records and be provided a means to manually launch this process</span>

<p class="callout info"><span style="font-weight: 400;">Check for student term records with at\_grade field between the grade span start and end grades</span></p>

<p class="callout info"><span style="font-weight: 400;">If any records found, then do not automatically create student terms.</span></p>

<p class="callout info"><span style="font-weight: 400;">Provide users a means to manually launch this process if they delete student term records</span></p>

#### <span style="font-weight: 400;">Potential for Errors</span>

<p class="callout danger"><span style="font-weight: 400;">The user may choose to delete the student terms and start over or add the missing terms manually. If the user adds terms manually, then the student sequence may not be ordered according to the actual start date</span></p>