Development mode for this application starts up 2 processes in the same container, one running on port 5000 (Python/Django backend) and one that writes to the disk and recompiles the frontend. This allows for changes to be picked up and re-built from the mounted local volumes.
With Docker installed run
docker-compose down; docker-compose build && docker-compose up
Then the app in development should be accessible on http://localhost:5000/
Now you can make changes to files in frontend and the changes should show up in the browser automagically.
This app can currently only be launched via LTI. Please see the Wiki for instructions on configuring with LTI.
The backend uses the Django Rest Framework to build out a REST API. When DEBUG is equal to True in Django settings, the application leverages the drf-spectacular library to document existing endpoints and provide for API testing using Swagger.
The OpenAPI schema can be downloaded as a YAML file from http://localhost:5000/api/schema. To use the Swagger UI, do the following:
- Launch the tool from a course in Canvas.
- Right-click in the iframe and select "View Frame Source" in Chrome (or your browser's equivalent).
- Change the URL to navigate to
/api/schema/swagger-ui.
Once on the page, requests can be made against the API using the "Try it out" functionality.
For endpoints protected by course tab isolation middleware, Swagger requests must include the signed course context header.
- In Swagger UI, click
Authorize. - For
SignedCoursePayload, paste the signed value from session storage (no quotes). - Click
Authorize, thenClose.
To get the signed value, use one of the following methods.
Method 1 (recommended): DevTools Application tab
- Open browser devtools in the launched tool page.
- Go to
Application->Session Storage. - Select the app origin (for local this may be
localhost:5000; when proxied, select yourngrokorigin). - Find key
signed_course_user_payloadand copy its value. - Paste that value into Swagger
AuthorizeforSignedCoursePayload. Method 2: Get it from Source - Launch the app and Right click and choose "View Frame Source"
- Look for <script> tag and
cae_globalsand Find keysigned_course_user_payloadand copy its value. - Paste that value into Swagger
AuthorizeforSignedCoursePayload.
### Testing production (Openshift) build
The openshift build compiles all of the frontend assets into the container during the build. It uses whitenoise currently to serve up the content.
To build, use the separate docker-compose-openshift-test.yml file. This uses a slightly different dockerfiles/Dockerfile.openshift that uses a static path and disables DEBUG.
`docker compose -f docker-compose-openshift-test.yml build`
Then to start it you can run
`docker compose -f docker-compose-openshift-test.yml up`
This should start up as expected on http://localhost:5000
### Running Unit test
All test are in the `tests` folder. To run the tests
```sh
docker exec -it instructor_tools python manage.py test
- Getting the Alt text from course images run as a background task.
- We are using Django ORM is set a default message Broker.
- Django admin can be used for tracking Successful, Failed, Queued, Scheduled Tasks
- Apart from Django admin, CLI can be used for tracking as well:
python manage.py qinfo
- Apart from Django admin, CLI can be used for tracking as well:
- The following environment variables can be set to configure Django Q background task processing
Q_CLUSTER_WORKERS- Number of worker processes (default: 4)Q_CLUSTER_TIMEOUT- Task execution timeout in seconds (default: 900, i.e., 15 minutes)Q_CLUSTER_RETRY- Retry interval in seconds for failed tasks (default: 1800, i.e., 30 minutes)Q_CLUSTER_BULK- Sets the number of messages each cluster tries to get from the broker per call.Q_CLUSTER_MAX_ATTEMPTS- Maximum number of retry attempts for a task after failure (default: 1)Q_CLUSTER_NAME- Cluster Name
The concept for the Alt Text Helper tool was inspired by a proof‑of‑concept project created by Chris Smith (@ smithcth), Help Desk Supervisor in the Office of Online & Digital Education at the University of Michigan–Flint. We appreciate his guidance and collaboration on implementing the LTI version of the Alt Text Helper tool.