# Outcomes 2023 # Tasks: # # - List all courses (in semester) in iLearn: # + SLOs associated with the course # + Whether they are current or inactive # + Whether they are attached to an assessment # + Whether and by how many students, they have been assessed # # - Fetch most current SLOs from Curricunet # + Assemble multiple versions of a (CQ) course and determine which semesters they apply to # + Whether they are present in the relevant classes in iLearn # + Insert SLO into course if not present # + Mark as inactive (change name) if necessary # - Issue: # + Course naming / sections joined... import concurrent.futures import pandas as pd from pipelines import fetch, url, header from courses import getCoursesInTerm import codecs, json from path_dict import PathDict NUM_THREADS = 8 get_fresh = 0 sem_courses = getCoursesInTerm(176,get_fresh) # shorter list for test? #sem_courses = sem_courses[:50] print("Got %i courses in current semester." % len(sem_courses)) def course_slo_getter(q): (name,id) = q info = {'ilearnname':name,'ilearnid':id} print(" + Thread getting %s %s" % (str(name),str(id))) u1 = url + "/api/v1/courses/%s/outcome_groups" % str(id) og_for_course = fetch(u1) if len(og_for_course): for og in og_for_course: if "outcomes_url" in og: outcomes = fetch(url + og["outcomes_url"]) og['outcomes'] = outcomes og['full_outcomes'] = {} for oo in outcomes: print(" -> " + url + oo['outcome']['url']) this_outcome = fetch( url + oo['outcome']['url'] ) og['full_outcomes'][this_outcome['id']] = this_outcome og_for_course.insert(0,info) print(" - Thread %s DONE" % str(id)) return og_for_course output = [] with concurrent.futures.ThreadPoolExecutor(max_workers=NUM_THREADS) as pool: results = [] for C in sem_courses: print("Adding ", C['name'], C['id'], " to queue") results.append( pool.submit(course_slo_getter, [C['name'], C['id']] ) ) print("-- Done") print("results array has %i items" % len(results)) for r in concurrent.futures.as_completed(results): output.append(r.result()) raw_log = codecs.open('cache/outcome_raw_log.txt','w','utf-8') raw_log.write( json.dumps(output,indent=2) ) def ilearn_shell_slo_to_csv(shell_slos): L = ['canvasid','name','crn','has_outcomes',] for i in range(1,11): L.append("o%i_id" % i) L.append("o%i_vendor_guid" % i) L.append("o%i_desc" % i) L.append("o%i_assd" % i) df = pd.DataFrame(columns=L) for S in shell_slos: short = S[0] this_crs = {'canvasid':short['ilearnid'], 'name':short['ilearnname'], 'has_outcomes':0, } if len(S)>1: full = S[1] this_crs['has_outcomes'] = 1 i = 1 for o in full['outcomes']: try: this_id = int(o['outcome']['id']) this_crs['o%i_id' % i] = o['outcome']['id'] except Exception as e: this_crs['o%i_id' % i] = '!' try: this_crs['o%i_desc' % i] = full['full_outcomes'][this_id]['description'] except Exception as e: this_crs['o%i_desc' % i] = '!' try: assessed = 0 if full['full_outcomes'][this_id]['assessed'] == 'True': assessed = 1 this_crs['o%i_assd' % i] = assessed except Exception as e: this_crs['o%i_assd' % i] = '!' try: this_crs['o%i_vendor_guid' % i] = full['full_outcomes'][this_id]['vendor_guid'] except Exception as e: this_crs['o%i_vendor_guid' % i] = '!' i += 1 df2 = pd.DataFrame(this_crs, columns = df.columns, index=[0]) df = pd.concat( [df, df2], ignore_index = True ) df.to_csv('cache/outcome.csv') print(df) ilearn_shell_slo_to_csv(output)