def app_config(): current_term_name = app.config['CANVAS_CURRENT_ENROLLMENT_TERM'] current_term_id = sis_term_id_for_name(current_term_name) return tolerant_jsonify({ 'boacEnv': app.config['BOAC_ENV'], 'currentEnrollmentTerm': current_term_name, 'currentEnrollmentTermId': int(current_term_id), 'disableMatrixViewThreshold': app.config['DISABLE_MATRIX_VIEW_THRESHOLD'], 'devAuthEnabled': app.config['DEVELOPER_AUTH_ENABLED'], 'ebEnvironment': app.config['EB_ENVIRONMENT'] if 'EB_ENVIRONMENT' in app.config else None, 'featureFlagAdvisorAppointments': app.config['FEATURE_FLAG_ADVISOR_APPOINTMENTS'], 'googleAnalyticsId': app.config['GOOGLE_ANALYTICS_ID'], 'isDemoModeAvailable': app.config['DEMO_MODE_AVAILABLE'], 'maxAttachmentsPerNote': app.config['NOTES_ATTACHMENTS_MAX_PER_NOTE'], 'pingFrequency': app.config['PING_FREQUENCY'], 'supportEmailAddress': app.config['BOAC_SUPPORT_EMAIL'], 'timezone': app.config['TIMEZONE'], })
def load_current_term(): from boac.lib import berkeley from boac.models.team_member import TeamMember success_count = 0 failures = [] term_name = app.config['CANVAS_CURRENT_ENROLLMENT_TERM'] sis_term_id = berkeley.sis_term_id_for_name(term_name) # Currently, all external data is loaded starting from the individuals who belong # to one or more Cohorts. for csid, uid in db.session.query(TeamMember.member_csid, TeamMember.member_uid).distinct(): s, f = load_canvas_externals(uid) success_count += s failures += f db.session.commit() s, f = load_sis_externals(sis_term_id, csid) success_count += s failures += f db.session.commit() print('Complete. Fetched {} external feeds.'.format(success_count)) if len(failures): print('Failed to fetch {} feeds:'.format(len(failures))) print(failures)
def user_analytics(uid): canvas_profile = canvas.get_user_for_uid(uid) if canvas_profile is False: raise errors.ResourceNotFoundError('No Canvas profile found for user') elif not canvas_profile: raise errors.InternalServerError('Unable to reach bCourses') canvas_id = canvas_profile['id'] user_courses = canvas.get_student_courses_in_term(uid) courses_api_feed = api_util.canvas_courses_api_feed(user_courses) cohort_data = TeamMember.query.filter_by(member_uid=uid).first() if cohort_data and len(user_courses): term_id = sis_term_id_for_name(user_courses[0].get('term', {}).get('name')) merge_sis_enrollments(courses_api_feed, cohort_data.member_csid, term_id) merge_analytics_for_user(courses_api_feed, canvas_id) if cohort_data: sis_profile = merge_sis_profile(cohort_data.member_csid) cohort_data = cohort_data.to_api_json() else: sis_profile = False return tolerant_jsonify({ 'uid': uid, 'canvasProfile': canvas_profile, 'cohortData': cohort_data, 'courses': courses_api_feed, 'sisProfile': sis_profile, })
def all_term_ids(): """Return SIS IDs of each term covered by BOAC, from current to oldest.""" earliest_term_id = sis_term_id_for_name(app.config['CANVAS_EARLIEST_TERM']) term_id = current_term_id() ids = [] while int(term_id) >= int(earliest_term_id): ids.append(term_id) term_id = previous_term_id(term_id) return ids
def app_config(): current_term_name = app.config['CANVAS_CURRENT_ENROLLMENT_TERM'] current_term_id = sis_term_id_for_name(current_term_name) return tolerant_jsonify({ 'boacEnv': app.config['BOAC_ENV'], 'currentEnrollmentTerm': current_term_name, 'currentEnrollmentTermId': int(current_term_id), 'disableMatrixViewThreshold': app.config['DISABLE_MATRIX_VIEW_THRESHOLD'], 'demoMode': app.config['DEMO_MODE'], 'devAuthEnabled': app.config['DEVELOPER_AUTH_ENABLED'], 'ebEnvironment': app.config['EB_ENVIRONMENT'] if 'EB_ENVIRONMENT' in app.config else None, 'supportEmailAddress': app.config['BOAC_SUPPORT_EMAIL'], 'googleAnalyticsId': app.config['GOOGLE_ANALYTICS_ID'], })
def earliest_term_id(): return sis_term_id_for_name(app.config['LEGACY_EARLIEST_TERM'])
def test_missing_term_name(self): """Returns None for missing term names.""" assert berkeley.sis_term_id_for_name(None) is None
def test_unparseable_term_name(self): """Returns None for unparseable term names.""" assert berkeley.sis_term_id_for_name('Winter 2061') is None assert berkeley.sis_term_id_for_name('Default Term') is None
def test_sis_term_id_for_name(self): """Handles well-formed term names.""" assert berkeley.sis_term_id_for_name('Spring 2015') == '2152' assert berkeley.sis_term_id_for_name('Summer 2016') == '2165' assert berkeley.sis_term_id_for_name('Fall 2017') == '2178' assert berkeley.sis_term_id_for_name('Fall 1997') == '1978'
def future_term_id(): term_name = app.config['CANVAS_FUTURE_ENROLLMENT_TERM'] if term_name == 'auto': index = get_current_term_index() return index and sis_term_id_for_name(index['future_term_name']) return sis_term_id_for_name(term_name)
def current_term_id(use_cache=True): return sis_term_id_for_name(current_term_name(use_cache))
def get_filter_option_groups(self): current_year = datetime.now().year owner_user_id = AuthorizedUser.get_id_per_uid( self.owner_uid) if self.owner_uid else None return { 'Academic': [ _filter( 'academicStandings', 'Academic Standing', options=academic_standing_options( min_term_id=sis_term_id_for_name( f'Fall {current_year - 5}')), ), _filter('colleges', 'College', options=colleges), _filter('enteringTerms', 'Entering Term', options=entering_terms), _filter('epnCpnGradingTerms', 'EPN/CPN Grading Option', options=grading_terms), _filter('expectedGradTerms', 'Expected Graduation Term', options=grad_terms), _range_filter('gpaRanges', 'GPA (Cumulative)', labels_range=['', '-'], validation='gpa'), _range_filter('lastTermGpaRanges', 'GPA (Last Term)', labels_range=['', '-'], validation='gpa'), _boolean_filter('studentHolds', 'Holds'), _filter('intendedMajors', 'Intended Major', options=intended_majors), _filter('levels', 'Level', options=level_options), _filter('majors', 'Major', options=majors), _filter('minors', 'Minor', options=minors), _boolean_filter('midpointDeficient', 'Midpoint Deficient Grade'), _boolean_filter('transfer', 'Transfer Student'), _filter('unitRanges', 'Units Completed', options=unit_range_options), ], 'Demographics': [ _filter('ethnicities', 'Ethnicity', options=ethnicities), _filter('genders', 'Gender', options=genders), _range_filter( 'lastNameRanges', 'Last Name', labels_range=['Initials', 'through'], label_min_equals_max='Starts with', validation='char[2]', ), _boolean_filter('underrepresented', 'Underrepresented Minority'), _filter('visaTypes', 'Visa Type', options=visa_types), ], 'Departmental (ASC)': [ _boolean_filter_asc( 'isInactiveAsc', 'Inactive (ASC)', default_value=False if 'UWASC' in self.scope else None, ), _boolean_filter('inIntensiveCohort', 'Intensive (ASC)', available_to=['UWASC']), _filter('groupCodes', 'Team (ASC)', options=team_groups, available_to=['UWASC']), ], 'Departmental (COE)': [ _filter('coeAdvisorLdapUids', 'Advisor (COE)', options=get_coe_profiles, available_to=['COENG']), _filter('coeEthnicities', 'Ethnicity (COE)', options=coe_ethnicities, available_to=['COENG']), _filter('coeGenders', 'Gender (COE)', options=coe_gender_options, available_to=['COENG']), _filter('coePrepStatuses', 'PREP (COE)', options=coe_prep_status_options, available_to=['COENG']), _boolean_filter_coe('coeProbation', 'Probation (COE)'), _boolean_filter_coe( 'isInactiveCoe', 'Inactive (COE)', default_value=False if 'COENG' in self.scope else None), _boolean_filter_coe('coeUnderrepresented', 'Underrepresented Minority (COE)'), ], 'Advising': [ _filter('curatedGroupIds', 'My Curated Groups', options=lambda: curated_groups(owner_user_id) if owner_user_id else None), _filter( 'cohortOwnerAcademicPlans', 'My Students', options=lambda: academic_plans_for_cohort_owner( self.owner_uid) if self.owner_uid else None, ), _filter( 'freshmanOrTransfer', 'Freshman or Transfer', options=student_admit_freshman_or_transfer_options, available_to=['ZCEEE'], domain_='admitted_students', ), _boolean_filter_ce3('sir', 'Current SIR'), _filter( 'admitColleges', 'College', available_to=['ZCEEE'], domain_='admitted_students', options=student_admit_college_options, ), _filter( 'xEthnicities', 'XEthnic', available_to=['ZCEEE'], domain_='admitted_students', options=student_admit_ethnicity_options, ), _boolean_filter_ce3('isHispanic', 'Hispanic'), _boolean_filter_ce3('isUrem', 'UREM'), _boolean_filter_ce3('isFirstGenerationCollege', 'First Generation College'), _boolean_filter_ce3('hasFeeWaiver', 'Application Fee Waiver'), _filter( 'residencyCategories', 'Residency', available_to=['ZCEEE'], domain_='admitted_students', options=student_admit_residency_category_options, ), _boolean_filter_ce3('inFosterCare', 'Foster Care'), _boolean_filter_ce3('isFamilySingleParent', 'Family Is Single Parent'), _boolean_filter_ce3('isStudentSingleParent', 'Student Is Single Parent'), _range_filter( 'familyDependentRanges', 'Family Dependents', labels_range=['', '-'], label_min_equals_max='Exactly', available_to=['ZCEEE'], domain_='admitted_students', validation='dependents', ), _range_filter( 'studentDependentRanges', 'Student Dependents', labels_range=['', '-'], label_min_equals_max='Exactly', available_to=['ZCEEE'], domain_='admitted_students', validation='dependents', ), _boolean_filter_ce3('isReentry', 'Re-entry Status'), _boolean_filter_ce3('isLastSchoolLCFF', 'Last School LCFF+'), _filter( 'specialProgramCep', 'Special Program CEP', available_to=['ZCEEE'], domain_='admitted_students', options=student_admit_special_program_cep_options, ), ], }