fix up gott xref

This commit is contained in:
phowell 2024-08-29 10:00:40 -07:00
parent d4bebd05a4
commit cb6d9b1d5d
3 changed files with 35 additions and 20 deletions

View File

@ -284,7 +284,7 @@ ORDER BY num DESC, u.sortable_name""" % (where1,where2)
# Fetch the joined courses (one semester) and schedules tables
def all_sem_courses_teachers(SEM="202470"): def all_sem_courses_teachers(SEM="202470"):
q = f"""SELECT c.id, c.name, c.course_code, u.name, u.sortable_name, u.id AS user_cid, p.sis_user_id, s.type, s.crn FROM canvas.courses AS c q = f"""SELECT c.id, c.name, c.course_code, u.name, u.sortable_name, u.id AS user_cid, p.sis_user_id, s.type, s.crn FROM canvas.courses AS c
JOIN canvas.enrollments AS e ON e.course_id=c.id JOIN canvas.enrollments AS e ON e.course_id=c.id
@ -364,6 +364,7 @@ def courses_to_sched():
# TODO: fix units when they are variable... change to float in between range. round to 0.5 unit. # TODO: fix units when they are variable... change to float in between range. round to 0.5 unit.
EXECUTE = 1 EXECUTE = 1
last_time = 0
seasons = {'10':'wi','30':'sp','50':'su','70':'fa'} seasons = {'10':'wi','30':'sp','50':'su','70':'fa'}
seasons2 = {'wi':'10', 'sp':'30', 'su':'50', 'fa':'70'} seasons2 = {'wi':'10', 'sp':'30', 'su':'50', 'fa':'70'}
@ -405,13 +406,22 @@ def courses_to_sched():
try: try:
pod = '' pod = ''
if 'partofday' in c: pod = c['partofday'] if 'partofday' in c: pod = c['partofday']
#print(c['cred'])
cred_match = re.search(r'(\d+\.\d+)\-(\d+\.\d+)',c['cred'])
if cred_match:
#print(f"matched range: {cred_match.groups}")
cred_start = float(cred_match.group(1))
cred_end = float(cred_match.group(2))
mid = float(int( (cred_end-cred_start)/2 + cred_start ))
c['cred'] = str(mid)
#print(f"middle cred is {c['cred']}")
full_sis_code = sis_code+'-'+c['crn'] full_sis_code = sis_code+'-'+c['crn']
if full_sis_code in sis_to_sched: if full_sis_code in sis_to_sched:
q = [sis_to_sched[full_sis_code][0][0], c['crn'], c['code'], c['cred'], c['teacher'], c['start'], c['end'], c['type'], c['loc'], c['site'], pod, int(c['cap']), int(c['act']), sis_code] q = [sis_to_sched[full_sis_code][0][0], c['crn'], c['code'], c['cred'], c['teacher'], c['start'], c['end'], c['type'], c['loc'], c['site'], pod, int(c['cap']), int(c['act']), sis_code]
vals_cache.append( q ) # [ str(x) for x in q ] ) vals_cache.append( q ) # [ str(x) for x in q ] )
print(f"{i}: {q}") #print(f"{i}: {q}")
i += 1 i += 1
if i % 100 == 0: if i % 100 == 0:
if EXECUTE: if EXECUTE:

View File

@ -182,7 +182,7 @@ dean['CSIS'] = 'ss'
dean['CWE'] = 'ss' dean['CWE'] = 'ss'
dean['DM'] = 'ss' dean['DM'] = 'ss'
dean['ECOL'] = 'jn' dean['ECOL'] = 'jn'
dean['ECON'] = 'nl' dean['ECON'] = 'ss'
dean['ENGL'] = 'nl' dean['ENGL'] = 'nl'
dean['ENGR'] = 'jn' dean['ENGR'] = 'jn'
dean['ENVS'] = 'jn' dean['ENVS'] = 'jn'
@ -191,7 +191,7 @@ dean['ETHN'] = 'nl'
dean['FRNH'] = 'nl' dean['FRNH'] = 'nl'
dean['GEOG'] = 'jn' dean['GEOG'] = 'jn'
dean['GEOL'] = 'jn' dean['GEOL'] = 'jn'
dean['GUID'] = 'nl' dean['GUID'] = 'de'
dean['HIST'] = 'nl' dean['HIST'] = 'nl'
dean['HUM'] = 'nl' dean['HUM'] = 'nl'
dean['JOUR'] = 'nl' dean['JOUR'] = 'nl'
@ -219,6 +219,7 @@ dean_names['et'] = 'Enna Trevathan'
dean_names['ss'] = 'Susan Sweeney' dean_names['ss'] = 'Susan Sweeney'
dean_names['nl'] = 'Noah Lystrup' dean_names['nl'] = 'Noah Lystrup'
dean_names['jn'] = 'Jennifer Nari' dean_names['jn'] = 'Jennifer Nari'
dean_names['de'] = 'Diego Espinoza'
class FetchError(Exception): class FetchError(Exception):

View File

@ -2234,6 +2234,7 @@ def cross_ref_training():
courses = all_sem_courses_teachers('202470') courses = all_sem_courses_teachers('202470')
for c in courses: for c in courses:
print(c) print(c)
try:
goo = c[6] goo = c[6]
crn = c[8] crn = c[8]
name = c[1] # full course name name = c[1] # full course name
@ -2249,6 +2250,8 @@ def cross_ref_training():
if ctype=='in-person': continue if ctype=='in-person': continue
teachers[teacher].append(d) teachers[teacher].append(d)
teachers_bydept[dept1].add(teacher) teachers_bydept[dept1].add(teacher)
except:
print(f"Problem with {c}, skipping")
alldepts = list(alldepts) alldepts = list(alldepts)
alldepts.sort() alldepts.sort()
@ -2259,7 +2262,7 @@ def cross_ref_training():
deptfont = Font(bold=True) deptfont = Font(bold=True)
flagfont = PatternFill("solid", fgColor="00FFFFCC") flagfont = PatternFill("solid", fgColor="00FFFFCC")
for thedean in ['et','nl','ss','jn']: for thedean in ['et','nl','ss','jn', 'de']:
sheet.cell(row=r, column=1).value = dean_names[thedean] sheet.cell(row=r, column=1).value = dean_names[thedean]
sheet.cell(row=r, column=1).font = deptfont sheet.cell(row=r, column=1).font = deptfont
r += 2 r += 2
@ -2542,6 +2545,7 @@ if __name__ == "__main__":
#22: ['Sync personnel and conference user databases', user_db_sync], #22: ['Sync personnel and conference user databases', user_db_sync],
23: ['Find non-gnumbers', find_no_goo ], 23: ['Find non-gnumbers', find_no_goo ],
24: ['compare user tables', compare_db_tables], 24: ['compare user tables', compare_db_tables],
25: ['cross ref training', cross_ref_training], 25: ['cross ref training', cross_ref_training],
26: ['find goo numbers in training spreadsheet', training_find_goos], 26: ['find goo numbers in training spreadsheet', training_find_goos],
#3: ['Main index, 1 year, teachers and their classes', getAllTeachersInTerm], #3: ['Main index, 1 year, teachers and their classes', getAllTeachersInTerm],