def get_section_by_id(section_id): label = section_label_from_section_id(section_id) section = get_section_by_label(label) if section.is_independent_study: reg_id = instructor_regid_from_section_id(section_id) section.independent_study_instructor_regid = reg_id return section
def get_new_sections_by_term(changed_since_date, term, existing={}): kwargs = { 'future_terms': 0, 'transcriptable_course': 'all', 'include_secondaries': 'on', 'delete_flag': [Section.DELETE_FLAG_ACTIVE, Section.DELETE_FLAG_SUSPENDED] } sections = [] for section_ref in get_changed_sections_by_term( changed_since_date, term, **kwargs): primary_id = None course_id = '{term_id}-{curr_abbr}-{course_num}-{section_id}'.format( term_id=section_ref.term.canvas_sis_id(), curr_abbr=section_ref.curriculum_abbr.upper(), course_num=section_ref.course_number, section_id=section_ref.section_id.upper()) if course_id not in existing: try: label = section_ref.section_label() section = get_section_by_label(label) if is_time_schedule_construction(section): logger.info('Course: SKIP {}, TSC on'.format(label)) continue except DataFailureException as err: logger.info('Course: SKIP {}, {}'.format(label, err)) continue except ValueError as err: logger.info('Course: SKIP, {}'.format(err)) continue if section.is_independent_study: for instructor in section.get_instructors(): ind_course_id = '{}-{}'.format( course_id, instructor.uwregid) if ind_course_id not in existing: sections.append({'course_id': ind_course_id, 'primary_id': primary_id}) else: if not section.is_primary_section: primary_id = section.canvas_course_sis_id() sections.append({'course_id': course_id, 'primary_id': primary_id}) return sections
def test_exists_secondary_section_combined_list(self): section = get_section_by_label('2013,summer,MATH,125/G') self.assertFalse(exists_section_secondary_combined_list(section))
def test_is_tac_class_list_available(self): section = get_section_by_label('2013,autumn,T BUS,310/A') self.assertFalse(exists_section_list(section)) section = get_section_by_label('2013,spring,T BUS,310/A') self.assertTrue(exists_section_list(section))
def test_is_bot_class_list_available(self): section = get_section_by_label('2012,autumn,B BIO,180/A') self.assertFalse(exists_section_list(section)) section = get_section_by_label('2013,autumn,B BIO,180/A') self.assertTrue(exists_section_secondary_combined_list(section))
def test_section_list_names(self): section = get_section_by_label('2013,summer,MATH,125/G') self.assertEqual(get_section_list_name(section), 'math125g_su13') self.assertEqual(get_section_secondary_combined_list_name(section), 'multi_math125g_su13')
def test_tac_section_list_names(self): section = get_section_by_label('2013,autumn,T BUS,310/A') self.assertEqual(get_section_list_name(section), 'tbus310a_au13') self.assertEqual(get_section_secondary_combined_list_name(section), 'multi_tbus310a_au13')
def test_bot_section_list_names(self): section = get_section_by_label('2012,autumn,B BIO,180/A') self.assertEqual(get_section_list_name(section), 'bbio180a_au12') self.assertEqual(get_section_secondary_combined_list_name(section), 'multi_bbio180a_au12')