This commit is contained in:
Peter Howell 2025-09-24 18:45:09 +00:00
parent 4851edccd4
commit 7006f0f642
2 changed files with 21 additions and 3 deletions

View File

@ -1895,20 +1895,38 @@ def modify_courses():
print('****%s' % str(e))
def change_term(courseid,termid):
data = { 'course[term_id]': str(termid), 'course[restrict_enrollments_to_course_dates]':'false' }
t = f'{url}/api/v1/courses/{courseid}'
r3 = requests.put(t, headers=header, params=data)
result = json.loads(r3.text)
json.dumps(result,indent=2)
def teacher_to_many_shells():
for id in range(18089,18110):
for id in [21842,21096,20952,21561,21219,21274,20875,21018,21093,21719,21460,21102,21506,21169,21538]:
#print(id)
#continue
term_id_misc = 9
term_id_sp25 = 287
change_term(id, term_id_misc)
# Add teacher
u3 = url + f"/api/v1/courses/{id}/enrollments"
#usrid = input("id of %s? " % N)
usrid = '78'
usrid = '30286'
data2 = { "enrollment[type]":"TeacherEnrollment", "enrollment[user_id]":usrid,
"enrollment[enrollment_state]":"active" }
r4 = requests.post(u3, headers=header, params=data2)
result = json.loads(r4.text)
print(json.dumps(result, indent=2))
print(f"enrolled user id: {usrid} as teacher in course {id}.")
change_term(id, term_id_sp25)
import os, pickle

View File

@ -2938,7 +2938,7 @@ if __name__ == "__main__":
17: ['Show all convos for a user', convos_for_user],
21: ['Show all pushed notifications for a user', comm_mssgs_for_user],
18: ['Quiz submissions', quiz_submissions],
19: ['NLP Sample', nlp_sample],
#19: ['NLP Sample', nlp_sample],
20: ['Enroll a single user into a class', one_course_enrol],
21: ['Enroll a student into a section', section_enroll],
22: ['Teachers new this semester', find_new_teachers],