Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: import course dashboard v1 #710

Merged
merged 7 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
"ASPECTS_INSTRUCTOR_DASHBOARDS",
[
{
"name": "Instructor Dashboard",
"slug": "instructor-dashboard",
"uuid": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286",
"name": "Course Dashboard",
"slug": "course-dashboard-v1",
"uuid": "c0e64194-33d1-4d5a-8c10-4f51530c5ee9",
},
{
"name": "Learner Groups Dashboard",
Expand All @@ -102,7 +102,7 @@
(
"SUPERSET_EMBEDDABLE_DASHBOARDS",
{
"instructor-dashboard": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286",
"course-dashboard-v1": "c0e64194-33d1-4d5a-8c10-4f51530c5ee9",
"learner-groups": "8661d20c-cee6-4245-9fcc-610daea5fd24",
"individual-learner": "abae8a25-1ba4-4653-81bd-d3937a162a11",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def performance_metrics():
logger.info(f"Dashboard: {dashboard.slug}")
for slice in dashboard.slices:
result = measure_chart(slice)
if not result:
continue
for query in result["queries"]:
# Remove the data from the query to avoid memory issues on large datasets.
query.pop("data")
Expand Down Expand Up @@ -87,7 +89,11 @@ def measure_chart(slice, extra_filters=[]):
command = ChartDataCommand(query_context)

start_time = datetime.now()
result = command.run()
try:
result = command.run()
except Exception as e:
logger.error(f"Error fetching slice data: {slice}. Error: {e}")
return
end_time = datetime.now()

result["time_elapsed"] = (end_time - start_time).total_seconds()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
_file_name: Course_Information.yaml
cache_timeout: null
certification_details: null
certified_by: null
dataset_uuid: 633a1d4e-cd40-482f-a5dc-d5901c2181c2
description: null
params:
adhoc_filters: []
all_columns: []
annotation_layers: []
color_pn: true
conditional_formatting:
- colorScheme: '#ACE1C4'
column: Graded Learners
operator: '>'
targetValue: 0
- colorScheme: '#FDE380'
column: Avg Course Grade
operator: "\u2264 x \u2264"
targetValueLeft: '0.5'
targetValueRight: '0.7'
- colorScheme: '#EFA1AA'
column: Avg Course Grade
operator: <
targetValue: 0.5
- colorScheme: '#ACE1C4'
column: Avg Course Grade
operator: "\u2265"
targetValue: 0.7
- colorScheme: '#ACE1C4'
column: Median Course Grade
operator: "\u2265"
targetValue: 0.7
- colorScheme: '#FDE380'
column: Median Course Grade
operator: "\u2264 x \u2264"
targetValueLeft: '0.5'
targetValueRight: '0.7'
- colorScheme: '#EFA1AA'
column: Median Course Grade
operator: <
targetValue: 0.5
extra_form_data: {}
groupby:
- org
- course_key
- course_name
- course_run
metrics:
- aggregate: COUNT_DISTINCT
column:
advanced_data_type: null
certification_details: null
certified_by: null
column_name: actor_id
description: null
expression: null
filterable: true
groupby: true
id: 457
is_certified: false
is_dttm: false
python_date_format: null
type: STRING
type_generic: 1
verbose_name: null
warning_markdown: null
datasourceWarning: false
expressionType: SIMPLE
hasCustomLabel: true
label: Graded Learners
optionName: metric_25t7qgbwxu5_a9fbiaboytw
sqlExpression: null
- aggregate: AVG
column:
advanced_data_type: null
certification_details: null
certified_by: null
column_name: course_grade
description: null
expression: null
filterable: true
groupby: true
id: 461
is_certified: false
is_dttm: false
python_date_format: null
type: FLOAT64
type_generic: 0
verbose_name: null
warning_markdown: null
datasourceWarning: false
expressionType: SIMPLE
hasCustomLabel: true
label: Avg Course Grade
optionName: metric_i5mlkxng7kb_5auir2yzvnx
sqlExpression: null
- aggregate: null
column: null
datasourceWarning: false
expressionType: SQL
hasCustomLabel: true
label: Median Course Grade
optionName: metric_prd604bf33n_j3zxzos2g5
sqlExpression: 'quantile(0.5)(course_grade) '
order_by_cols: []
order_desc: true
percent_metrics: []
query_mode: aggregate
row_limit: 1000
server_page_length: 10
show_cell_bars: true
table_timestamp_format: smart_date
temporal_columns_lookup: {}
time_grain_sqla: P1D
viz_type: table
query_context: "{\"datasource\":{\"id\":70,\"type\":\"table\"},\"force\":false,\"\
queries\":[{\"filters\":[],\"extras\":{\"time_grain_sqla\":\"P1D\",\"having\":\"\
\",\"where\":\"\"},\"applied_time_extras\":{},\"columns\":[\"org\",\"course_key\"\
,\"course_name\",\"course_run\"],\"metrics\":[{\"aggregate\":\"COUNT_DISTINCT\"\
,\"column\":{\"advanced_data_type\":null,\"certification_details\":null,\"certified_by\"\
:null,\"column_name\":\"actor_id\",\"description\":null,\"expression\":null,\"filterable\"\
:true,\"groupby\":true,\"id\":457,\"is_certified\":false,\"is_dttm\":false,\"python_date_format\"\
:null,\"type\":\"STRING\",\"type_generic\":1,\"verbose_name\":null,\"warning_markdown\"\
:null},\"datasourceWarning\":false,\"expressionType\":\"SIMPLE\",\"hasCustomLabel\"\
:true,\"label\":\"Graded Learners\",\"optionName\":\"metric_25t7qgbwxu5_a9fbiaboytw\"\
,\"sqlExpression\":null},{\"aggregate\":\"AVG\",\"column\":{\"advanced_data_type\"\
:null,\"certification_details\":null,\"certified_by\":null,\"column_name\":\"course_grade\"\
,\"description\":null,\"expression\":null,\"filterable\":true,\"groupby\":true,\"\
id\":461,\"is_certified\":false,\"is_dttm\":false,\"python_date_format\":null,\"\
type\":\"FLOAT64\",\"type_generic\":0,\"verbose_name\":null,\"warning_markdown\"\
:null},\"datasourceWarning\":false,\"expressionType\":\"SIMPLE\",\"hasCustomLabel\"\
:true,\"label\":\"Avg Course Grade\",\"optionName\":\"metric_i5mlkxng7kb_5auir2yzvnx\"\
,\"sqlExpression\":null},{\"aggregate\":null,\"column\":null,\"datasourceWarning\"\
:false,\"expressionType\":\"SQL\",\"hasCustomLabel\":true,\"label\":\"Median Course\
\ Grade\",\"optionName\":\"metric_prd604bf33n_j3zxzos2g5\",\"sqlExpression\":\"\
quantile(0.5)(course_grade) \"}],\"orderby\":[[{\"aggregate\":\"COUNT_DISTINCT\"\
,\"column\":{\"advanced_data_type\":null,\"certification_details\":null,\"certified_by\"\
:null,\"column_name\":\"actor_id\",\"description\":null,\"expression\":null,\"filterable\"\
:true,\"groupby\":true,\"id\":457,\"is_certified\":false,\"is_dttm\":false,\"python_date_format\"\
:null,\"type\":\"STRING\",\"type_generic\":1,\"verbose_name\":null,\"warning_markdown\"\
:null},\"datasourceWarning\":false,\"expressionType\":\"SIMPLE\",\"hasCustomLabel\"\
:true,\"label\":\"Graded Learners\",\"optionName\":\"metric_25t7qgbwxu5_a9fbiaboytw\"\
,\"sqlExpression\":null},false]],\"annotation_layers\":[],\"row_limit\":1000,\"\
series_limit\":0,\"order_desc\":true,\"url_params\":{},\"custom_params\":{},\"custom_form_data\"\
:{},\"post_processing\":[]}],\"form_data\":{\"datasource\":\"70__table\",\"viz_type\"\
:\"table\",\"slice_id\":186,\"query_mode\":\"aggregate\",\"groupby\":[\"org\",\"\
course_key\",\"course_name\",\"course_run\"],\"time_grain_sqla\":\"P1D\",\"temporal_columns_lookup\"\
:{},\"metrics\":[{\"aggregate\":\"COUNT_DISTINCT\",\"column\":{\"advanced_data_type\"\
:null,\"certification_details\":null,\"certified_by\":null,\"column_name\":\"actor_id\"\
,\"description\":null,\"expression\":null,\"filterable\":true,\"groupby\":true,\"\
id\":457,\"is_certified\":false,\"is_dttm\":false,\"python_date_format\":null,\"\
type\":\"STRING\",\"type_generic\":1,\"verbose_name\":null,\"warning_markdown\"\
:null},\"datasourceWarning\":false,\"expressionType\":\"SIMPLE\",\"hasCustomLabel\"\
:true,\"label\":\"Graded Learners\",\"optionName\":\"metric_25t7qgbwxu5_a9fbiaboytw\"\
,\"sqlExpression\":null},{\"aggregate\":\"AVG\",\"column\":{\"advanced_data_type\"\
:null,\"certification_details\":null,\"certified_by\":null,\"column_name\":\"course_grade\"\
,\"description\":null,\"expression\":null,\"filterable\":true,\"groupby\":true,\"\
id\":461,\"is_certified\":false,\"is_dttm\":false,\"python_date_format\":null,\"\
type\":\"FLOAT64\",\"type_generic\":0,\"verbose_name\":null,\"warning_markdown\"\
:null},\"datasourceWarning\":false,\"expressionType\":\"SIMPLE\",\"hasCustomLabel\"\
:true,\"label\":\"Avg Course Grade\",\"optionName\":\"metric_i5mlkxng7kb_5auir2yzvnx\"\
,\"sqlExpression\":null},{\"aggregate\":null,\"column\":null,\"datasourceWarning\"\
:false,\"expressionType\":\"SQL\",\"hasCustomLabel\":true,\"label\":\"Median Course\
\ Grade\",\"optionName\":\"metric_prd604bf33n_j3zxzos2g5\",\"sqlExpression\":\"\
quantile(0.5)(course_grade) \"}],\"all_columns\":[],\"percent_metrics\":[],\"adhoc_filters\"\
:[],\"order_by_cols\":[],\"row_limit\":1000,\"server_page_length\":10,\"order_desc\"\
:true,\"table_timestamp_format\":\"smart_date\",\"show_cell_bars\":true,\"color_pn\"\
:true,\"conditional_formatting\":[{\"colorScheme\":\"#ACE1C4\",\"column\":\"Graded\
\ Learners\",\"operator\":\">\",\"targetValue\":0},{\"colorScheme\":\"#FDE380\"\
,\"column\":\"Avg Course Grade\",\"operator\":\"\u2264 x \u2264\",\"targetValueLeft\"\
:\"0.5\",\"targetValueRight\":\"0.7\"},{\"colorScheme\":\"#EFA1AA\",\"column\":\"\
Avg Course Grade\",\"operator\":\"<\",\"targetValue\":0.5},{\"colorScheme\":\"#ACE1C4\"\
,\"column\":\"Avg Course Grade\",\"operator\":\"\u2265\",\"targetValue\":0.7},{\"\
colorScheme\":\"#ACE1C4\",\"column\":\"Median Course Grade\",\"operator\":\"\u2265\
\",\"targetValue\":0.7},{\"colorScheme\":\"#FDE380\",\"column\":\"Median Course\
\ Grade\",\"operator\":\"\u2264 x \u2264\",\"targetValueLeft\":\"0.5\",\"targetValueRight\"\
:\"0.7\"},{\"colorScheme\":\"#EFA1AA\",\"column\":\"Median Course Grade\",\"operator\"\
:\"<\",\"targetValue\":0.5}],\"extra_form_data\":{},\"dashboards\":[16],\"force\"\
:false,\"result_format\":\"json\",\"result_type\":\"full\"},\"result_format\":\"\
json\",\"result_type\":\"full\"}"
slice_name: Course Information
uuid: fa249dda-78da-4ccc-9ef3-39177e6aae0c
version: 1.0.0
viz_type: table
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
_file_name: Cumulative_Enrollments_by_Track.yaml
cache_timeout: null
certification_details: null
certified_by: null
dataset_uuid: a234545d-08ff-480d-8361-961c3d15f14f
description: null
params:
adhoc_filters:
- clause: WHERE
comparator: No filter
datasourceWarning: false
expressionType: SIMPLE
filterOptionName: filter_utjjqw9427d_5p5ur7mob2
isExtra: false
isNew: false
operator: TEMPORAL_RANGE
sqlExpression: null
subject: emission_time
annotation_layers: []
color_scheme: supersetColors
comparison_type: values
extra_form_data: {}
forecastInterval: 0.8
forecastPeriods: 10
groupby:
- enrollment_mode
legendMargin: null
legendOrientation: top
legendType: scroll
markerEnabled: true
markerSize: 6
metrics:
- aggregate: COUNT_DISTINCT
column:
advanced_data_type: null
certification_details: null
certified_by: null
column_name: actor_id
description: null
expression: null
filterable: true
groupby: true
id: 138
is_certified: false
is_dttm: false
python_date_format: null
type: String
type_generic: 1
verbose_name: null
warning_markdown: null
datasourceWarning: false
expressionType: SIMPLE
hasCustomLabel: true
label: Number of Learners
optionName: metric_tpdu0kpjpka_gsgo2so3eld
sqlExpression: null
only_total: true
opacity: 0.2
order_desc: true
rich_tooltip: true
rolling_type: cumsum
row_limit: 10000
seriesType: line
show_empty_columns: true
show_extra_controls: false
show_legend: true
show_value: false
sort_series_type: sum
time_grain_sqla: P1M
tooltipTimeFormat: smart_date
truncate_metric: true
viz_type: echarts_area
x_axis: emission_time
x_axis_sort_asc: true
x_axis_sort_series: name
x_axis_sort_series_ascending: true
x_axis_time_format: smart_date
x_axis_title_margin: 15
y_axis_bounds:
- null
- null
y_axis_format: ~g
y_axis_title_margin: 15
y_axis_title_position: Left
zoomable: true
query_context: '{"datasource":{"id":12,"type":"table"},"force":false,"queries":[{"filters":[{"col":"emission_time","op":"TEMPORAL_RANGE","val":"No
filter"}],"extras":{"having":"","where":""},"applied_time_extras":{},"columns":[{"timeGrain":"P1M","columnType":"BASE_AXIS","sqlExpression":"emission_time","label":"emission_time","expressionType":"SQL"},"enrollment_mode"],"metrics":[{"aggregate":"COUNT_DISTINCT","column":{"advanced_data_type":null,"certification_details":null,"certified_by":null,"column_name":"actor_id","description":null,"expression":null,"filterable":true,"groupby":true,"id":138,"is_certified":false,"is_dttm":false,"python_date_format":null,"type":"String","type_generic":1,"verbose_name":null,"warning_markdown":null},"datasourceWarning":false,"expressionType":"SIMPLE","hasCustomLabel":true,"label":"Number
of Learners","optionName":"metric_tpdu0kpjpka_gsgo2so3eld","sqlExpression":null}],"orderby":[[{"aggregate":"COUNT_DISTINCT","column":{"advanced_data_type":null,"certification_details":null,"certified_by":null,"column_name":"actor_id","description":null,"expression":null,"filterable":true,"groupby":true,"id":138,"is_certified":false,"is_dttm":false,"python_date_format":null,"type":"String","type_generic":1,"verbose_name":null,"warning_markdown":null},"datasourceWarning":false,"expressionType":"SIMPLE","hasCustomLabel":true,"label":"Number
of Learners","optionName":"metric_tpdu0kpjpka_gsgo2so3eld","sqlExpression":null},false]],"annotation_layers":[],"row_limit":10000,"series_columns":["enrollment_mode"],"series_limit":0,"order_desc":true,"url_params":{},"custom_params":{},"custom_form_data":{},"time_offsets":[],"post_processing":[{"operation":"pivot","options":{"index":["emission_time"],"columns":["enrollment_mode"],"aggregates":{"Number
of Learners":{"operator":"mean"}},"drop_missing_columns":false}},{"operation":"cum","options":{"operator":"sum","columns":{"Number
of Learners":"Number of Learners"}}},{"operation":"rename","options":{"columns":{"Number
of Learners":null},"level":0,"inplace":true}},{"operation":"flatten"}]}],"form_data":{"datasource":"12__table","viz_type":"echarts_area","slice_id":189,"x_axis":"emission_time","time_grain_sqla":"P1M","x_axis_sort_asc":true,"x_axis_sort_series":"name","x_axis_sort_series_ascending":true,"metrics":[{"aggregate":"COUNT_DISTINCT","column":{"advanced_data_type":null,"certification_details":null,"certified_by":null,"column_name":"actor_id","description":null,"expression":null,"filterable":true,"groupby":true,"id":138,"is_certified":false,"is_dttm":false,"python_date_format":null,"type":"String","type_generic":1,"verbose_name":null,"warning_markdown":null},"datasourceWarning":false,"expressionType":"SIMPLE","hasCustomLabel":true,"label":"Number
of Learners","optionName":"metric_tpdu0kpjpka_gsgo2so3eld","sqlExpression":null}],"groupby":["enrollment_mode"],"adhoc_filters":[{"expressionType":"SIMPLE","subject":"emission_time","operator":"TEMPORAL_RANGE","comparator":"No
filter","clause":"WHERE","sqlExpression":null,"isExtra":false,"isNew":false,"datasourceWarning":false,"filterOptionName":"filter_utjjqw9427d_5p5ur7mob2"}],"order_desc":true,"row_limit":10000,"truncate_metric":true,"show_empty_columns":true,"rolling_type":"cumsum","comparison_type":"values","annotation_layers":[],"forecastPeriods":10,"forecastInterval":0.8,"x_axis_title_margin":15,"y_axis_title_margin":15,"y_axis_title_position":"Left","sort_series_type":"sum","color_scheme":"supersetColors","seriesType":"line","opacity":0.2,"show_value":false,"only_total":true,"show_extra_controls":false,"markerEnabled":true,"markerSize":6,"zoomable":true,"show_legend":true,"legendType":"scroll","legendOrientation":"top","legendMargin":null,"x_axis_time_format":"smart_date","rich_tooltip":true,"tooltipTimeFormat":"smart_date","y_axis_format":"~g","y_axis_bounds":[null,null],"extra_form_data":{},"dashboards":[16],"force":false,"result_format":"json","result_type":"full"},"result_format":"json","result_type":"full"}'
slice_name: Cumulative Enrollments by Track
uuid: f207c896-030a-462b-b69f-6416230d50b6
version: 1.0.0
viz_type: echarts_area
Loading