course merge, sem setup
This commit is contained in:
parent
28fd54a8b7
commit
f16288322e
14
courses.py
14
courses.py
|
|
@ -74,17 +74,17 @@ def get_plague_passers():
|
|||
oo = { 'passed': passed_by_deptdidnt': didnt_by_dept
|
||||
for cr in crossref:
|
||||
student_int = course_enrollment(cr)
|
||||
student_by_dept{ str(k): v for k,v in student_int.items() }
|
||||
oo[cr] = student_by_dept
|
||||
student_by_dict{ str(k): v for k,v in student_int.items() }
|
||||
oo[cr] = student_by_dict
|
||||
output_by_course[cr] = { 'passed':{}, 'didnt':{}, 'missing':{} }
|
||||
|
||||
course_s[cr] = set( [ str(k) for k in student_by_deptys() ])
|
||||
course_s[cr] = set( [ str(k) for k in student_by_dict.keys() ])
|
||||
|
||||
for k,v in student_by_deptems():
|
||||
for k,v in student_by_dict.items():
|
||||
key_s = str(k)
|
||||
|
||||
if key_s in passed_by_dept output_by_course[cr]['passed'][key_s] = passed_by_depty_s]
|
||||
elif key_s in didnt_by_dept output_by_course[cr]['didnt'][key_s] = didnt_by_depty_s]
|
||||
if key_s in passed_by_dict output_by_course[cr]['passed'][key_s] = passed_by_dicty_s]
|
||||
elif key_s in didnt_by_dict output_by_course[cr]['didnt'][key_s] = didnt_by_dicty_s]
|
||||
else:
|
||||
output_by_course[cr]['missing'][key_s] = v['user']
|
||||
|
||||
|
|
@ -1742,7 +1742,7 @@ def fetch_rubric_scores(course_id=16528, assignment_id=1):
|
|||
print(json.dumps(rubric,indent=2))
|
||||
for r in rubric:
|
||||
for rat in r.get('ratings',[]):
|
||||
ratings_by_dept[rat['id']] = { 'rub_by_deptription': r['description'], 'rat_by_deptription': rat['description'], 'points': rat['points']}
|
||||
ratings_by_dept[rat['id']] = { 'description': r['description'], 'long_description': rat['description'], 'points': rat['points']}
|
||||
|
||||
|
||||
# Print the assignments dictionary
|
||||
|
|
|
|||
91
stats.py
91
stats.py
|
|
@ -1194,6 +1194,96 @@ def lstm_model_sections():
|
|||
df
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def visualize_course_modes_multi_semester():
|
||||
import plotly.express as px
|
||||
from plotly.subplots import make_subplots
|
||||
seasons = {'sp':'30','su':'50','fa':'70'}
|
||||
semcodes = "sp18 su18 fa18 sp19 su19 fa19 sp20 su20 fa20 sp21 su21 fa21 sp22 su22 fa22 sp23 su23 fa23 sp24".split(" ")
|
||||
# sems = {'sp23':'202330','su23':'202350','fa23':'202370'}
|
||||
sems = { x:'20' + x[2:] + seasons[x[:2]] for x in semcodes }
|
||||
sem_dfs = []
|
||||
sem_dfs_depts = []
|
||||
for s in sems.keys():
|
||||
sched = requests.get(f"http://gavilan.cc/schedule/{s}_sched_expanded.json").json()
|
||||
for crs in sched:
|
||||
if 'extra' in crs: del crs['extra']
|
||||
crs['dept'] = crs['code'].split(' ')[0]
|
||||
df = pd.DataFrame(sched)
|
||||
df_depts = df.copy()
|
||||
df_depts = df_depts.drop(columns=['crn','sec','code','cmp','name','days','time','rem','wl_cap','wl_act','wl_rem','teacher','date','loc','ztc','time_start','time_end','start','end','doy'])
|
||||
df = df.drop(columns=['crn','sec','code','cmp','name','days','time','rem','wl_cap','wl_act','wl_rem','teacher','date','loc','ztc','time_start','time_end','start','end','doy'])
|
||||
dept_counts = grouped_by_dept = df_depts.groupby(['dept','type']).size().reset_index(name='count')
|
||||
grouped_by_mode = df['type'].value_counts().reset_index()
|
||||
grouped_by_dept["semester"] = sems[s]
|
||||
grouped_by_mode["semester"] = sems[s]
|
||||
#print(dept_counts)
|
||||
sem_dfs.append(grouped_by_mode)
|
||||
sem_dfs_depts.append(grouped_by_dept)
|
||||
|
||||
#grouped_json = grouped_by_dept.to_json(orient='records')
|
||||
#j = json.loads(grouped_json)
|
||||
#print(json.dumps(j,indent=2))
|
||||
|
||||
#grouped_by_dept.columns = ['Department', 'Count'] # rename the column names appropriately
|
||||
#fig = px.bar(grouped_by_dept, x='Department', y='Count', title='Section Counts by Department')
|
||||
#fig.write_html(f"cache/output_{s}.html")
|
||||
|
||||
|
||||
combined_data = pd.concat(sem_dfs, axis=0)
|
||||
combined_data = combined_data.rename(columns={'type':'count','index':'type'})
|
||||
combined_data.reset_index(drop=True,inplace=True)
|
||||
pivoted_data = combined_data.pivot(index='semester', columns='type', values='count')
|
||||
pivoted_data.reset_index(inplace=True)
|
||||
|
||||
fig = px.bar(pivoted_data, x='semester',y=['hybrid', 'in-person', 'online', 'online live'], barmode='stack',
|
||||
title='Course Delivery by Semester',
|
||||
color_discrete_sequence=["#000066","#660000","#333366","#9400D3"])
|
||||
fig.write_html(f"cache/sections_by_deliverymode.html")
|
||||
|
||||
|
||||
combined_data_depts = pd.concat(sem_dfs_depts, axis=0)
|
||||
combined_data_depts.reset_index(drop=True,inplace=True)
|
||||
#print(combined_data_depts)
|
||||
combined_data_depts.to_csv('cache/section_delivery_by_dept.csv')
|
||||
'''pivoted_data_depts = combined_data_depts.pivot(index='semester', columns='type', values='count')
|
||||
pivoted_data_depts.reset_index(inplace=True)
|
||||
|
||||
fig = px.bar(pivoted_data_depts, x='semester',y=['hybrid', 'in-person', 'online', 'online live'], barmode='stack',
|
||||
title='Course Delivery by Semester',
|
||||
color_discrete_sequence=["#000066","#660000","#333366","#9400D3"])
|
||||
fig.write_html(f"cache/sections_depts_by_deliverymode.html")'''
|
||||
|
||||
unique_depts = combined_data_depts['dept'].unique()
|
||||
fig = make_subplots(rows=len(unique_depts), cols=1,
|
||||
subplot_titles=unique_depts,
|
||||
)
|
||||
for i, dept in enumerate(unique_depts, start=1):
|
||||
#if i>1: break
|
||||
# Filter the dataframe for the current department
|
||||
dept_data = combined_data_depts[combined_data_depts['dept'] == dept]
|
||||
|
||||
# Pivot the data frame
|
||||
pivoted_dept_data = dept_data.pivot(index='semester', columns='type', values='count').reset_index()
|
||||
pivoted_dept_data.fillna(0,inplace=True)
|
||||
print(pivoted_dept_data)
|
||||
|
||||
# Plot the data
|
||||
columns_to_plot = ['hybrid', 'in-person', 'online', 'online live']
|
||||
valid_columns = [col for col in columns_to_plot if col in pivoted_dept_data.columns]
|
||||
fig_sub = px.bar(pivoted_dept_data, x='semester', y=valid_columns, barmode='stack',
|
||||
#title=f'Course Delivery by Semester for {dept}',
|
||||
color_discrete_sequence=["#000066","#660000","#333366","#9400D3"])
|
||||
fig.add_traces(fig_sub['data'], rows=[i]*len(fig_sub['data']), cols=[1]*len(fig_sub['data']))
|
||||
fig.update_layout(height=70*len(fig['data']), width=1100, showlegend=False)
|
||||
fig.write_html(f"cache/sections_depts_by_deliverymode.html")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
options = { 1: ['get all historical grades from ilearn',get_all] ,
|
||||
2: ['process grades csv file',process_grades] ,
|
||||
|
|
@ -1212,6 +1302,7 @@ if __name__ == "__main__":
|
|||
15: ['student courses by semester', student_by_semester],
|
||||
16: ['LSTM model sections', lstm_model_sections],
|
||||
17: ['rearrange section data to yearly form', sections_grouped_by_year_mode],
|
||||
30: ['visualize course modes multi semester', visualize_course_modes_multi_semester],
|
||||
}
|
||||
print ('')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue