Introduction to SE – Section Specification
Section Specification
insightUBC Section Specification 1. API
2. Managing course section data 2.1 Adding a dataset
2.2 Removing a dataset
2.3 Listing all datasets
3. Querying the data for insights
Valid Query argument to performQuery Query EBNF
Valid query keys
Simple example query
Complex example query
4. IInsightFacade.ts
5. Caching Progress (Persistence)
Change Log
01/22/24 – Updated the Caching Progress section
https://sites.google.com/view/ubccpsc310-23w2/project/section-specification?authuser=0 1/28
1/29/24, 5:08 PM Introduction to SE – Section Specification
insightUBC Section Specification
UBC has a wide variety of courses. Manually viewing information about the courses is painful and slow. Students and Professors (users) would like to be able to query information about courses to gain insights into UBC. InsightUBC will provide a way for users to manage their course section data and query this data for insights.
Users will interact with your project through a xed API, de ned through a provided interface,
. Very important: do not alter the given API (interface) in any way, as it is used to grade
your project!
The interface provides four methods: , , Users will manage their course section data through the methods
and users will query their data using the method
, and . and
The contents of the API le, , is given below in the IInsightFacade.ts section. Read the entire le carefully – it contains details about the expected parameters, what the methods should do and what specific error types to throw for failures.
For example, a user might write the following code to use your API:
2. Managing course section data
We allow users to perform three actions for managing their data: 1. Adding a dataset, so it is available for querying.
2. Listing all datasets that are available to query.
3. Removing a dataset, so it is no longer available for query.
Each of these actions has a corresponding API method de ned in . 2.1 Adding a dataset
)”piz.snoitces-cbu/sevihcra/secruoser/crs”(eliFdaer.sf nruter
{ >rebmun
)swoRmun.!tesatad >= )tesatad((neht.
))”cbu” === di.tesatad >= )tesatad((dnif.stesatad >= )stesatad((neht.
))(stesataDtsil.)(edacaFthgisnI wen >= )((neht.
))snoitceS.dniKtesataDthgisnI
,tnetnoc ,”cbu”(tesataDdda.)(edacaFthgisnI wen >= )tnetnoc((neht.
))”46esab”(gnirtSot.reffub >= )reffub((neht.
st.edacaFthgisnII
yreuQmrofrep
tesataDtsil tesataDdda
tesataDevomer
yreuQmrofrep tesataDevomer tesataDtsil tesataDdda
st.edacaFthgisnII
st.edacaFthgisnII
https://sites.google.com/view/ubccpsc310-23w2/project/section-specification?authuser=0 2/28
1/29/24, 5:08 PM Introduction to SE – Section Specification
Without data, there is nothing to search through for insights! Before a user can query, they will need to add data to the system. All valid course sections should be extracted from the dataset and stored such that they can later be queried.
The following method is de ned in the interface le:
adds a dataset to the internal model, providing the id of the dataset, the string of the content of the dataset, and the kind of the dataset. Any invalid inputs should be rejected.
Each of the three arguments to addDataset are described below:
Valid ID argument to addDataset
A user can add multiple datasets to your project and they will be identi ed by the ID provided by the user. A valid
is an , de ned in the EBNF (see below). In addition, an that is only whitespace is invalid. Valid Content argument to addDataset
The parameter is the entire zip le, in the format of a base64 string. That’s the entire zip le, all the data you need is contained in it. You should use the JSZip module to unzip, navigate through, and view the les inside.
A valid dataset:
Is a structured as a base64 string of a zip le. Contains at least one valid section.
A valid course:
Is a JSON formatted le.
Contains one or more valid sections.
Within a JSON formatted le, valid sections will be found within the key.
Is located within a folder called in the zip’s root directory.
A valid section:
Contains every eld which can be used by a query (see the “Valid Query Keys” section below).
If a eld you use in a section is present in the JSON but contains something counter-intuitive like empty string, it is still valid.
An example of a valid dataset which contains 64,612 valid UBC course sections can be found here. This data has been obtained from UBC PAIR and has not been modi ed in any way. The data is provided as a zip le: inside of the zip you will nd a le for each of the courses offered at UBC. Each of those le contains a JSON object containing the information about each section of the course.
Unzip the example valid dataset to see what a valid JSON formatted le looks like. You can use an online JSON
gnirtsdi di
>][gnirts