This commit is contained in:
phowell 2023-04-29 16:23:28 -07:00
commit 7696445ea0
2 changed files with 31 additions and 14 deletions

View File

@ -1153,7 +1153,7 @@ def fetch_current_rosters():
[print(" %s" % f) for f in files] [print(" %s" % f) for f in files]
i = 0 i = 0
got_courses = 0 got_courses = 0
if len(files)>1: # and 'users.csv' in files: if len(files)>0: # and 'users.csv' in files:
try: try:
if 'users.csv' in files: if 'users.csv' in files:
sftp.get('users.csv','cache/rosters/users-'+dt_label+'.csv') sftp.get('users.csv','cache/rosters/users-'+dt_label+'.csv')
@ -1201,7 +1201,7 @@ def fetch_current_rosters():
def fetch_current_rosters_auto(): def fetch_current_rosters_auto():
schedule.every().hour.at(":57").do(fetch_current_rosters) schedule.every().hour.at(":58").do(fetch_current_rosters)
schedule.every().day.at("12:35").do(sync_non_interactive) schedule.every().day.at("12:35").do(sync_non_interactive)
schedule.every().day.at("21:00").do(sync_non_interactive) schedule.every().day.at("21:00").do(sync_non_interactive)

View File

@ -16,6 +16,9 @@
import pysftp, os, datetime, requests, re, json, sqlite3, codecs, csv, sys import pysftp, os, datetime, requests, re, json, sqlite3, codecs, csv, sys
import funcy, os.path, shutil, urllib import funcy, os.path, shutil, urllib
from datetime import datetime from datetime import datetime
from collections import defaultdict
from datetime import strptime
from time import mktime
from canvas_secrets import badgr_target, badgr_hd from canvas_secrets import badgr_target, badgr_hd
@ -25,8 +28,12 @@ if os.name != 'posix':
import win32com.client as win32 import win32com.client as win32
import pypandoc import pypandoc
from docxtpl import DocxTemplate 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 #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(): def certificates_gott_build():
#send_email("Peter Howell", "Peter", "phowell@gavilan.edu", "test", "this is a test") #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 = {} g2name = {}
ix = {} # everyone ix = {} # everyone
ix1 = {} # only gott 1 ix1 = {} # only gott 1
@ -341,7 +349,7 @@ def put_file(classfoldername):
def switch_enrol(): def switch_enrol():
global results, header global results, header
results = [] 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" url = "https://gavilan.instructure.com:443/api/v1/courses/"+id+"/enrollments?type[]=StudentEnrollment"
while (url): url = fetch(url) while (url): url = fetch(url)
all_stud = results all_stud = results
@ -353,7 +361,7 @@ def switch_enrol():
r2 = requests.post(u2, headers=header, data=params) r2 = requests.post(u2, headers=header, data=params)
#print( "Response: ", r2.text ) #print( "Response: ", r2.text )
#res = json.loads(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']) u3 = "https://gavilan.instructure.com:443/api/v1/courses/"+id+"/enrollments/"+str(S['id'])
params = {'course_id':id, 'id':S['id'],'task':'delete'} params = {'course_id':id, 'id':S['id'],'task':'delete'}
r3 = requests.delete(u3, headers=header, data=params) r3 = requests.delete(u3, headers=header, data=params)
@ -361,7 +369,7 @@ def switch_enrol():
# Change dates & term of a class to unrestrict enrollment # Change dates & term of a class to unrestrict enrollment
def unrestrict_course(): def unrestrict_course():
id = raw_input('the course id? ') id = input('the course id? ')
t1 = url + '/api/v1/courses/' + id t1 = url + '/api/v1/courses/' + id
course = fetch(t1) course = fetch(t1)
@ -386,6 +394,7 @@ def unrestrict_course():
# Bulk enroll users into a course # Bulk enroll users into a course
"""
def enroll_accred(): def enroll_accred():
global results, results_dict,header global results, results_dict,header
# enroll this account in every published course in the semester # 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) r3 = requests.post(t3, headers=header, params=form)
print ( "\t", r2.text ) print ( "\t", r2.text )
print ( '\tok' ) print ( '\tok' )
"""
# Calculate attendance stats based on enrollment/participation at 20% of term progressed, then 60% of term progressed. # 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()) schedule = json.loads(open(schedfile,'r').read())
ok = 0 ok = 0
if not crn: if not crn:
crn = raw_input("What is the CRN? ") crn = input("What is the CRN? ")
for s in schedule: for s in schedule:
if s['crn']== crn: if s['crn']== crn:
ok = 1 ok = 1
@ -535,14 +544,21 @@ def course_2060_dates(crn=""):
def course_update_all_users_locallogs(course_id=''): def course_update_all_users_locallogs(course_id=''):
if not 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) emts = course_enrollment(course_id)
#print(emts) #print(emts)
def hours_calc_pulldata(course_id=''): def hours_calc_pulldata(course_id=''):
# broken...
endDT = 0
second_cen_date = 0
first_cen_date = 0
beginDT = 0
if not 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) emts = course_enrollment(course_id)
#print(emts) #print(emts)
@ -666,7 +682,7 @@ def pos_atten():
errors = "" errors = ""
wr = csv.writer(f,quoting=csv.QUOTE_ALL) wr = csv.writer(f,quoting=csv.QUOTE_ALL)
pa_wr = csv.writer(pa,quoting=csv.QUOTE_MINIMAL) pa_wr = csv.writer(pa,quoting=csv.QUOTE_MINIMAL)
load_users() teacherRolesCache()
# get users in course 59 # get users in course 59
target = url + '/api/v1/courses/3295/users?per_page=100' target = url + '/api/v1/courses/3295/users?per_page=100'
@ -1374,6 +1390,7 @@ if __name__ == "__main__":
################################ ################################
if 0: if 0:
pass
if (0): if (0):
out = open('cache/badgr.txt','w') out = open('cache/badgr.txt','w')
@ -1396,8 +1413,8 @@ if __name__ == "__main__":
if (0): if (0):
certificates_gott_build() certificates_gott_build()
if (0): #if (0):
blueprint_semester() # blueprint_semester()