This platform is operated by The Norwegian Directorate of Education's Department for Digital Services, which is responsible for managing a number of national digital solutions that support education and skills development.
KPAS provides competency packages across various themes to enhance skills and practices in kindergartens, schools, the Educational Psychological Service (PPT), training companies, and examination boards. The platform is designed to support collaborative and long-term professional development with embedded process and leadership support.
A Python Django application that provides HTTP endpoints for statistical aggregations related to courses and groups on Canvas LMS. It runs scheduled tasks to periodically pull data from the Canvas LMS REST APIs into a MySQL database, supporting dynamic data analysis and reporting.
Services
Service | Environment | URL |
---|---|---|
Statistics API | Production | https://statistics-api.azurewebsites.net/ |
Statistics API | Stage | https://statistics-api-staging.azurewebsites.net/ |
Related Codebases
Name | Description |
---|---|
Frontend | Custom frontend for Canvas LMS |
KPAS API | Extends Canvas LMS through LTI tools and REST endpoints |
Quick links
- Git: A free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
- Visual Studio Code: A lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux.
- Docker: A tool for developing, shipping, and running applications inside lightweight, portable containers.
- Docker Compose: A tool for defining and running multi-container Docker applications.
- Open up
docker-compose.yml
and fill out:CANVAS_ACCESS_KEY
It's advisable to directly import a database dump from the stage environment. Using the CLI method, which involves executing multiple API requests to populate the database, can be inefficient and time-consuming.
Alternatively, you can directly utilize the stage database by updating all variables prefixed with DB_
in the .env
file.
- Start up the application:
docker compose up --build
- Log into the docker container:
docker exec -it kpas_stats_app bash
- To populatet the db run
python manage.py <name of command>
Name | Description |
---|---|
import_county_teacher_counts_from_csv | This command will populate the db with high school teacher counts for each county. This statistics is found in a csv file located in the data folder. This file needs to be updated yearly. |
import_school_teacher_counts_from_csv | This command will populate the db with primary school teacher counts for each school. This statistics is found in a csv file located in the data folder. This file needs to be updated yearly. |
fetch_course_enrollment_activity | This |
import_school_teacher_counts_from_csv | This command will populate the db with number of enrolled users who has been active the last 24 hours. |
pull_course_group_registrations | This command will populate the db with number of new group and course registrations the last day |
pull_data_from_matomo | This populates the db with visit and page statistics from matomo. To run this command you will need to set the MATOMO_ACCESS_KEY in the .env file. |
pull_finnish_marks_canvas | This populates the db with statistics on finnsih marks for each module item. |
pull_history_from_canvas_and_update_db | Populates the db with history statisics from canvas |
pull_total_students_counts_from_canvas | Populates the db with number of studens in groups from canvas. |
-
Start:
docker compose up
-
Stop:
docker compose down
Any merge to stage
or master
branch will automatically deploy the application to the stage and production environments respectively.
Maintaining a Django project involves regular updates to ensure that the backend remains secure, performant, and up-to-date with the latest standards and best practices. Here’s how updates are typically managed:
-
Update Packages:
- Identify outdated Python packages using
pip list --outdated
. - Update individual packages with
pip install -U [package]
or all packages according to therequirements.txt
by runningpip install -r requirements.txt
.
- Identify outdated Python packages using
-
Security Audits:
- Analyze Python code for security issues with
bandit
by runningbandit -r .
. - Check installed dependencies for known security vulnerabilities with
safety
by executingsafety check
.
- Analyze Python code for security issues with