How To: Extend the Ed-Fi ODS / API - Student Transcript Example
In this example, we will create a new domain entity called Student Transcript. This entity will be exposed in Ed-Fi ODS / API through a new API resource called studentTranscripts.
Before you begin:
- This example uses MetaEd to generate extended artifacts and documentation. MetaEd is a free tool developed by the Ed-Fi Alliance, and is the recommended way to add new fields to the Ed-Fi ODS / API. You should download and install MetaEd before beginning. If you prefer to generate extended artifacts manually instead of using MetaEd, steps are listed in Appendix A of this page.
- This example assumes knowledge of the basic concepts described in the How To: Extend the ODS / API - Student Transportation Example. If you're new to the Ed-Fi technology stack, or if you haven't used MetaEd before, then we suggest you run through that example first.
- This example assumes that the Ed-Fi ODS / API has been successfully downloaded and is running in a local development environment per the instructions in the Getting Started documentation.
- Back up any existing code or scripts, either in source control or on your file system. This is important if you or your team have performed these steps before. The MetaEd deployment feature replaces existing files, some of which may contain hand-crafted customizations (e.g., to define an authorization strategy).
Step 1. Design Your Extension
In a real project, you would take the preliminary step of designing your extension, and analyzing how your needs map to the Ed-Fi ODS / API data model. We'll propose a design.
This example will create a new Student Transcript entity, which will carry information about where students enroll in college after graduation, a new element indicating whether graduates were part of a special education program, and some additional information about whether a transmitted record is an official or unofficial submission.
Based on our needs, we require a new entity (to contain information about postsecondary institutions) and we need to add some elements to existing entities. The following diagram is a sketch showing the additional entity and the new elements we're bolting on to existing Ed-Fi entities.
You'll notice that a few elements are shown with a type of "descriptor." The Ed-Fi Descriptor is analogous to an enumeration. It's an Ed-Fi-specific design pattern that allows for enumeration-like definition and validation within an operational context, but may vary between contexts. We'll see more about how these are implemented below.
This example is somewhat complex, but illustrates most of the advanced concepts required to extend the Ed-Fi ODS / API. Let's continue with the mechanics.
Step 2. Author Your Extension Using MetaEd
In this step, we'll create a new project in MetaEd, and author our new entity. You do need to download and install MetaEd to do this step. Do that now if you haven't already.
Step 2a. Set or Confirm MetaEd Target Version
MetaEd allows you to target different versions of the Ed-Fi technology stack and data model. Confirm that your MetaEd IDE is targeting v6.1 by following the instructions in the Version Targeting documentation for the MetaEd IDE.
The desired model for the latest ODS / API is "ed-fi-model-4.0".
Step 2b. Create a New Extension Project
Create a new extension by following the steps in MetaEd IDE - Creating and Maintaining Your Extension. In this example our extension is in a folder called "StudentTranscript"
Listing of files
StudentTranscript/
├─ Association/
├─ Choice/
├─ Common/
├─ Descriptor/
├─ Domain/
├─ DomainEntity/
├─ Enumeration/
├─ Interchange/
├─ Shared/
├─ package.json
Step 2c. Update the package.json File
Open the package.json file by double-clicking on the file in the tree view to the left and provide an appropriate name for your project. In this case we will call it "SampleStudentTranscript".
Click "Save" under the "File" menu or press Ctrl + S to save your changes.
{
"metaEdProject": {
"projectName": "SampleStudentTranscript",
"projectVersion": "1.0.0"
}
}
Step 2d. Add MetaEd Source Files to Your Project
We're going to add seven new .metaed source files to the project we just created. You'll recall that MetaEd files are required to be organized into subfolders named after their entity type. The core ed-fi-model project provides examples of subfolder naming.
2d.1. Add Domain Entities
Now we'll add two MetaEd source files to the DomainEntity folder. Right-click on the folder DomainEntity, and select New File.
Name the new file PostSecondaryOrganization.metaed to match the name of the
new entity to be created.
Note the new file appears in the tree view to the left. Double-click on the file in the tree view to open it. Type or copy and paste the code listing below into your MetaEd file:
Note that errors will be listed in the linter panel until the referenced Descriptors are created in a future step.
MetaEd Source for PostSecondaryOrganization Entity
Domain Entity PostSecondaryOrganization
documentation "PostSecondaryOrganization"
shared string EdFi.NameOfInstitution
documentation "The name of the institution."
is part of identity
descriptor InstitutionLevel
documentation "The level of the institution."
is required
descriptor InstitutionControl
documentation "The type of control of the institution (i.e., public or private)."
is required
bool AcceptanceIndicator
documentation "An indication of acceptance."
is required
We'll now create a Domain Entity source file, called
StudentAcademicRecordExtension, to add our new elements to the existing
Student Academic Record entity. Note that we can extend an existing entity using
the additions keyword (line 1 in the example below).
MetaEd Source for StudentAcademicRecordExtensions Entity
Domain Entity EdFi.StudentAcademicRecord additions
domain entity PostSecondaryOrganization
documentation "A reference to the postsecondary organization."
is optional
descriptor SubmissionCertification
documentation "The type of submission certification."
is optional
common extension EdFi.ClassRanking
documentation "Class Ranking Extension"
is optional