Course

Struct Course 

Source
pub struct Course {
    pub csv_id: Option<String>,
    pub id: Option<String>,
    pub name: String,
    pub prefix: String,
    pub number: String,
    pub prerequisites: Vec<String>,
    pub corequisites: Vec<String>,
    pub strict_corequisites: Vec<String>,
    pub credit_hours: f32,
    pub canonical_name: Option<String>,
}
Expand description

Represents a course in a curriculum

§Note on Complex Prerequisites

Currently, prerequisites are stored as a flat list with implicit AND semantics. However, real curricula often have complex boolean expressions like:

  • “CS101 OR CS102”
  • “(CS101 AND MATH156) OR CS200”
  • “CS101 OR (CS102 AND MATH156)”

Several approaches to handle complex prerequisites:

  1. Disjunctive Normal Form (DNF): Store as Vec<Vec<String>> where outer Vec is OR, inner Vec is AND. Example: [[\"CS101\"], [\"CS102\", \"MATH156\"]] means CS101 OR (CS102 AND MATH156). This is a standard form in logic.

  2. Prerequisite Expression Trees: Use a recursive enum:

    enum PrereqExpr {
        Course(String),
        And(Vec<PrereqExpr>),
        Or(Vec<PrereqExpr>),
    }

    This can represent any boolean expression and is most flexible.

  3. Virtual Courses: Create synthetic course keys like \"CS101_OR_CS102\" or \"CS101_AND_MATH156\" in the DAG. Each virtual course represents a requirement that can be satisfied by its components.

  4. Hypergraph Representation: Extend DAG to support hyperedges where a single edge can connect to multiple prerequisite sets with boolean operators.

  5. Choice Resolution at Plan Build Time (Recommended for Plan Analysis): The Course struct stores the full prerequisite expression (using one of the above approaches), but when building a DAG from a Plan, the plan specifies which alternative was chosen. This keeps plan DAGs simple while preserving the full requirement information in courses. Plans represent actual student selections where boolean logic has been resolved.

Note: Regardless of approach, the Course struct must be able to represent the full prerequisite expression. The choice resolution approach means that when analyzing a specific plan, we only include the paths the student actually took, not all possibilities.

Fields§

§csv_id: Option<String>

Original course ID from the curriculum file

§id: Option<String>

Unique course identifier (optional, used for deduplication when multiple courses have same key)

§name: String

Course name (e.g., “Calculus for Physical Scientists I”)

§prefix: String

Course prefix (e.g., “MATH”, “CS”)

§number: String

Course number (e.g., “1342”, “2510”)

§prerequisites: Vec<String>

Prerequisites - stored as “PREFIX NUMBER” keys (e.g., “MATH 1341”) Currently assumes ALL prerequisites must be satisfied (AND semantics)

§corequisites: Vec<String>

Co-requisites - stored as “PREFIX NUMBER” keys

§strict_corequisites: Vec<String>

Strict co-requisites - stored as “PREFIX NUMBER” keys (must be taken together)

§credit_hours: f32

Credit hours (can be fractional)

§canonical_name: Option<String>

Canonical name for cross-institution lookup (e.g., “Calculus I”)

Implementations§

Source§

impl Course

Source

pub const fn new( name: String, prefix: String, number: String, credit_hours: f32, ) -> Self

Create a new course

§Arguments
  • name - Full course name
  • prefix - Course prefix
  • number - Course number
  • credit_hours - Credit hours (can be fractional)
Source

pub fn key(&self) -> String

Get the course key for lookups (prefix + number)

§Returns

A string in the format “PREFIXNUMBER” (e.g., “CS2510”)

Source

pub fn add_prerequisite(&mut self, prereq_key: String)

Add a prerequisite by course key

Source

pub fn add_corequisite(&mut self, coreq_key: String)

Add a co-requisite by course key

Source

pub fn add_strict_corequisite(&mut self, coreq_key: String)

Add a strict co-requisite by course key

Source

pub fn set_canonical_name(&mut self, name: String)

Set the canonical name

Trait Implementations§

Source§

impl Clone for Course

Source§

fn clone(&self) -> Course

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Course

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Course

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Course

Source§

fn eq(&self, other: &Course) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Course

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Course

Auto Trait Implementations§

§

impl Freeze for Course

§

impl RefUnwindSafe for Course

§

impl Send for Course

§

impl Sync for Course

§

impl Unpin for Course

§

impl UnwindSafe for Course

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,