mizzoureview-reading
v2.1.2
Published
This module defines TypeScript classes for modeling professor data, including identity, metrics, and AI-generated summaries.
Downloads
6
Readme
Professor Models
This module defines TypeScript classes for modeling professor data, including identity, metrics, and AI-generated summaries.
📦 Classes Overview
BasicInfo
Represents a professor’s personal and departmental details.
Fields:
name: Name– ANameobject (imported from./name)department: string– Department name, like "School of Natural Resources"title?: string– (Optional) Title like "Part-Time Adjunct Faculty", or "Emeritus"education?: string– (Optional) Educational background, like "Doctor of Philosophy"tenure?: number– (Optional) Years of tenure.
Method:
toString()– Returns a string combining name and department, with slashes removed.
ObjectiveMetrics
Represents quantifiable metrics such as GPA and confidence level.
Fields:
gpa: number– Must be between 0 and 4.0.confidence: number– Must be between 0 and 100.
Constructor Validation: Throws an error if values are out of range.
SubjectiveMetrics
Represents student-supplied qualitative metrics, rated from 0–10.
Optional Fields:
qualitydifficultygradingIntensityattendancetextbookpolarizing
Constructor Validation: Each metric must be between 0 and 10 if provided.
AIPromptAnswers
Stores AI-generated content related to the professor.
Optional Fields:
letterToProfessor?: string– A letter directed to the professor.letterToStudent?: string– A letter directed to the student.funFacts?: string[]– Facts derived from wikipedia articles, must be an array of length 5 for each fact.
Professor
The main class encapsulating all other class data.
Fields:
professorId: stringbasicInfo?: BasicInfoobjectiveMetrics?: ObjectiveMetricssubjectiveMetrics?: SubjectiveMetricsaIPromptAnswers?: AIPromptAnswers
Methods:
static initFromObject(jsonObject: any): Professor
Creates aProfessorinstance from a raw JSON object.toString(): string
Returns a full, stringified version of the object and all nested data.
✅ Example Usage
import { Professor } from "./professor";
import { Name } from "./name";
const name = new Name("Ada", "Lovelace");
const basicInfo = new BasicInfo(name, "Computer Science", {
title: "Professor",
education: "PhD in Mathematics",
tenure: 10,
});
const objectiveMetrics = new ObjectiveMetrics(3.9, 95);
const subjectiveMetrics = new SubjectiveMetrics({
quality: 9,
difficulty: 6,
});
const aiAnswers = new AIPromptAnswers({
letterToStudent: "Keep pushing forward!"
});
const prof = new Professor("ada123", {
basicInfo,
objectiveMetrics,
subjectiveMetrics,
aIPromptAnswers: aiAnswers,
});
console.log(prof.toString());Functions
database client
getProfessorsFromName(db: Firestore, fname: string, lname: string): Promise<Professor[]>
Fetches all professors from Firestore whose first and last names match the provided values.
📥 Parameters
db(Firestore) – A Firestore instance from the Firebase Web Client SDK.fname(string) – The first name of the professor to search for.lname(string) – The last name of the professor to search for.
📤 Returns
- A
Promisethat resolves to an array ofProfessorobjects that match the given first and last name.
🧠 Notes
- Ignores middle name, so returns multiple values upon there being multiple "James Williams", for example.
🧪 Example
import { getProfessorsFromName } from "mizzoureview-reading/database-client";
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
const firebaseConfig = {
/* your config */
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const profs = await getProfessorsFromName(db, "John", "Doe");
console.log(profs);getProfessorsFromDepartment(db: Firestore, department: string): Promise<Professor[]>
Fetches all professors from Firestore who belong to a specific department.
📥 Parameters
db(Firestore) – A Firestore instance from the Firebase Web Client SDK.department(string) – The name of the department to filter professors by.
📤 Returns
- A
Promisethat resolves to an array ofProfessorobjects that match the department.
🧠 Notes
- See this page to see some examples of what "department" means
🧪 Example
import { getProfessorsFromDepartment } from "mizzoureview-reading/database-client";
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
const firebaseConfig = {
/* your config */
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const profs = await getProfessorsFromDepartment(db, "Computer Science");
console.log(profs);getProfessorFromID(db: Firestore, professorId: string): Promise<Professor | null>
Fetches a single professor from Firestore by their unique professorId.
📥 Parameters
db(Firestore) – A Firestore instance from the Firebase Web Client SDK.professorId(string) – The document ID of the professor to retrieve.
📤 Returns
- A
Promisethat resolves to aProfessorobject if found and valid, ornullotherwise.
🧠 Notes
- Returns
nullif the document is missing, malformed, or incomplete.
🧪 Example
import { getProfessorFromID } from "mizzoureview-reading/database-client";
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
const firebaseConfig = {
/* your config */
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const prof = await getProfessorFromID(db, "abc123");
console.log(prof);getSomeProfessors(db: Firestore, count: number): Promise<Professor[]>
Retrieves a limited number of professors from the professors collection in Firestore using the Firebase Web Client SDK.
📥 Parameters
db(Firestore) – A Firestore instance imported fromfirebase/firestore.count(number) – The maximum number of professor documents to retrieve.
📤 Returns
- A
Promisethat resolves to an array ofProfessorobjects, up to the specifiedcount.
🧠 Notes
- Best for use in testing database connection or getting a small amount of data to practice rendering stuff or something
🧪 Example
import { getSomeProfessors } from "mizzoureview-reading/database-client";
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
const firebaseConfig = {
/* your config */
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const profs = await getSomeProfessors(db, 5);
console.log(profs);getAllProfessors(db: Firestore): Promise<Professor[]>
Retrieves all professors from the professors collection in your Firestore database using the Firebase Web Client SDK.
📥 Parameters
db(Firestore) – A Firestore instance imported fromfirebase/firestore.
📤 Returns
- A
Promisethat resolves to an array ofProfessorobjects. Only professors with validbasicInfoand a definedprofessorIdare returned.
🧠 Notes
- Internally calls
Professor.initFromObject(doc.data())to construct eachProfessor. - Skips documents that are missing required fields (
professorIdorbasicInfo).
🧪 Example
import { getAllProfessors } from "mizzoureview-reading/database-client";
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
const firebaseConfig = {
/* your config */
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const profs = await getAllProfessors(db);
console.log(profs);