Ejemplo n.º 1
0
 def enroll_student(
     self, section: SectionIdentity, student_number: str
 ) -> Result[str, str]:
     c = self.connection.cursor()
     term = (student_number, section.to_string())
     c.execute(
         "INSERT INTO enrollment(student_number, section_id) VALUES (%s, %s)", term
     )
     self.connection.commit()
     return Ok(student_number)
Ejemplo n.º 2
0
 def resolve_section(self, info, course, year, semester, section_code):
     return (
         course_api(info)
         .get_section(
             SectionIdentity(
                 course.to_domain(), year, DomainSemester(semester), section_code
             )
         )
         .map_or(Section.from_domain, None)
     )
Ejemplo n.º 3
0
 def get_officehour_for_section_by_day(
     self, section_identity: SectionIdentity, day: Weekday, mp: MeetingPersistence
 ) -> List[OfficeHour]:
     c = self.connection.cursor()
     officehours = []
     c.execute(
         "SELECT * FROM officehours WHERE day_of_week=%s AND section_id=%s",
         (day.value, section_identity.to_string()),
     )
     results = c.fetchall()
     if len(results) > 0:
         officehours = list(
             filter(
                 None,
                 (
                     self._res_to_officehour(res, mp).unwrap_or(None)
                     for res in results
                 ),
             )
         )
     return officehours
Ejemplo n.º 4
0
 def identity(self):
     return SectionIdentity(self.course.to_domain(), self.year,
                            self.semester, self.section_code)
Ejemplo n.º 5
0
 def to_section_identity(id):
     params = id.split(";delimiter;")
     return SectionIdentity(
         Course(params[0]), int(params[1]), Semester(int(params[2])), params[3]
     )