From 19a628efab480e0e68b7d0195e0d0ec7e7c3e5f6 Mon Sep 17 00:00:00 2001 From: Peter Howell Date: Thu, 13 Nov 2025 17:48:10 +0000 Subject: [PATCH] k --- courses.py | 88 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/courses.py b/courses.py index 1598b89..74cc4c7 100644 --- a/courses.py +++ b/courses.py @@ -689,31 +689,34 @@ def xlist_ii(parasite_id,host_id,new_name,new_code): xyz = 'y' #xyz = input("Perform cross list? Enter y for yes, n for no: ") if xyz != 'n': - uu = url + '/api/v1/courses/%s/sections' % parasite_id - c_sect = fetch(uu) - #print(json.dumps(c_sect,indent=2)) - if len(c_sect) > 1: - print("* * * * Already Crosslisted!!") - return - if not c_sect: - print("* * * * Already Crosslisted!!") - return - else: - parasite_sxn_id = str(c_sect[0]['id']) - print("Parasite section id: ", parasite_sxn_id) + try: + uu = url + '/api/v1/courses/%s/sections' % parasite_id + c_sect = fetch(uu) + #print(json.dumps(c_sect,indent=2)) + if len(c_sect) > 1: + print("* * * * Already Crosslisted!!") + return + if not c_sect: + print("* * * * Already Crosslisted!!") + return + else: + parasite_sxn_id = str(c_sect[0]['id']) + print("Parasite section id: ", parasite_sxn_id) - u = url + "/api/v1/sections/%s/crosslist/%s" % (parasite_sxn_id,host_id) - print(u) - res = requests.post(u, headers = header) - print(res.text) + u = url + "/api/v1/sections/%s/crosslist/%s" % (parasite_sxn_id,host_id) + print(u) + res = requests.post(u, headers = header) + print(res.text) - u3 = url + "/api/v1/courses/%s" % host_id - data = {'course[name]': new_name, 'course[course_code]': new_code} - print(data) - print(u3) - r3 = requests.put(u3, headers=header, params=data) - print(r3.text) - print("\n\n") + u3 = url + "/api/v1/courses/%s" % host_id + data = {'course[name]': new_name, 'course[course_code]': new_code} + print(data) + print(u3) + r3 = requests.put(u3, headers=header, params=data) + print(r3.text) + print("\n\n") + except Exception as e: + print(f"\n\nSome sort of failure on {new_name}: {e}") # Relevant stuff trying to see if its even being used or not @@ -1702,19 +1705,20 @@ def overview_start_dates(): def course_by_depts_terms(section=0): - get_fresh = 1 - TERM = 287 - WI_TERM = 286 + get_fresh = 0 + TERM = 291 + WI_TERM = 290 DOING_WINTER_MOVES = 1 - SEM = "sp25" - make_changes = 1 - do_all = 0 + SEM = "sp26" - winter_start_day = 2 - aviation_start_day = 9 + make_changes = 0 + do_all = 'a' + + winter_start_day = 5 + aviation_start_day = 7 nursing_start_day = 0 - spring_start_day = 27 + spring_start_day = 26 # get list of online course shells if get_fresh: @@ -1743,18 +1747,18 @@ def course_by_depts_terms(section=0): # try to find online shell matching this schedule entry try: this_id = crn_to_canvasid[S['crn']] + report_line = f" - {start} {d_start} - id: {this_id} - {S['code']} {S['crn']} {S['name']}" except Exception as e: print(f"DIDN'T FIND CRN - {start} {d_start} - {S['code']} {S['crn']} {S['name']}" ) continue - print(f" - {start} {d_start} - id: {this_id} - {S['code']} {S['crn']} {S['name']}" ) if 1: #if d_start.month < 5 or d_start.month > 7: # print(f" Ignoring {d_start}, starting too far away...") # continue if d_start.month == 1 and d_start.day == aviation_start_day: - print("- Aviation ", start, d_start, " - ", S['code'], " ", S['crn'] ) + print(f"+ AVIAT {report_line}") continue #if d_start.month == 1 and d_start.day == nursing_start_day: @@ -1762,11 +1766,11 @@ def course_by_depts_terms(section=0): # continue if d_start.month == 1 and d_start.day == spring_start_day: - print(" Ignoring, term start date" ) + print(f" IGNORE {report_line}" ) continue else: - print(" Adjust course start day?") + #print(f" Adjust course start day? {report_line}") if make_changes: if do_all != 'a': @@ -1778,17 +1782,17 @@ def course_by_depts_terms(section=0): 'course[restrict_enrollments_to_course_dates]':True } u2 = f"https://gavilan.instructure.com:443/api/v1/courses/{this_id}" r3 = requests.put(u2, headers=header, params=data) - print(" updated.. OK") + print(f"+ UPDATED {report_line}") - + make_changes = 1 if DOING_WINTER_MOVES: if d_start.month == 1 and d_start.day == winter_start_day: - print("+ winter session: ", d_start, " - ", S['code']) + print(f"+ WINTER {report_line}") data = {'course[term_id]':WI_TERM} u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s" % crn_to_canvasid[S['crn']] if make_changes: r3 = requests.put(u2, headers=header, params=data) - print(" updated.. OK") + #print(" updated.. OK") #print(r3.text) @@ -1804,8 +1808,8 @@ def xlist_cwe(): # cwe192 get put into another shell - this_sem_190_id = 22890 # they get 190s and 290s - this_sem_192_id = 22894 # they get 192s + this_sem_190_id = 23594 # they get 190s and 290s + this_sem_192_id = 23603 # they get 192s # this_sem_term = 289 term = find_term( input("term? (ex: fa25) ") )