Timetable App

The timetable app is the core application that has been a part of Semester.ly since our very first release. The timetable app does the heavy lifting for timetable generation, sharing, and viewing.

Models

class timetable.models.Course(*args, **kwargs)[source]

Represents a course at a school, made unique by its course code. Courses persist across semesters and years. Their presence in a semester or year is indicated by the existence of sections assigned to that course for that semester or year. This is why a course does not have fields like professor, those varies.

The course model maintains only attributes which tend not to vary across semesters or years.

A course has many Section which a student can enroll in.

school

the school code corresponding to the school for the course

Type

CharField

code

the course code without indication of section (E.g. EN.600.100)

Type

CharField

name

the general name of the course (E.g. Calculus I)

Type

CharField

description

the explanation of the content of the courzse

Type

TextField

notes

usually notes pertaining to registration (e.g. Lab Fees)

Type

TextField, optional

info

similar to notes

Type

TextField, optional

unstopped_description

automatically generated description without stopwords

Type

TextField

campus

an indicator for which campus the course is taught on

Type

CharField, optional

prerequisites

courses required before taking this course

Type

TextField, optional

corequisites

courses required concurrently with this course

Type

TextField, optional

exclusions

reasons why a student would not be able to take this

Type

TextField, optional

num_credits

the number of credit hours this course is worth

Type

FloatField

areas

comma seperated list of all degree areas this course satisfies

Type

CharField

department

department offering course (e.g. Computer Science)

Type

CharField

level

indicator of level of course (e.g. 100, 200, Upper, Lower, Grad)

Type

CharField

cores

core areas satisfied by this course

Type

CharField

geneds

geneds satisfied by this course

Type

CharField

related_courses

courses computed similar to this course

Type

ManyToManyField of Course, optional

same_as

If this course is the same as another course, provide Foreign key

Type

ForeignKey

vector

the vector representation of a course transformed from course vectorizer

Type

PickleObjectField

exception DoesNotExist
exception MultipleObjectsReturned
get_avg_rating()[source]

Calculates the avg rating for a course, -1 if no ratings. Includes all courses that are marked as the same by the self.same_as field on the model nstance.

Returns

the average course rating

Return type

(float)

get_reactions(student=None)[source]

Return a list of dicts for each type of reaction (by title) for this course. Each dict has:

title: the title of the reaction

count: number of reactions with this title that this course has received

reacted: True if the student provided has given a reaction with this title

class timetable.models.CourseIntegration(id, course, integration, json)[source]
exception DoesNotExist
exception MultipleObjectsReturned
class timetable.models.Evaluation(*args, **kwargs)[source]

A review of a course represented as a score out of 5, a summary/comment, along with the professor and year the review is in subject of.

course (ForeignKey to Course):

the course this evaluation belongs to

score (FloatField): score out of 5.0 summary (TextField): text with information about why the rating was given professor (CharField): the professor(s) this review pertains to year (CharField): the year of the review course_code (Charfield): a string of the course code, along with section indicator

exception DoesNotExist
exception MultipleObjectsReturned
class timetable.models.Integration(id, name)[source]
exception DoesNotExist
exception MultipleObjectsReturned
class timetable.models.Offering(*args, **kwargs)[source]

An Offering is the most granular part of the Course heirarchy. An offering may be looked at as the backend equivalent of a single slot on a timetable. For each day/time which a section meets, an offering is created.abs

section

the section which is the parent of this offering

Type

ForeignKey to Section

day

the day the course is offered (single character M,T,W,R,F,S,U)

Type

CharField

time_start

the time the slot starts in 24hrs time in the format (HH:MM) or (H:MM)

Type

CharField

time_end

the time it ends in 24hrs time in the format (HH:MM) or (H:MM)

Type

CharField

location

the location the course takes place, defaulting to TBA if not provided

Type

CharField, optional

exception DoesNotExist
exception MultipleObjectsReturned
class timetable.models.Section(*args, **kwargs)[source]

Represents one (of possibly many) choice(s) for a student to enroll in a Course for a specific semester. Since this model is specific to a semester, it contains enrollment data, instructor information, textbooks, etc.

A section can come in different forms. For example, a lecture which is required for every student. However, it can also be a tutorial or practical. During timetable generation we allow a user to select one of each, and we can automatically choose the best combonation for a user as well.

A section has many offerings related to it. For example, section 1 of a Course could have 3 offerings (one that meets each day: Monday, Wednesday, Friday). Section 2 of a Course could have 3 other offerings (one that meets each: Tuesday, Thursday).

course

The course this section belongs to

Type

Course

meeting_section

the name of the section (e.g. 001, L01, LAB2)

Type

CharField

size

the capacity of the course (the enrollment cap)

Type

IntegerField

enrolment

the number of students registered so far

Type

IntegerField

waitlist

the number of students waitlisted so far

Type

IntegerField

waitlist_size

the max size of the waitlist

Type

IntegerField

section_type

the section type, example ‘L’ is lecture, ‘T’ is tutorial, P is practical

Type

CharField

instructors

comma seperated list of instructors

Type

CharField

semester

the semester for the section

Type

ForeignKey to Semester

textbooks

textbooks for this section via the TextbookLink model

Type

ManyToManyField of Textbook

was_full

whether the course was full during the last parse

Type

BooleanField

exception DoesNotExist
exception MultipleObjectsReturned
get_textbooks()[source]

Returns the textbook info using tb.get_info() for each textbook

class timetable.models.Semester(*args, **kwargs)[source]

Represents a semester which is composed of a name (e.g. Spring, Fall) and a year (e.g. 2017).

name

the name (e.g. Spring, Fall)

Type

CharField

year

the year (e.g. 2017, 2018)

Type

CharField

exception DoesNotExist
exception MultipleObjectsReturned
class timetable.models.Textbook(*args, **kwargs)[source]

A textbook which is associated with sections of courses. Stores information from the Amazon product API including a detail url and ISBN.

isbn

the primary (unique) key ISBN number

Type

BigIntegerField

detail_url

url to the detail page on Amazon.com

Type

URLField

image_url

url to product image hosted on Amazon.com

Type

URLField

author

authors first and last name

Type

CharField

title

the title of the book

Type

CharField

exception DoesNotExist
exception MultipleObjectsReturned

This model serves as a ManyToMany link betwen a Section anda textbook. The reason for this additional model is because the edge that connects a Section has a label which is whether that textbook is required. Thus, a seperate model/table exists to link the two with this label.abs

textbook

the textbook

Type

ForeignKey to Textbook

is_required

whether or not the textbook is required

Type

BooleanField

section

the section the textbook is linked to

Type

Section

exception DoesNotExist
exception MultipleObjectsReturned

Views

class timetable.views.TimetableLinkView(**kwargs)[source]

A subclass of FeatureFlowView (see Flows Documentation) for the viewing of shared timetable links. Provides the logic for preloading the shared timetable into initData when a user hits the corresponding url. The frontend can then act on this data to load the shared timetable for viewing.

Additionally, on POST provides the functionality for the creation of shared timetables.

get_feature_flow(request, slug)[source]

Overrides FeatureFlowView get_feature_flow method. Takes the slug, decrypts the hashed database id, and either retrieves the corresponding timetable or hits a 404.

post(request)[source]

Creates a SharedTimetable and returns the hashed database id as the slug for the url which students then share and access.

class timetable.views.TimetableView(**kwargs)[source]

This view is responsible for responding to any requests dealing with the generation of timetables and the satisfaction of constraits provided by the frontend/user.

post(request)[source]

Generate best timetables given the user’s selected courses

Serializers

class timetable.serializers.DisplayTimetableSerializer(*args, **kwargs)[source]
class timetable.serializers.EventSerializer(*args, **kwargs)[source]
class timetable.serializers.SlotSerializer(*args, **kwargs)[source]

Utils

class timetable.utils.DisplayTimetable(slots, has_conflict, name='', events=None, id=None)[source]

Object that represents the frontend’s interpretation of a timetable.

classmethod from_model(timetable)[source]

Create DisplayTimetable from Timetable instance.

class timetable.utils.Slot(course, section, offerings, is_optional, is_locked)
course

Alias for field number 0

is_locked

Alias for field number 4

is_optional

Alias for field number 3

offerings

Alias for field number 2

section

Alias for field number 1

class timetable.utils.Timetable(courses, sections, has_conflict)
courses

Alias for field number 0

has_conflict

Alias for field number 2

sections

Alias for field number 1

timetable.utils.add_meeting_and_check_conflict(day_to_usage, new_meeting, school)[source]

Takes a @day_to_usage dictionary and a @new_meeting section and returns a tuple of the updated day_to_usage dict and a boolean which is True if conflict, False otherwise.

timetable.utils.can_potentially_conflict(course_1_date_start, course_1_date_end, course_2_date_start, course_2_date_end)[source]

Checks two courses start & end dates to see whether they can overlap and hence potentially conflict. If any of the values are passed as None it will automatically consider that they can potentially conflict. Input type is string but has to be in a reasonable date format.

Parameters
  • {[string]} -- [course 1 start date in a reasonable date format] (course_1_date_start) –

  • {[string]} -- [course 1 end date in a reasonable date format] (course_1_date_end) –

  • {[string]} -- [course 2 start date in a reasonable date format] (course_2_date_start) –

  • {[string]} -- [course 2 end date in a reasonable date format] (course_2_date_end) –

Returns

[bool] – [True if if dates ranges of course 1 and 2 overlap, otherwise False]

timetable.utils.courses_to_slots(courses, locked_sections, semester, optional_course_ids)[source]

Return a list of lists of Slots. Each Slot sublist represents the list of possibilities for a given course and section type, i.e. a valid timetable consists of any one slot from each sublist.

timetable.utils.find_slots_to_fill(start, end, school)[source]

Take a @start and @end time in the format found in the coursefinder (e.g. 9:00, 16:30), and return the indices of the slots in thet array which represents times from 8:00am to 10pm that would be filled by the given @start and @end. For example, for uoft input: ‘10:30’, ‘13:00’ output: [5, 6, 7, 8, 9]

timetable.utils.get_current_semesters(school)[source]

List of semesters ordered by academic temporality.

For a given school, get the possible semesters ordered by the most recent year for each semester that has course data, and return a list of (semester name, year) pairs.

timetable.utils.get_day_to_usage(custom_events, school)[source]

Initialize day_to_usage dictionary, which has custom events blocked out.

timetable.utils.get_hour_from_string_time(time_string)[source]

Get hour as an int from time as a string.

timetable.utils.get_hours_minutes(time_string)[source]

Return tuple of two integers representing the hour and the time given a string representation of time. e.g. ‘14:20’ -> (14, 20)

timetable.utils.get_minute_from_string_time(time_string)[source]

Get minute as an int from time as a string.

timetable.utils.get_time_index(hours, minutes, school)[source]

Take number of hours and minutes, and return the corresponding time slot index

timetable.utils.get_xproduct_indicies(lists)[source]

Takes a list of lists and returns two lists of indicies needed to iterate through the cross product of the input.

timetable.utils.slots_to_timetables(slots, school, custom_events, with_conflicts)[source]

Generate timetables in a depth-first manner based on a list of slots.

timetable.utils.update_locked_sections(locked_sections, cid, locked_section, semester)[source]

Take cid of new course, and locked section for that course and toggle its locked status (ie if was locked, unlock and vice versa.