From 7623c52a4a8b05297a1c80be8379957139caa5f1 Mon Sep 17 00:00:00 2001 From: Coding with Peter Date: Fri, 28 Apr 2023 10:12:12 -0700 Subject: [PATCH] cleanup errors and missing imports --- tasks.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/tasks.py b/tasks.py index 6915a4d..3b6e07a 100644 --- a/tasks.py +++ b/tasks.py @@ -16,6 +16,9 @@ import pysftp, os, datetime, requests, re, json, sqlite3, codecs, csv, sys import funcy, os.path, shutil, urllib from datetime import datetime +from collections import defaultdict +from datetime import strptime +from time import mktime from canvas_secrets import badgr_target, badgr_hd @@ -25,8 +28,12 @@ if os.name != 'posix': import win32com.client as win32 import pypandoc from docxtpl import DocxTemplate + import xlwt -from pipelines import header, url, fetch +from pipelines import header, url, fetch, convert_roster_files, move_to_folder, fetch_dict +from courses import course_enrollment +from users import teacherRolesCache +from util import match59, partition #from localcache import local_data_folder, sqlite_file, db, user_goo_to_email @@ -175,7 +182,8 @@ def convert_to_pdf(name1, name2): def certificates_gott_build(): #send_email("Peter Howell", "Peter", "phowell@gavilan.edu", "test", "this is a test") - g2e = user_goo_to_email() + #g2e = user_goo_to_email() + g2e = {} # missing function? g2name = {} ix = {} # everyone ix1 = {} # only gott 1 @@ -341,7 +349,7 @@ def put_file(classfoldername): def switch_enrol(): global results, header results = [] - id = raw_input("Id of course? ") + id = input("Id of course? ") url = "https://gavilan.instructure.com:443/api/v1/courses/"+id+"/enrollments?type[]=StudentEnrollment" while (url): url = fetch(url) all_stud = results @@ -353,7 +361,7 @@ def switch_enrol(): r2 = requests.post(u2, headers=header, data=params) #print( "Response: ", r2.text ) #res = json.loads(r2.text) - #if raw_input('continue? y/n ') == 'y': + #if input('continue? y/n ') == 'y': u3 = "https://gavilan.instructure.com:443/api/v1/courses/"+id+"/enrollments/"+str(S['id']) params = {'course_id':id, 'id':S['id'],'task':'delete'} r3 = requests.delete(u3, headers=header, data=params) @@ -361,7 +369,7 @@ def switch_enrol(): # Change dates & term of a class to unrestrict enrollment def unrestrict_course(): - id = raw_input('the course id? ') + id = input('the course id? ') t1 = url + '/api/v1/courses/' + id course = fetch(t1) @@ -386,6 +394,7 @@ def unrestrict_course(): # Bulk enroll users into a course +""" def enroll_accred(): global results, results_dict,header # enroll this account in every published course in the semester @@ -404,7 +413,7 @@ def enroll_accred(): r3 = requests.post(t3, headers=header, params=form) print ( "\t", r2.text ) print ( '\tok' ) - +""" # Calculate attendance stats based on enrollment/participation at 20% of term progressed, then 60% of term progressed. @@ -503,7 +512,7 @@ def course_2060_dates(crn=""): schedule = json.loads(open(schedfile,'r').read()) ok = 0 if not crn: - crn = raw_input("What is the CRN? ") + crn = input("What is the CRN? ") for s in schedule: if s['crn']== crn: ok = 1 @@ -535,14 +544,21 @@ def course_2060_dates(crn=""): def course_update_all_users_locallogs(course_id=''): if not course_id: - course_id = raw_input("ID of course to calculate hours? ") + course_id = input("ID of course to calculate hours? ") emts = course_enrollment(course_id) #print(emts) def hours_calc_pulldata(course_id=''): + + # broken... + endDT = 0 + second_cen_date = 0 + first_cen_date = 0 + beginDT = 0 + if not course_id: - course_id = raw_input("ID of course to calculate hours? ") + course_id = input("ID of course to calculate hours? ") emts = course_enrollment(course_id) #print(emts) @@ -666,7 +682,7 @@ def pos_atten(): errors = "" wr = csv.writer(f,quoting=csv.QUOTE_ALL) pa_wr = csv.writer(pa,quoting=csv.QUOTE_MINIMAL) - load_users() + teacherRolesCache() # get users in course 59 target = url + '/api/v1/courses/3295/users?per_page=100' @@ -1374,6 +1390,7 @@ if __name__ == "__main__": ################################ if 0: + pass if (0): out = open('cache/badgr.txt','w') @@ -1396,8 +1413,8 @@ if __name__ == "__main__": if (0): certificates_gott_build() - if (0): - blueprint_semester() + #if (0): + # blueprint_semester()