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

✨(dashboard) add courses and statements dashboards #14

Merged
merged 1 commit into from
Jul 16, 2021
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
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ jobs:
command: make build
- run:
name: Format sources
command: bin/jsonnetfmt --test $(find src/ -type f -name '*.jsonnet')
command: |
bin/jsonnetfmt --test $(find src/ -type f -name '*.jsonnet') $(find src/ -type f -name '*.libsonnet')
- run:
name: Lint sources
command: make lint
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to

### Added

- Video course and statements Dashboards
- Video details dashboard new panel: video events distribution along the video
timeline
- Course video events distribution panel in details Dashboard
Expand Down
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)
jmaupetit marked this conversation as resolved.
Show resolved Hide resolved
.PHONY: format

lint: ## lint Jsonnet sources
bin/jsonnet-lint $(sources)
lint: ## lint Jsonnet sources and libraries
bin/jsonnet-lint $(sources) $(libraries)
jmaupetit marked this conversation as resolved.
Show resolved Hide resolved
.PHONY: lint

logs: ## display grafana logs (follow mode)
Expand Down
6 changes: 5 additions & 1 deletion bin/jsonnet-lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ 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\//}"

# FIXME: once PR https://github.com/google/go-jsonnet/pull/548 is merged,
# there will be no need for this loop.
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;

{
constants: {
lrs: 'lrs',
verb_id_completed: 'http://adlnet.gov/expapi/verbs/completed',
verb_id_played: 'https://w3id.org/xapi/video/verbs/played',
},
fields: {
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',
},
utils: {
double_escape_string(x):: std.strReplace(std.strReplace(x, ':', '\\\\:'), '/', '\\\\/'),
single_escape_string(x):: std.strReplace(std.strReplace(x, ':', '\\:'), '/', '\\/'),
},
objects: {
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',
},
},
},
queries: {
school_course_session: '%(school)s:$SCHOOL AND %(course)s:$COURSE AND %(session)s:$SESSION' % {
school: $.utils.single_escape_string($.fields.school),
course: $.utils.single_escape_string($.fields.course),
session: $.utils.single_escape_string($.fields.session),
},
},
templates: {
course: template.new(
name='COURSE',
current='all',
label='Course',
datasource=$.constants.lrs,
query='{"find": "terms", "field": "%(course)s", "query": "%(school)s:$SCHOOL"}' % {
course: $.fields.course,
school: $.utils.double_escape_string($.fields.school),
},
refresh='time'
),
school: template.new(
name='SCHOOL',
current='all',
label='School',
datasource=$.constants.lrs,
query='{"find": "terms", "field": "%(school)s"}' % { school: $.fields.school },
refresh='time'
),
session: template.new(
name='SESSION',
current='all',
label='Session',
datasource=$.constants.lrs,
query='{"find": "terms", "field": "%(session)s", "query": "%(course)s:$COURSE"}' % {
session: $.fields.session,
course: $.utils.double_escape_string($.fields.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'
),
},
}
Loading