コード例 #1
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)
     )
コード例 #2
0
 def resolve_sections(
     self,
     info,
     taught_by: str = None,
     enrolled_in: str = None,
     course_code: str = None,
 ):
     return [
         Section.from_domain(section) for section in course_api(
             info).query_sections(taught_by=taught_by,
                                  enrolled_in=enrolled_in,
                                  course_code=course_code)
     ]
コード例 #3
0
    def mutate(self, info, section_input):
        num_students = section_input.num_students or 0
        taught_by = section_input.taught_by
        instructor = (instructor_api(info).get_instructor(taught_by).expect(
            f"Instructor with username {taught_by} does not exist.")
                      if taught_by else info.context.user)

        return (course_api(info).create_section(
            section_input.course.to_domain(),
            section_input.year,
            DomainSemester(section_input.semester),
            section_input.section_code,
            instructor,
            num_students,
        ).map(Section.from_domain).unwrap())
コード例 #4
0
 def resolve_sections(self, info, filters=None):
     return [
         Section.from_domain(section)
         for section in course_api(info).query_sections(filters)
     ]
コード例 #5
0
 def resolve_courses(self, info, filters=None):
     return [
         Course.from_domain(course)
         for course in course_api(info).query_courses(filters)
     ]
コード例 #6
0
 def resolve_course(self, info, course_code):
     return course_api(info).get_course(course_code).map_or(Course.from_domain, None)
コード例 #7
0
 def mutate(self, info, office_hour_id):
     return (course_api(info).delete_officehour(office_hour_id).map(
         DeleteOfficeHour).unwrap())
コード例 #8
0
 def mutate(self, info, section_input, starting_hour, weekday):
     section = course_api(info).get_section(
         section_input.to_identity()).unwrap()
     return (course_api(info).create_officehour(
         section, starting_hour,
         DomainWeekday(weekday)).map(OfficeHour.from_domain).unwrap())
コード例 #9
0
 def mutate(self, info, section_input, student_numbers):
     return EnrollStudents(
         course_api(info).enroll_students(section_input.to_identity(),
                                          student_numbers))
コード例 #10
0
 def mutate(self, info, course_input):
     return (course_api(info).create_course(course_input.course_code).map(
         Course.from_domain).unwrap())
コード例 #11
0
 def resolve_enrolled_in(self, info):
     return [
         Section.from_domain(section) for section in course_api(
             info).get_sections_of_student(info.context.user.student_number)
     ]
コード例 #12
0
 def resolve_officehours(self, info, section_input, weekday):
     return [
         OfficeHour.from_domain(officehour) for officehour in course_api(
             info).get_officehours_for_section_on_weekday(
                 section_input.to_identity(), DomainWeekday(weekday))
     ]
コード例 #13
0
 def resolve_officehour(self, info, office_hour_id):
     return course_api(info).get_officehour(office_hour_id).unwrap_or(None)
コード例 #14
0
 def mutate(self, info, course_input):
     return course_api(info).create_course(
         course_input.course_code).unwrap()