Skip to content

Commit

Permalink
✨(dashboard) add courses and statements dashboards
Browse files Browse the repository at this point in the history
We display course related statistics in a dedicated dashboards.
  • Loading branch information
SergioSim committed Jun 30, 2021
1 parent 3d4a791 commit b54bb5b
Show file tree
Hide file tree
Showing 5 changed files with 631 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ WAIT_GRAFANA = $(COMPOSE_RUN) dockerize -wait http://grafana:3000 -timeo

# -- Targets
sources := $(shell find src/ -type f -name '*.jsonnet')
libraries := $(shell find src/ -type f -name '*.libsonnet')
targets := $(patsubst src/%.jsonnet,var/lib/grafana/%.json,$(sources))

# -- Plugins
Expand Down Expand Up @@ -73,12 +74,12 @@ down: ## remove stack (warning: it removes the database container)
@$(COMPOSE) down || echo WARNING: unable to remove the stack. Try to stop linked containers or networks first.
.PHONY: down

format: ## format Jsonnet sources
bin/jsonnetfmt -i $(sources)
format: ## format Jsonnet sources and libraries
bin/jsonnetfmt -i $(sources) $(libraries)
.PHONY: format

lint: ## lint Jsonnet sources
bin/jsonnet-lint $(sources)
lint: ## lint Jsonnet sources and libraries
bin/jsonnet-lint $(sources) $(libraries)
.PHONY: lint

logs: ## display grafana logs (follow mode)
Expand Down
3 changes: 2 additions & 1 deletion bin/jsonnet-lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ DOCKER_USER="$(id -u):$(id -g)"
# the dashboard directory is mounted in the container working directory, e.g.
# src/dashboards is mounted in /app/dashboards (with /app as the working
# directory).
DOCKER_USER=${DOCKER_USER} docker-compose run --rm app jsonnet-lint "${@//src\//}"
COMMAND="for file_name in ${@//src\//}; do jsonnet-lint \$file_name ; done"
DOCKER_USER=${DOCKER_USER} docker-compose run --rm app /bin/sh -c "$COMMAND"
90 changes: 90 additions & 0 deletions src/dashboards/videos/common.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
local grafana = import 'grafonnet/grafana.libsonnet';
local template = grafana.template;

{
field: {
actor_account_name: 'actor.account.name.keyword',
context_extensions_completion_threshold: 'context.extensions.https://w3id.org/xapi/video/extensions/completion-threshold',
course: 'object.definition.extensions.http://adlnet.gov/expapi/activities/course.keyword',
result_extensions_length: 'result.extensions.https://w3id.org/xapi/video/extensions/length',
result_extensions_time: 'result.extensions.https://w3id.org/xapi/video/extensions/time',
school: 'object.definition.extensions.https://w3id.org/xapi/acrossx/extensions/school.keyword',
session: 'object.definition.extensions.http://adlnet.gov/expapi/activities/module.keyword',
video_id: 'object.id.keyword',
},
lrs: 'lrs',
method: {
double_escape_string(x):: std.strReplace(std.strReplace(x, ':', '\\\\:'), '/', '\\\\/'),
single_escape_string(x):: std.strReplace(std.strReplace(x, ':', '\\:'), '/', '\\/'),
},
object: {
count_metric: { id: '1', type: 'count' },
date_histogram(interval='auto', min_doc_count='1'):: {
id: 'date',
field: 'timestamp',
type: 'date_histogram',
settings: {
interval: interval,
min_doc_count: min_doc_count,
trimEdges: '0',
},
},
},
query: {
school_course_session: '%(school)s:$SCHOOL AND %(course)s:$COURSE AND %(session)s:$SESSION' % {
school: $.method.single_escape_string($.field.school),
course: $.method.single_escape_string($.field.course),
session: $.method.single_escape_string($.field.session),
},
},
template: {
course: template.new(
name='COURSE',
current='all',
label='Course',
datasource=$.lrs,
query='{"find": "terms", "field": "%(course)s", "query": "%(school)s:$SCHOOL"}' % {
course: $.field.course,
school: $.method.double_escape_string($.field.school),
},
refresh='time'
),
school: template.new(
name='SCHOOL',
current='all',
label='School',
datasource=$.lrs,
query='{"find": "terms", "field": "%(school)s"}' % { school: $.field.school },
refresh='time'
),
session: template.new(
name='SESSION',
current='all',
label='Session',
datasource=$.lrs,
query='{"find": "terms", "field": "%(session)s", "query": "%(course)s:$COURSE"}' % {
session: $.field.session,
course: $.method.double_escape_string($.field.course),
},
refresh='time'
),
statements_interval: template.custom(
name='STATEMENTS_INTERVAL',
current='7d',
label='Statements interval',
query='1d,7d,14d,21d,28d',
refresh='time'
),
view_count_threshold: template.custom(
name='VIEW_COUNT_THRESHOLD',
current='30',
label='View count threshold',
query='0,10,20,30,40,50,60',
refresh='time'
),
},
value: {
verb_id_completed: 'http://adlnet.gov/expapi/verbs/completed',
verb_id_played: 'https://w3id.org/xapi/video/verbs/played',
},
}
Loading

0 comments on commit b54bb5b

Please sign in to comment.