sp24 changes to track whole semester

This commit is contained in:
Coding with Peter 2024-01-29 17:55:17 -08:00
parent 84aacc32dc
commit 38985af6aa
4 changed files with 112 additions and 76 deletions

View File

@ -662,42 +662,103 @@ def xlist_ii(parasite_id,host_id,new_name,new_code):
print(r3.text)
print("\n\n")
def course_term_summary_2():
lines = codecs.open('cache/term_summary.txt','r','utf-8').readlines()
output = codecs.open('cache/term_summary.html','w','utf-8')
for L in lines:
try:
L = L.strip()
print(L)
if re.search('unpublished',L):
m = re.search(r"'id': (\d+),",L)
m2 = re.search(r"'course_code': '(.+?)',",L)
if m:
ss = "<br />Course: <a href='%s' target='_blank'>%s</a><br />" % ("https://ilearn.gavilan.edu/courses/"+str(m.group(1)), m2.group(1))
output.write( ss )
print(ss+"\n")
except Exception as e:
print(e)
def course_term_summary_3():
# doesn't work cause of single, not double quotes?!?!
lines = codecs.open('cache/term_summary.txt','r','utf-8').readlines()
output = codecs.open('cache/term_summary.html','w','utf-8')
for L in lines:
try:
L = L.strip()
print(L)
ll = json.loads(L)
print(ll)
print(ll['course_code'])
if ll['workflow_state'] == 'unpublished':
ss = "<br />Course: <a href='%s' target='_blank'>%s</a><br />" % ("https://ilearn.gavilan.edu/courses/"+str(ll['id']), ll['course_code'] )
output.write( ss )
print(ss+"\n")
except Exception as e:
print(e)
# check number of students and publish state of all shells in a term
def all_semester_course_sanity_check():
c = getCoursesInTerm(178,0,0) # sp23
codecs.open('cache/courses_in_term_178.json','w','utf-8').write(json.dumps(c,indent=2))
output = codecs.open('cache/courses_w_sections.csv','w','utf-8')
output.write( ",".join(['what','id','parent_course_id','sis_course_id','name']) + "\n" )
t = 181
term = "sp24"
c = getCoursesInTerm(t,0,0)
sched1 = requests.get(f"http://gavilan.cc/schedule/{term}_sched_expanded.json").json()
sched = { x['crn']: x for x in sched1 }
#codecs.open('cache/courses_in_term_{t}.json','w','utf-8').write(json.dumps(c,indent=2))
#output = codecs.open('cache/courses_w_sections.csv','w','utf-8')
#output.write( ",".join(['what','id','parent_course_id','sis_course_id','name']) + "\n" )
output2 = codecs.open('cache/courses_checker.csv','w','utf-8')
output2.write( ",".join(['id','sis_course_id','name','state','students']) + "\n" )
output2.write( ",".join(['id','sis_course_id','name','state','mode','startdate','students']) + "\n" )
htmlout = codecs.open('cache/courses_checker.html','w','utf-8')
htmlout.write('<html><body><table>\n')
htmlout.write(f'<tr><td><b>Name</b></td><td><b>SIS ID</b></td><td><b>State</b></td><td><b>Mode</b></td><td><b>Start Date</b></td><td><b># Stu</b></td></tr>\n')
i = 0
for course in c:
u2 = url + '/api/v1/courses/%s?include[]=total_students' % str(course['id'])
course['info'] = fetch(u2)
#print(json.dumps(course['info'],indent=2))
# correlate to schedule
crn = course['sis_course_id'][7:]
ctype = '?'
cstart = '?'
ts = '?'
try:
ts = course['info']['total_students']
except Exception as e:
pass
if crn in sched:
ctype = sched[crn]['type']
cstart = sched[crn]['start']
ts = sched[crn]['act']
info = [ 'course', course['id'], '', course['sis_course_id'], course['name'], course['workflow_state'], ts ]
info = list(map(str,info))
info2 = [ course['id'], course['sis_course_id'], course['name'], course['workflow_state'], ts ]
info2 = [ course['id'], course['sis_course_id'], course['name'], course['workflow_state'], ctype, cstart, ts ]
info2 = list(map(str,info2))
output2.write( ",".join(info2) + "\n" )
output2.flush()
print(info2)
output.write( ",".join(info) + "\n" )
#output.write( ",".join(info) + "\n" )
uu = f"https://ilearn.gavilan.edu/courses/{course['id']}"
htmlout.write(f'<tr><td><a href="{uu}" target="_blank">{course["name"]}</a></td><td>{course["sis_course_id"]}</td><td>{course["workflow_state"]}</td><td>{ctype}</td><td>{cstart}</td><td>{ts}</td></tr>\n')
htmlout.flush()
#uu = url + '/api/v1/courses/%s/sections' % str(course['id'])
#course['sections'] = fetch(uu)
#s_info = [ [ 'section', y['id'], y['course_id'], y['sis_course_id'], y['name'], y['total_students'] ] for y in course['sections'] ]
#for row in s_info:
# print(row)
# output.write( ",".join( map(str,row) ) + "\n" )
output.flush()
#output.flush()
i += 1
if i % 5 == 0:
codecs.open('cache/courses_w_sections.json','w','utf-8').write(json.dumps(c,indent=2))
codecs.open('cache/courses_w_sections.json','w','utf-8').write(json.dumps(c,indent=2))
#if i % 5 == 0:
# codecs.open('cache/courses_w_sections.json','w','utf-8').write(json.dumps(c,indent=2))
#codecs.open('cache/courses_w_sections.json','w','utf-8').write(json.dumps(c,indent=2))
htmlout.write('</table></body></html>\n')
def eslCrosslister():
@ -1511,47 +1572,6 @@ def create_sandboxes():
def course_term_summary_2():
lines = codecs.open('cache/term_summary.txt','r','utf-8').readlines()
output = codecs.open('cache/term_summary.html','w','utf-8')
for L in lines:
try:
L = L.strip()
print(L)
if re.search('unpublished',L):
m = re.search(r"'id': (\d+),",L)
m2 = re.search(r"'course_code': '(.+?)',",L)
if m:
ss = "<br />Course: <a href='%s' target='_blank'>%s</a><br />" % ("https://ilearn.gavilan.edu/courses/"+str(m.group(1)), m2.group(1))
output.write( ss )
print(ss+"\n")
except Exception as e:
print(e)
def course_term_summary_3():
# doesn't work cause of single, not double quotes?!?!
lines = codecs.open('cache/term_summary.txt','r','utf-8').readlines()
output = codecs.open('cache/term_summary.html','w','utf-8')
for L in lines:
try:
L = L.strip()
print(L)
ll = json.loads(L)
print(ll)
print(ll['course_code'])
if ll['workflow_state'] == 'unpublished':
ss = "<br />Course: <a href='%s' target='_blank'>%s</a><br />" % ("https://ilearn.gavilan.edu/courses/"+str(ll['id']), ll['course_code'] )
output.write( ss )
print(ss+"\n")
except Exception as e:
print(e)
## ##
## ##
## ## Course Nav and External Tools
@ -1559,8 +1579,8 @@ def course_term_summary_3():
## ##
def do_gav_connect():
term = 180
sem = "202370"
term = 181
sem = "202430"
get_fresh = 1
crns = [sem + "-" + x.strip() for x in open('cache/starfish.txt','r').readlines()]
target = len(crns)
@ -1997,13 +2017,14 @@ if __name__ == "__main__":
8: ['Save enrollments in a course', course_enrollment],
9: ['Simple list of course data, search by sis_id', course_search_by_sis],
10: ['Overview of a term', course_term_summary],
20: ['process the semester overview output (10)', course_term_summary_2],
35: ['Check all courses & their sections in semester', all_semester_course_sanity_check],
11: ['Enroll ORIENTATION and STEM student shells after catching up database.', enroll_o_s_students],
12: ['Enroll stem students', enroll_stem_students_live],
13: ['Enroll orientation students (refresh local db)', enroll_orientation_students],
14: ['Enroll ART students', enroll_art_students_live],
20: ['process the semester overview output (10)', course_term_summary_2],
22: ['Get a course info by id',getCourses],
23: ['Reset course conclude date',update_course_conclude],
@ -2015,10 +2036,9 @@ if __name__ == "__main__":
21: ['Add course evals', add_evals],
31: ['Fine tune term dates and winter session', course_by_depts_terms],
32: ['Cross-list classes', xlist ],
33: ['Cross list helper', eslCrosslister],
#32: ['Cross-list classes', xlist ],
#33: ['Cross list helper', eslCrosslister],
34: ['Cross list a semester from file', semester_cross_lister],
35: ['Check all courses & their sections in semester', all_semester_course_sanity_check],
36: ['Quick course list', quick_sem_course_list ],
37: ['Cross list CWE courses', xlist_cwe],
38: ['Create calendar event', create_calendar_event],

View File

@ -1867,8 +1867,18 @@ WHERE
connection.close()
def add_sessions(filename='cache/pd_sp24.csv'):
out = codecs.open('cache/pd_sp24.sql','w','utf-8')
with codecs.open(filename, 'r','utf-8') as file:
reader = csv.DictReader(file)
for dirty_row in reader:
row = {k: v.replace("'", "''") for k, v in dirty_row.items()} # Escape single quotes in CSV data
out.write(f"INSERT INTO conf_sessions \
(title, starttime, mode, location, location_irl, `desc`, `type`, length, track, gets_survey, is_flex_approved, category, parent) \
VALUES ('{row['title']}', '{row['starttime']}', '{row['mode']}', '{row['location']}', '{row['location_irl']}', '{row['desc']}', 101, 1, 1, 1, 1, 0, 1364);\n")
def add_sessions():
def add_sessions2():
j_in = json.loads( codecs.open('cache/2023sessions.json','r','utf-8').read())
# Function to format the starttime
@ -1888,7 +1898,7 @@ def add_sessions():
track = 1
id = 1341
f = "id, title, desc, type, length, starttime, track, location, location_irl, mode, gets_survey, is_flex_approved, parent"
f = "id, title, `desc`, `type`, length, starttime, track, location, location_irl, mode, gets_survey, is_flex_approved, parent"
fields = ",".join([ ugh(x) for x in f.split(', ') ])
for session_data in j_in:
@ -1927,7 +1937,7 @@ def test_long_running():
def courses_to_sched():
# Correlate rows in courses table with an id to rows in schedule table.
conn,cur = db('cache/canvas_data/data20231012.db')
conn,cur = db('cache/canvas_data/data.db')
q = "SELECT canvasid, code, sis, schedule FROM courses ORDER BY sis DESC"
conn.row_factory = dict_factory

22
ui.py
View File

@ -2,10 +2,14 @@
from textual.app import App, ComposeResult
from textual.widgets import Placeholder, Static
from textual.containers import VerticalScroll
from textual import events
from textual.reactive import Reactive
from textual.widgets import Placeholder, Static, Button, Digits
from textual.containers import Container, VerticalScroll
from textual import events, on
from textual.reactive import Reactive, var
from textual.css.query import NoMatches
from itertools import cycle
@ -53,6 +57,9 @@ class Hello(Static):
class MyApp(App):
value = var("")
"""
async def startup(self):
await self.bind("q", "action_quit")
await self.push_view(self.control)
@ -69,10 +76,7 @@ class MyApp(App):
)
# Right area with lorem ipsum placeholder
lorem_ipsum = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
"""
lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
self.view.add_right(
# VerticalScroll(StrContent(lorem_ipsum), name="Lorem"),
Static(lorem_ipsum, name="Lorem"),
@ -82,7 +86,9 @@ class MyApp(App):
# Command input at the bottom
self.view.add_bottom(Static("Enter command: "), height=3)
"""
def action_quit(self):
self.exit()

View File

@ -1789,8 +1789,8 @@ def track_user(id=0,qid=0):
url_addition = ""
if 1: # hard code dates
start_date = "2023-01-01T00:00:00-07:00"
end_date = "2023-08-01T00:00:00-07:00"
start_date = "2023-08-01T00:00:00-07:00"
end_date = "2024-01-01T00:00:00-07:00"
url_addition = f"?start_time={start_date}&end_time={end_date}"
elif 'last_days_log' in info:
print("There's existing log data for %s (%s)" % (info['name'] , info['sis_user_id']))