Skip to content

Commit

Permalink
a working slider
Browse files Browse the repository at this point in the history
  • Loading branch information
parmentelat committed Dec 11, 2017
1 parent c1f1e14 commit 7bd292a
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 205 deletions.
1 change: 0 additions & 1 deletion nbhosting/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
url(r'^nbh/stats/daily_metrics/(?P<course>[\w_.-]+)', nbhosting.stats.views.send_daily_metrics),
url(r'^nbh/stats/monitor_counts/(?P<course>[\w_.-]+)', nbhosting.stats.views.send_monitor_counts),
url(r'^nbh/stats/material_usage/(?P<course>[\w_.-]+)', nbhosting.stats.views.send_material_usage),
url(r'^nbh/stats/animated_attendance/(?P<course>[\w_.-]+)', nbhosting.stats.views.send_animated_attendance),
url(r'^nbh/stats/(?P<course>[\w_.-]+)', nbhosting.stats.views.show_stats),
url(r'^nbh', nbhosting.main.views.welcome),
]
21 changes: 3 additions & 18 deletions nbhosting/stats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def _write_events_line(self, student, notebook, action, port):
try:
with path.open("a") as f:
f.write("{timestamp} {course} {student} {notebook} {action} {port}\n".
format(timestamp=timestamp, course=course, notebook=notebook,
action=action, port=port))
format(timestamp=timestamp, course=course, student=student,
notebook=notebook, action=action, port=port))
except Exception as e:
logger.exception("Cannot store stats line into {}".format(path))

Expand Down Expand Up @@ -322,7 +322,7 @@ def monitor_counts(self):
# and should all contain integers
if len(values) > max_counts:
logger.error("{}:{}: counts line has too many fields - {} > {}"
.format(counts_path, lineno, len(values),max_counts))
.format(counts_path, lineno, len(values), max_counts))
continue
ivalues = [int(v) for v in values]
for count, ivalue in zip(known_counts, ivalues):
Expand Down Expand Up @@ -438,21 +438,6 @@ def material_usage(self):
},
}


def animated_attendance(self):
return dict(
notebooks = [ 'x1', 'x2', 'x3'],
timestamps = ['2010', '2011', '2012', '2013', '2014',],
attendance = [
[0, 0, 0],
[10, 0, 0],
[12, 2 ,0],
[15, 5, 2],
[20, 8, 3],
],
)


if __name__ == '__main__':
import sys
course = 'fp' if len(sys.argv) == 1 else sys.argv[1]
Expand Down
35 changes: 14 additions & 21 deletions nbhosting/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ def show_stats(request, course):
title = 'Progression',
id = 'PROGRESSION',
subsections = [
{ 'plotly_name' : 'plotly-nbstudents-per-notebook',
{ 'div_id' : 'plotly-nbstudents-per-notebook',
'title' : 'Students per notebook',
'hide' : True,
},
{ 'plotly_name' : 'plotly-nbstudents-per-notebook-animated',
'title' : 'Students per notebook (animated)',
'hide' : True,
{ 'div_id' : 'd3-nb-students-per-notebook',
'title' : 'Students per notebook - animation',
'engine': 'd3',
# 'hide' : True,
},
{ 'plotly_name' : 'plotly-nbstudents-per-nbnotebooks',
{ 'div_id' : 'plotly-nbstudents-per-nbnotebooks',
'title' : 'Number of notebooks per student',
'hide' : True,
},
{ 'plotly_name' : 'plotly-students',
{ 'div_id' : 'plotly-students',
'title' : 'Students who showed up at least once',
'hide' : True,
},
{ 'plotly_name' : 'plotly-notebooks',
{ 'div_id' : 'plotly-notebooks',
'title' : 'Notebooks read at least once',
'hide' : True,
},
Expand All @@ -45,21 +46,18 @@ def show_stats(request, course):
title = 'Details',
id = 'DETAILS',
subsections = [
{ 'plotly_name' : 'plotly-heatmap',
{ 'div_id' : 'plotly-heatmap',
'title' : 'Complete map',
'hide' : True,
},
# { 'plotly_name' : 'd3-nb-students-per-notebook',
# 'title' : 'Animated students per notebook',
# },
]
))

sections.append(dict(
title = 'Activity',
id = 'ACTIVITY',
subsections = [
{ 'plotly_name' : 'plotly-containers-kernels',
{ 'div_id' : 'plotly-containers-kernels',
'title' : 'Jupyter containers and kernels',
'hide' : True,
},
Expand All @@ -69,15 +67,15 @@ def show_stats(request, course):
title = 'System',
id = 'SYSTEM',
subsections = [
{ 'plotly_name' : 'plotly-ds-percent',
{ 'div_id' : 'plotly-ds-percent',
'title' : 'Free Disk Space %',
'hide' : True,
},
{ 'plotly_name' : 'plotly-ds-free',
{ 'div_id' : 'plotly-ds-free',
'title' : 'Free Disk Space in Bytes',
'hide' : True,
},
{ 'plotly_name' : 'plotly-cpu-load',
{ 'div_id' : 'plotly-cpu-load',
'title' : 'CPU loads',
'hide' : True,
},
Expand All @@ -87,6 +85,7 @@ def show_stats(request, course):
# set 'hide' to False by default
for section in sections:
for subsection in section['subsections']:
subsection.setdefault('engine', 'plotly')
subsection.setdefault('hide', False)

env = dict(course=course, sections=sections)
Expand All @@ -113,9 +112,3 @@ def send_material_usage(request, course):
encoded = json.dumps(stats.material_usage())
return HttpResponse(encoded, content_type = "application/json")

@csrf_protect
def send_animated_attendance(request, course):
stats = Stats(course)
encoded = json.dumps(stats.animated_attendance())
return HttpResponse(encoded, content_type = "application/json")

Loading

0 comments on commit 7bd292a

Please sign in to comment.