Overview
Classes in ESP are represented by two primary models:- ClassSubject: The class itself with title, description, and teachers
- ClassSection: A specific meeting time/instance of a class
esp/esp/program/models/class_.py
ClassSubject Model
Represents a class/course offered in a program.Core Fields
Program this class belongs to
- Links to:
Program - Required field
Category/subject area of the class
- Links to:
ClassCategories - Examples: Math, Science, Arts, etc.
Name/title of the class
- Max length: 200 characters
Detailed description of the class content
- Rich text field for class information
- Shown to students in catalog
Approval status of the class
- Choices: CANCELLED (-20), REJECTED (-10), UNREVIEWED (0), HIDDEN (5), ACCEPTED (10)
- Default: UNREVIEWED (0)
Size and Capacity
Minimum number of students needed for class to run
Maximum number of students allowed in class
Ideal class size as specified by teacher
Acceptable size ranges for this class
- Links to:
ClassSizeRange
Teacher Fields
Teachers/instructors for this class
- Links to:
ESPUser - Can have multiple co-teachers
Whether students can join after class starts
- Default: False
- If True, allows 20-minute grace period
Content Fields
Prerequisites for taking this class
- Text description of required background
Minimum grade level for students
Maximum grade level for students
Difficulty level indicator
ClassSection Model
Represents a specific offering/time slot of a class. Source:esp/esp/program/models/class_.py:293
Core Fields
The ClassSubject this section belongs to
- Links to:
ClassSubject - Related name:
sections
Section-specific status
- Choices: Same as ClassSubject
- Default: UNREVIEWED (0)
Whether registration is open for this section
- Choices: OPEN (0), CLOSED (10)
- Default: OPEN (0)
Length of section in hours
- Max digits: 5
- Decimal places: 2
- Example: 1.5 for 90 minutes
Time blocks when this section meets
- Links to:
Event - Can span multiple time blocks
Override capacity for this specific section
- If not set, uses parent class capacity
Non-teacher moderators for this section
- Links to:
ESPUser - Separate from main teachers
Students registered for this section
- Links to:
ESPUser - Through model:
StudentRegistration
ClassSection Methods
Scheduling Methods
Returns the first meeting time for this sectionReturns: Event object or None if not scheduledExample:
Returns the last meeting time for this sectionReturns: Event object with latest end time, or None
Checks if section has assigned meeting timesReturns: True if meeting_times exist
assign_start_time(first_event)
Schedules the class starting at given eventParameters:
first_event(Event): Starting time block
- Automatically extends to cover class duration
- Clears existing rooms
- Attempts to reassign same rooms if available
assign_meeting_times(event_list)
Manually set all meeting times for sectionParameters:
event_list(list): List of Event objects
- Clears existing meeting times
- Adds all events in list
Room Assignment
Returns assigned classroom resourcesReturns: QuerySet of Resource objects with res_type=“Classroom”Example:
Assign a classroom to this sectionParameters:
base_room(Resource): Classroom resource to assignclear_others(bool): Remove other room assignments firstallow_partial(bool): Allow partial time block coveragelock(int): Lock level for scheduling (0=unlocked)
clearRooms()
Removes all classroom assignments from this section
Returns list of room namesReturns: List of strings (room names) or empty list if unscheduled
Student Management
Returns students with specified relationship to sectionParameters:
verbs(list): Registration types (e.g., [‘Enrolled’, ‘Interested’])
Count of students in sectionParameters:
verbs(list): Registration types to count
Returns students currently checked in to this sectionReturns: QuerySet of ESPUser objects
Checks if section is at capacityReturns: True if num_students >= capacity
Checks if user can register for this sectionParameters:
user(ESPUser): User attempting to registercheckFull(bool): Check capacity limits
Cancellation
cancel(email_students=True, email_teachers=True, explanation=None, unschedule=False)
Cancels the section and optionally notifies participantsParameters:
email_students(bool): Send cancellation email to studentsemail_teachers(bool): Send email to teachersexplanation(str): Reason for cancellationunschedule(bool): Remove time and room assignments
- Sets status to CANCELLED
- Clears student registrations
- Sends notification emails
- Optionally removes scheduling
Properties
Effective capacity of the sectionCalculation:
- Uses max_class_capacity if set
- Otherwise uses min of: class_size_max, room capacity
- Applies program-specific multipliers if configured
Unique identifier for this sectionFormat:
{parent_class_emailcode}s{section_index}Example: “E1234s1” for first section of class E1234Returns parent class title
Section number within parent classReturns: 1-indexed position (first section = 1)
Usage Examples
Creating a Class with Sections
Scheduling a Section
Checking Registration Eligibility
Getting Class Information
Related Models
- Program - Parent program containing classes
- User - Teachers and students
- Registration - Student enrollments
- Resources - Classrooms and equipment