for adding 'redirect' nav links to courses
This commit is contained in:
parent
aed354ad7f
commit
06ca6a9dc8
415
courses.py
415
courses.py
|
|
@ -1064,93 +1064,10 @@ def course_search_by_sis():
|
|||
# print(json.dumps(x, indent=2))
|
||||
|
||||
|
||||
def mod_eval_visibility( shell_id, visible=True ):
|
||||
evals_hidden = True
|
||||
if (visible): evals_hidden = False
|
||||
data = {'position':2, 'hidden':evals_hidden}
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s/tabs/context_external_tool_1953" % shell_id
|
||||
r3 = requests.put(u2, headers=header, params=data)
|
||||
#print(" " + r3.text)
|
||||
|
||||
|
||||
|
||||
def instructor_list_to_activate_evals():
|
||||
courses = all_sem_courses_teachers()
|
||||
|
||||
mylist = codecs.open('cache/fa21_eval_teachers.txt','r','utf-8').readlines()
|
||||
mylist = [ x.split(',')[2].strip() for x in mylist ]
|
||||
|
||||
count = 0
|
||||
limit = 5000
|
||||
|
||||
for c in courses:
|
||||
shell_id = c[1]
|
||||
teacher_id = c[6]
|
||||
teacher_name = c[5]
|
||||
course_name = c[3]
|
||||
|
||||
if teacher_id in mylist:
|
||||
print("Teacher: %s \t course: %s" % (teacher_name,course_name))
|
||||
mod_eval_visibility( shell_id, False)
|
||||
count += 1
|
||||
if count > limit: return
|
||||
|
||||
|
||||
#print(mylist)
|
||||
|
||||
|
||||
|
||||
def add_evals(section=0):
|
||||
# show or hide?
|
||||
hidden = False
|
||||
#s = [ x.strip() for x in codecs.open('cache/sp21_eval_sections.txt','r').readlines()]
|
||||
#s = [ x.split(',')[4].split('::') for x in codecs.open('cache/fa22_eval_sections.csv','r').readlines()]
|
||||
#s = [ x.strip() for x in codecs.open('cache/fa22_eval_sections.csv','r').readlines()]
|
||||
s = [ x.strip() for x in codecs.open('cache/sp23_eval_sections.csv','r').readlines()]
|
||||
s = list(funcy.flatten(s))
|
||||
s.sort()
|
||||
print(s)
|
||||
xyz = input('hit return to continue')
|
||||
|
||||
#c = getCoursesInTerm(168,0,1)
|
||||
#c = getCoursesInTerm(174,0,1) # sp22
|
||||
#c = getCoursesInTerm(176,0,1) # fa22
|
||||
c = getCoursesInTerm(178,0,1) # sp23
|
||||
print(c)
|
||||
ids = []
|
||||
courses = {}
|
||||
for C in c:
|
||||
if C and 'sis_course_id' in C and C['sis_course_id']:
|
||||
parts = C['sis_course_id'].split('-')
|
||||
if parts[1] in s:
|
||||
print(C['name'])
|
||||
courses[str(C['id'])] = C
|
||||
ids.append(str(C['id']))
|
||||
|
||||
ask = 1
|
||||
data = {'position':2, 'hidden':hidden}
|
||||
|
||||
for i in ids:
|
||||
if ask:
|
||||
a = input("Hit q to quit, a to do all, or enter to activate eval for: " + str(courses[i]))
|
||||
if a == 'a': ask = 0
|
||||
if a == 'q': return
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s/tabs/context_external_tool_1953" % i
|
||||
r3 = requests.put(u2, headers=header, params=data)
|
||||
print(r3.text)
|
||||
time.sleep(0.400)
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/12001/tabs"
|
||||
r = fetch(u2)
|
||||
print(json.dumps(r,indent=2))
|
||||
|
||||
|
||||
|
||||
# PUT /api/v1/courses/:course_id/tabs/:tab_id
|
||||
|
||||
def course_dates_terms(section=0):
|
||||
"""s = [ x.strip() for x in codecs.open('cache/fa22_eval_sections.csv','r').readlines()]
|
||||
s = list(funcy.flatten(s))
|
||||
|
|
@ -1216,65 +1133,6 @@ def course_dates_terms(section=0):
|
|||
|
||||
|
||||
|
||||
def remove_n_analytics(section=0):
|
||||
print("Fetching list of all active courses")
|
||||
|
||||
c = getCoursesInTerm(172,1,0)
|
||||
print(c)
|
||||
ids = []
|
||||
courses = {}
|
||||
data = {'hidden':True}
|
||||
|
||||
pause = 1
|
||||
|
||||
for C in c:
|
||||
#print( json.dumps(C,indent=2) )
|
||||
parts = C['sis_course_id'].split('-')
|
||||
#print("\n")
|
||||
print(C['name'])
|
||||
courses[str(C['id'])] = C
|
||||
ids.append(str(C['id']))
|
||||
|
||||
u3 = url + '/api/v1/courses/%s/tabs' % str(C['id'])
|
||||
tabs = fetch(u3)
|
||||
for T in tabs:
|
||||
if T['label'] == "New Analytics":
|
||||
print( "\tVisibility is: " + T["visibility"] ) # json.dumps(tabs,indent=2) )
|
||||
if "hidden" in T:
|
||||
print( "\tHidden is: " + str(T["hidden"]) ) # json.dumps(tabs,indent=2) )
|
||||
if 1: # T["visibility"] != "admins":
|
||||
u4 = url + "/api/v1/courses/%s/tabs/%s" % ( str(C['id']), str(T['id']) )
|
||||
print( "\tChanging visiblity of a. tab" )
|
||||
r4 = requests.put(u4, headers=header, params=data)
|
||||
print("\t" + r4.text)
|
||||
if pause:
|
||||
xyz = input('\n\nenter for next one or [y] to do all: ')
|
||||
if xyz == 'y': pause = 0
|
||||
|
||||
|
||||
exit()
|
||||
|
||||
|
||||
"""ask = 1
|
||||
|
||||
evals_hidden = True
|
||||
|
||||
|
||||
data = {'position':2, 'hidden':evals_hidden}
|
||||
|
||||
for i in ids:
|
||||
if ask:
|
||||
a = input("Hit q to quit, a to do all, or enter to activate eval for: \n " + str(courses[i]) + "\n> ")
|
||||
if a == 'a': ask = 0
|
||||
if a == 'q': return
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s/tabs/context_external_tool_1953" % i
|
||||
print(courses[i]['name'])
|
||||
r3 = requests.put(u2, headers=header, params=data)
|
||||
print(" " + r3.text)
|
||||
time.sleep(0.300)
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def xlist_cwe():
|
||||
|
||||
|
|
@ -1378,6 +1236,148 @@ def course_term_summary_2():
|
|||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
|
||||
|
||||
## ##
|
||||
## ##
|
||||
## ## Course Nav and External Tools
|
||||
## ##
|
||||
## ##
|
||||
|
||||
def do_gav_connect():
|
||||
crn = "40061"
|
||||
term = 178
|
||||
sem = "202330"
|
||||
get_fresh = 0
|
||||
c = getCoursesInTerm(term, get_fresh, 0)
|
||||
for course in c:
|
||||
if course['sis_course_id'] == f"{sem}-{crn}":
|
||||
print("Adding gav connect to", course['name'])
|
||||
print()
|
||||
add_gav_connect(course['id'])
|
||||
|
||||
def add_gav_connect(course_id):
|
||||
params = { "name": "GavConnect",
|
||||
"privacy_level": "anonymous",
|
||||
"description": "Add links to external web resources that show up as navigation items in course, user or account navigation. Whatever URL you specify is loaded within the content pane when users click the link.",
|
||||
"consumer_key": "N/A",
|
||||
"shared_secret": "N/A",
|
||||
"url": "https://www.edu-apps.org/redirect",
|
||||
"custom_fields[new_tab]": "1",
|
||||
"custom_fields[url]": "https://gavilan.starfishsolutions.com/starfish-ops/support/login.html?tenantId=9458",
|
||||
"workflow_state": "anonymous",
|
||||
"course_navigation[enabled]": "true",
|
||||
"course_navigation[visibility]": "public",
|
||||
"course_navigation[label]": "GavConnect",
|
||||
"course_navigation[selection_width]": "800",
|
||||
"course_navigation[selection_height]": "400",
|
||||
"course_navigation[icon_url]": "https://www.edu-apps.org/assets/lti_redirect_engine/redirect_icon.png",
|
||||
}
|
||||
|
||||
# POST
|
||||
u = url + f"/api/v1/courses/{course_id}/external_tools"
|
||||
res = requests.post(u, headers = header, params=params)
|
||||
result = json.loads(res.text)
|
||||
|
||||
#print( json.dumps( result, indent=2) )
|
||||
if "errors" in result:
|
||||
return 0
|
||||
if "id" in result:
|
||||
return 1
|
||||
|
||||
def mod_eval_visibility( shell_id, visible=True ):
|
||||
evals_hidden = True
|
||||
if (visible): evals_hidden = False
|
||||
data = {'position':2, 'hidden':evals_hidden}
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s/tabs/context_external_tool_1953" % shell_id
|
||||
r3 = requests.put(u2, headers=header, params=data)
|
||||
#print(" " + r3.text)
|
||||
|
||||
|
||||
|
||||
def instructor_list_to_activate_evals():
|
||||
courses = all_sem_courses_teachers()
|
||||
|
||||
mylist = codecs.open('cache/fa21_eval_teachers.txt','r','utf-8').readlines()
|
||||
mylist = [ x.split(',')[2].strip() for x in mylist ]
|
||||
|
||||
count = 0
|
||||
limit = 5000
|
||||
|
||||
for c in courses:
|
||||
shell_id = c[1]
|
||||
teacher_id = c[6]
|
||||
teacher_name = c[5]
|
||||
course_name = c[3]
|
||||
|
||||
if teacher_id in mylist:
|
||||
print("Teacher: %s \t course: %s" % (teacher_name,course_name))
|
||||
mod_eval_visibility( shell_id, False)
|
||||
count += 1
|
||||
if count > limit: return
|
||||
|
||||
|
||||
#print(mylist)
|
||||
|
||||
|
||||
|
||||
def add_evals(section=0):
|
||||
# show or hide?
|
||||
hidden = False
|
||||
#s = [ x.strip() for x in codecs.open('cache/sp21_eval_sections.txt','r').readlines()]
|
||||
#s = [ x.split(',')[4].split('::') for x in codecs.open('cache/fa22_eval_sections.csv','r').readlines()]
|
||||
#s = [ x.strip() for x in codecs.open('cache/fa22_eval_sections.csv','r').readlines()]
|
||||
s = [ x.strip() for x in codecs.open('cache/sp23_eval_sections.csv','r').readlines()]
|
||||
s = list(funcy.flatten(s))
|
||||
s.sort()
|
||||
print(s)
|
||||
xyz = input('hit return to continue')
|
||||
|
||||
#c = getCoursesInTerm(168,0,1)
|
||||
#c = getCoursesInTerm(174,0,1) # sp22
|
||||
#c = getCoursesInTerm(176,0,1) # fa22
|
||||
c = getCoursesInTerm(178,0,1) # sp23
|
||||
print(c)
|
||||
ids = []
|
||||
courses = {}
|
||||
for C in c:
|
||||
if C and 'sis_course_id' in C and C['sis_course_id']:
|
||||
parts = C['sis_course_id'].split('-')
|
||||
if parts[1] in s:
|
||||
print(C['name'])
|
||||
courses[str(C['id'])] = C
|
||||
ids.append(str(C['id']))
|
||||
|
||||
ask = 1
|
||||
data = {'position':2, 'hidden':hidden}
|
||||
|
||||
for i in ids:
|
||||
if ask:
|
||||
a = input("Hit q to quit, a to do all, or enter to activate eval for: " + str(courses[i]))
|
||||
if a == 'a': ask = 0
|
||||
if a == 'q': return
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s/tabs/context_external_tool_1953" % i
|
||||
r3 = requests.put(u2, headers=header, params=data)
|
||||
print(r3.text)
|
||||
time.sleep(0.400)
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/12001/tabs"
|
||||
r = fetch(u2)
|
||||
print(json.dumps(r,indent=2))
|
||||
|
||||
|
||||
|
||||
# PUT /api/v1/courses/:course_id/tabs/:tab_id
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_ext_tools():
|
||||
r = url + '/api/v1/accounts/1/external_tools'
|
||||
s = fetch(r)
|
||||
|
|
@ -1390,19 +1390,131 @@ def set_ext_tools():
|
|||
s = json.loads(requests.put(r, headers=header, params=data).text)
|
||||
print(json.dumps(s,indent=2))
|
||||
|
||||
|
||||
def get_course_ext_tools():
|
||||
course_id = "15971"
|
||||
r = url + f"/api/v1/courses/{course_id}/external_tools"
|
||||
s = fetch(r)
|
||||
print(json.dumps(s,indent=2))
|
||||
|
||||
|
||||
def remove_n_analytics(section=0):
|
||||
print("Fetching list of all active courses")
|
||||
|
||||
c = getCoursesInTerm(172,1,0)
|
||||
print(c)
|
||||
ids = []
|
||||
courses = {}
|
||||
data = {'hidden':True}
|
||||
|
||||
pause = 1
|
||||
|
||||
for C in c:
|
||||
#print( json.dumps(C,indent=2) )
|
||||
parts = C['sis_course_id'].split('-')
|
||||
#print("\n")
|
||||
print(C['name'])
|
||||
courses[str(C['id'])] = C
|
||||
ids.append(str(C['id']))
|
||||
|
||||
u3 = url + '/api/v1/courses/%s/tabs' % str(C['id'])
|
||||
tabs = fetch(u3)
|
||||
for T in tabs:
|
||||
if T['label'] == "New Analytics":
|
||||
print( "\tVisibility is: " + T["visibility"] ) # json.dumps(tabs,indent=2) )
|
||||
if "hidden" in T:
|
||||
print( "\tHidden is: " + str(T["hidden"]) ) # json.dumps(tabs,indent=2) )
|
||||
if 1: # T["visibility"] != "admins":
|
||||
u4 = url + "/api/v1/courses/%s/tabs/%s" % ( str(C['id']), str(T['id']) )
|
||||
print( "\tChanging visiblity of a. tab" )
|
||||
r4 = requests.put(u4, headers=header, params=data)
|
||||
print("\t" + r4.text)
|
||||
if pause:
|
||||
xyz = input('\n\nenter for next one or [y] to do all: ')
|
||||
if xyz == 'y': pause = 0
|
||||
|
||||
|
||||
exit()
|
||||
|
||||
|
||||
"""ask = 1
|
||||
|
||||
evals_hidden = True
|
||||
|
||||
|
||||
data = {'position':2, 'hidden':evals_hidden}
|
||||
|
||||
for i in ids:
|
||||
if ask:
|
||||
a = input("Hit q to quit, a to do all, or enter to activate eval for: \n " + str(courses[i]) + "\n> ")
|
||||
if a == 'a': ask = 0
|
||||
if a == 'q': return
|
||||
u2 = "https://gavilan.instructure.com:443/api/v1/courses/%s/tabs/context_external_tool_1953" % i
|
||||
print(courses[i]['name'])
|
||||
r3 = requests.put(u2, headers=header, params=data)
|
||||
print(" " + r3.text)
|
||||
time.sleep(0.300)
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def quick_sem_course_list(term=180):
|
||||
c = getCoursesInTerm(term,1,0)
|
||||
c = sorted(c, key=lambda k: k['name'])
|
||||
for C in c:
|
||||
print(C['name'])
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
|
||||
|
||||
def create_calendar_event():
|
||||
events = codecs.open('cache/events.csv','r','utf-8').readlines()
|
||||
|
||||
for e in events:
|
||||
(date, title, desc) = e.split(',')
|
||||
local = pytz.timezone("America/Los_Angeles")
|
||||
naive = datetime.strptime(date, "%Y-%m-%d")
|
||||
local_dt = local.localize(naive, is_dst=None)
|
||||
utc_dt = local_dt.astimezone(pytz.utc).isoformat()
|
||||
|
||||
|
||||
|
||||
params = {
|
||||
"calendar_event[context_code]": "course_15924", # 2023 student orientation
|
||||
"calendar_event[title]": title,
|
||||
"calendar_event[description]": desc,
|
||||
"calendar_event[start_at]": utc_dt, # DateTime
|
||||
"calendar_event[all_day]": "true",
|
||||
|
||||
}
|
||||
|
||||
u = url + "/api/v1/calendar_events"
|
||||
res = requests.post(u, headers = header, params=params)
|
||||
result = json.loads(res.text)
|
||||
print(title,end=" ")
|
||||
if "errors" in result:
|
||||
print(result["errors"])
|
||||
if "id" in result:
|
||||
print("ok, id#", result["id"])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
options = { 1: ['Cross check schedule with ztc responses',make_ztc_list] ,
|
||||
2: ['Add announcements to homepage', change_course_ann_homepage],
|
||||
3: ['Cross-list classes', xlist ],
|
||||
4: ['List students who passed quiz X', get_quiz_passers],
|
||||
5: ['List the terms', getTerms],
|
||||
6: ['Cross list helper', eslCrosslister],
|
||||
7: ['Show courses in a term', getCoursesInTerm],
|
||||
8: ['Save enrollments in a course', course_enrollment],
|
||||
9: ['Simple list of course data, search by sis_id', course_search_by_sis],
|
||||
|
|
@ -1413,21 +1525,26 @@ if __name__ == "__main__":
|
|||
14: ['Enroll ART students', enroll_art_students_live],
|
||||
15: ['List users who passed GOTT 1 / Bootcamp', get_gott1_passers],
|
||||
16: ['List users who passed Plagiarism Module', get_plague_passers],
|
||||
17: ['Remove "new analytics" from all courses navs in a semester', remove_n_analytics],
|
||||
18: ['Create some sandbox courses', create_sandboxes],
|
||||
19: ['Add course evals', add_evals],
|
||||
20: ['process the semester overview output (10)', course_term_summary_2],
|
||||
21: ['Add announcements to homepage', change_course_ann_homepage],
|
||||
22: ['Get a course info by id',getCourses],
|
||||
23: ['Reset course conclude date',update_course_conclude],
|
||||
#24: ['Add course evals to whole semester',instructor_list_to_activate_evals],
|
||||
25: ['ext tools',get_ext_tools],
|
||||
26: ['set ext tools',set_ext_tools],
|
||||
26: ['set ext tools',set_ext_tools],
|
||||
32: ['Get course ext tools', get_course_ext_tools],
|
||||
33: ['Add GavConnect to a course', do_gav_connect],
|
||||
17: ['Remove "new analytics" from all courses navs in a semester', remove_n_analytics],
|
||||
19: ['Add course evals', add_evals],
|
||||
27: ['Fine tune term dates and winter session', course_dates_terms],
|
||||
3: ['Cross-list classes', xlist ],
|
||||
6: ['Cross list helper', eslCrosslister],
|
||||
28: ['Cross list a semester from file', semester_cross_lister],
|
||||
29: ['Check all courses & their sections in semester', all_semester_course_sanity_check],
|
||||
30: ['Quick course list', quick_sem_course_list ],
|
||||
31: ['Cross list CWE courses', xlist_cwe],
|
||||
34: ['Create calendar event', create_calendar_event],
|
||||
# 24: ['Add course evals to whole semester',instructor_list_to_activate_evals],
|
||||
# 21: ['Add announcements to homepage', change_course_ann_homepage],
|
||||
# TODO wanted: group shell for each GP (guided pathway) as a basic student services gateway....
|
||||
#
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue