My Learning Analytics (MyLA) is a learning analytics platform designed for students to view their own learning data generated in the Canvas Learning Management System. It currently has 3 views (Resources Accessed, Assignment Planning, and Grade Distribution), with more views planned in the future.
These instructions will get a copy of MyLA up and running on your local machine with anonymized/fake student data.
- Clone this repo.
git clone https://github.com/tl-its-umich-edu/my-learning-analytics.git
- Then cd into the repo.
cd my-learning-analytics
- Create a directory in your home directory called "mylasecrets".
mkdir ~/mylasecrets
. This directory is mapped by docker-compose.yml into the container as /secrets/ - Copy the config/env_sample.json into mylasecrets as env.json.
cp config/env_sample.json ~/mylasecrets/env.json
- Examine the
env.json
file, you may need to change some of the configuration in it now or later. There are comments to help the configuration. - Create a new
.env
file and copy the values from.env.sample
, which has the suggested default environment variable settings. - Examine the
.env
file. It mostly just has the MySQL information as well as locations of the environment files. - Start the Docker build process (this will take some time).
docker-compose up -d --build
- Download the latest SQL file from this link: https://drive.google.com/drive/u/0/folders/1Pj7roNjRPGyumKKal8-h5E6ukUiXTDI9.
- Load database with data.
docker exec -i student_dashboard_mysql mysql -u student_dashboard_user --password=student_dashboard_pw student_dashboard < {name of sql file}
You may also optionally place the json settings directly into the ENV_JSON
environment variable if your deployment environment doesn't easily support mounting the env.json
file into container. When using ENV_JSON
put the entire contents of env.json
into it as single line string.
- Navigate to http://localhost:5001/ and log in as:
username: root password: root
- As you are now logged in as
root
, there are no courses listed. Next 3 steps will help you view a sample course. - Connect to MySQL database.
Host: 127.0.0.1 Username: student_dashboard_user Password: student_dashboard_pw Database: student_dashboard Port: 5306
- Navigate to
course
table and select canvas_idcanvas_id
("SELECT canvas_id From course"), which will be used in the next step. - Nagivate to http://localhost:5001/courses/{canvas_id} with the canvas_id you found. (For example, with SQL file myla_test_data_2019_10_16.sql loaded in, nagivate to http://localhost:5001/courses/235420 or http://localhost:5001/courses/362855 and you can view the course page as an admin.)
- To get to the Django admin panel, click on the Avator in the top right, then click
Admin
, or go here: http://localhost:5001/admin.
- Click on the top-right circle, then click
Logout
. - Connect to MySQL database.
Host: 127.0.0.1 Username: student_dashboard_user Password: student_dashboard_pw Database: student_dashboard Port: 5306
- Navigate to
user
table and select a studentsis_name
, which will be used in the next step. - Create an authorized user.
docker exec -it student_dashboard python manage.py createuser --username={insert sis_name} --password={create password} --email=test@test.com
- Note: You can also make a user a superuser by connecting to the database, editing the record in
auth_user
and settingis_staff=1
andis_superuser=1
.
- Note: You can also make a user a superuser by connecting to the database, editing the record in
- Login using the username and password created.
- The course(s) enrolled by the student with selected
sis_name
will be displayed. Click on a course to view as the student selected in step 3.
- If you were using a prior version of MyLA, there is a utility
env_to_json.py
to help convert your configuration. Runningpython env_to_json.py > config/env.json
should create your new config file from your.env
file.
The bq_cred.json
defined in the .env
file is service account for BigQuery, and it needs to be supplied and put into the directory defined in the .env
file and setup in the environment.
(Openshift Only) The /secrets/saml
directory needs to contain 4 files for SAML configuration. These are currently hard-coded in settings.py
though the path comes from the environment SAML2_FILES_BASE.
remote-metadata.xml
student-dashboard-saml.key
student-dashboard-saml.pem
View options can be controlled at the global and course level. If a view is disabled globally, it will be disabled for every course, even if previously enabled at the course level. If a view is not globally disabled, it can still be disabled at the course level.
VIEWS_DISABLED
is the comma delimited list of views to disable (default empty). The expected name of the view is the same as the view's column name in the course_view_option
table. For example VIEWS_DISABLED=show_resources_accessed,show_grade_distribution
will disable both the Resources Accessed and Grade Distribution views.
Note that by default all views are enabled when a course is added.
Only basic LTI launches are supported at the moment (automatic account creation and redirection to the correct course). New courses are not added nor are course view options modified.
The relative LTI launch url is /lti/auth/
(ex: https://example.com/lti/auth/
). NOTE The trailing slash after /auth/
is required! You'll get an error about CSRF if you have the wrong URL! :)
-
When you configure the tool in Canvas the "Privacy" option must be changed from Anonymous to Public to pass along the user information required.
-
You should use the XML builder to generate and paste the XML that rather than manually adding it. This will allow options like "Course Navigation" extension.
-
You also need to configure CSP value in the environment, specifically the
FRAME_SRC.
(See next section) In addition you need to ensure you are using https andCSRF_COOKIE_SECURE
is true with your domain (or instructure.com) in trusted origins.
Environment variables:
STUDENT_DASHBOARD_LTI
: Set to True to enable LTI (default false).
PYLTI_CONFIG_CONSUMERS
: JSON string of supported LTI Consumers (default none). Formatted { "LTI_CONSUMER_KEY_1": { "secret": "LTI_CONSUMER_SECRET_1" } }
. These are the actual key and secret you put into your launch (like in Canvas).
LTI_PERSON_SOURCED_ID_FIELD
: LTI launch field containing the user's SIS ID (default: lis_person_sourcedid
). Useful for retrieving SIS ID from custom LTI launch fields if lis_person_sourcedid
is not available.
LTI_EMAIL_FIELD
: LTI launch field containing the user's email address (default: lis_person_contact_email_primary
). Useful for retrieving email from custom LTI launch fields if lis_person_contact_email_primary
is not available.
LTI_CANVAS_COURSE_ID_FIELD
: LTI launch field containing the course's canvas id (default: custom_canvas_course_id
).
All of the Content Security Policy headers can be configured. In the env_sample.json
there is a sample security policy that should work to bring it up. It has REPORT_ONLY
set to true; by default it won't actually do anything. If you're using LTI to embed this tool or you want to configure the policy you need to adjust these values and set REPORT_ONLY
to false.
A demo_init.sh.sample
file has been provided to help initialize terms and courses. This can be used in combination
with cron.py
to provide some data to start exploring the tool's features. Rename the file to demo_init.sh
and
replace the provided fabricated values with those of terms and courses relevant to your local institution, providing
additional courses or terms as desired. Ensure that the CANVAS_DATA_ID_INCREMENT
environment variable is set
appropriately in dashboard/settings.py
, and then run the following command:
docker exec -it student_dashboard /bin/bash ./demo_init.sh
If you have problems, you can connect direct into a specific container with the command
docker-compose run web /bin/bash
You should login via Shibboleth into the application. Once you do that for the first admin you'll have to go into the database auth_user
table and change is_staff
and is_superuser
to both be true. After doing this you can change future users with any admin via the GUI.
Users and files are loaded now with the cron job. This is run on a separate pod in Openshift when the environment variable IS_CRON_POD=true
.
Crons are configured in this project with django-cron. Django-cron is executed whenever python manage.py runcrons
is run but it is limited via a few environment variables.
The installation notes recommends that you have a Unix crontab scheduled to run every 5 minutes to run this command. https://django-cron.readthedocs.io/en/latest/installation.html
This is configured with these values (Django Cron) Run only at 2AM
RUN_AT_TIMES=2:00
(Unix Cron) - Run every 5 minutes
CRONTAB_SCHEDULE=*/5 * * * *
For local testing, make sure your secrets are added and your VPN is active. Then run this command on a running container to execute the cronjob
docker exec -it student_dashboard /bin/bash -c "python manage.py migrate django_cron && python manage.py runcrons --force"
After about 30-60 seconds the crons should have completed and you should have data! In the admin interface there is a table where you can check the status of the cron job runs.
- Since MyLA can be used by multiple institution, copyright information needs to be entitled to institutions needs.
- Django Flatpages serves the purpose. The display of the copyright content can be controlled from the Django Admin view.
- The url for configuring copyright info must be
/copyright/
since that is used in thebase.html
for pulling the info. Read more here
MyLA is licenced under Apache v2.0. There is a file myla_licence_compat.ini
that can be used with Python Licence Check to check any new dependencies and their licences.