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
¶ CharField
– the school code corresponding to the school for the course
-
code
¶ CharField
– the course code without indication of section (E.g. EN.600.100)
-
name
¶ CharField
– the general name of the course (E.g. Calculus I)
-
description
¶ TextField
– the explanation of the content of the courzse
-
notes
¶ TextField
, optional – usually notes pertaining to registration (e.g. Lab Fees)
-
info
¶ TextField
, optional – similar to notes
-
unstopped_description
¶ TextField
– automatically generated description without stopwords
-
campus
¶ CharField
, optional – an indicator for which campus the course is taught on
-
prerequisites
¶ TextField
, optional – courses required before taking this course
-
corequisites
¶ TextField
, optional – courses required concurrently with this course
-
exclusions
¶ TextField
, optional – reasons why a student would not be able to take this
-
num_credits
¶ FloatField
– the number of credit hours this course is worth
-
areas
¶ CharField
– comma seperated list of all degree areas this course satisfies
-
department
¶ CharField
– department offering course (e.g. Computer Science)
-
level
¶ CharField
– indicator of level of course (e.g. 100, 200, Upper, Lower, Grad)
-
cores
¶ CharField
– core areas satisfied by this course
-
geneds
¶ CharField
– geneds satisfied by this course
ManyToManyField
ofCourse
, optional – courses computed similar to this course
-
same_as
¶ ForeignKey
– If this course is the same as another course, provide Foreign key
-
vector
¶ PickleObjectField
– the vector representation of a course transformed from course vectorizer
-
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.
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
toCourse
): - 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- course (
-
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
-
day
¶ CharField
– the day the course is offered (single character M,T,W,R,F,S,U)
-
time_start
¶ CharField
– the time the slot starts in 24hrs time in the format (HH:MM) or (H:MM)
-
time_end
¶ CharField
– the time it ends in 24hrs time in the format (HH:MM) or (H:MM)
-
location
¶ CharField
, optional – the location the course takes place, defaulting to TBA if not provided
-
-
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 aCourse
could have 3 other offerings (one that meets each: Tuesday, Thursday).-
meeting_section
¶ CharField
– the name of the section (e.g. 001, L01, LAB2)
-
size
¶ IntegerField
– the capacity of the course (the enrollment cap)
-
enrolment
¶ IntegerField
– the number of students registered so far
-
waitlist
¶ IntegerField
– the number of students waitlisted so far
-
waitlist_size
¶ IntegerField
– the max size of the waitlist
-
section_type
¶ CharField
– the section type, example ‘L’ is lecture, ‘T’ is tutorial, P is practical
-
instructors
¶ CharField
– comma seperated list of instructors
-
textbooks
¶ ManyToManyField
ofTextbook
– textbooks for this section via theTextbookLink
model
-
was_full
¶ BooleanField
– whether the course was full during the last parse
-
-
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
¶ CharField – the name (e.g. Spring, Fall)
-
year
¶ CharField – the year (e.g. 2017, 2018)
-
-
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
¶ BigIntegerField – the primary (unique) key ISBN number
-
detail_url
¶ URLField – url to the detail page on Amazon.com
-
image_url
¶ URLField – url to product image hosted on Amazon.com
CharField – authors first and last name
-
title
¶ CharField – the title of the book
-
-
class
timetable.models.
TextbookLink
(*args, **kwargs)[source]¶ This model serves as a ManyToMany link betwen a
Section
anda textbook. The reason for this additional model is because the edge that connects aSection
has a label which is whether that textbook is required. Thus, a seperate model/table exists to link the two with this label.abs-
is_required
¶ BooleanField
– whether or not the textbook is required
-
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.
Serializers¶
Utils¶
-
class
timetable.utils.
DisplayTimetable
(slots, has_conflict, name='', events=None, id=None)[source]¶ Object that represents the frontend’s interpretation of a timetable.
-
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.
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.