Skip to content

eduNEXT/platform-plugin-elm-credentials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Platform Plugin ELM Credentials

CI License status-badge

Purpose

Open edX plugin that includes an API endpoint to generate a JSON file with the European Learning Model (ELMv3) data model format. Only learners who have completed a course and have a certificate of completion are included in the files generated by the API endpoint.

This plugin has been created as an open source contribution to the Open edX platform and has been funded by the Unidigital project from the Spanish Government - 2024.

Compatibility Notes

Open edX Release Version
Palm >= 0.2.0
Quince >= 0.2.0
Redwood >= 0.2.0

The settings can be changed in platform_plugin_elm_credentials/settings/common.py or, for example, in tutor configurations.

NOTE: the current common.py works with Open edX Palm, Quince and Redwood version.

Getting Started

Developing

One Time Setup

Clone the repository:

git clone git@github.com:eduNEXT/platform_plugin_elm_credentials.git
cd platform_plugin_elm_credentials

Set up a virtualenv with the same name as the repo and activate it. Here's how you might do that if you have virtualenv set up:

virtualenv -p python3.8 platform_plugin_elm_credentials

Every time you develop something in this repo

Activate the virtualenv. Here's how you might do that if you're using virtualenv:

source platform_plugin_elm_credentials/bin/activate

Grab the latest code:

git checkout main
git pull

Install/update the dev requirements:

make requirements

Run the tests and quality checks (to verify the status before you make any changes):

make validate

Make a new branch for your changes:

git checkout -b <your_github_username>/<short_description>

Using your favorite editor, edit the code to make your change:

vim ...

Run your new tests:

pytest ./path/to/new/tests

Run all the tests and quality checks:

make validate

Commit all your changes, push your branch to github, and open a PR:

git commit ...
git push

Deploying

Tutor environments

To use this plugin in a Tutor environment, you must install it as a requirement of the openedx image. To achieve this, follow these steps:

tutor config save --append OPENEDX_EXTRA_PIP_REQUIREMENTS=git+https://github.com/edunext/platform-plugin-elm-credentials@vX.Y.Z
tutor images build openedx

Then, deploy the resultant image in your environment.

Using the API

IMPORTANT: To use the API, you need to have a course with certificates enabled. You should consider the following:

  1. You should configure from the Django administrator the coursemode, the certificate generation configuration, and the certificate html view configuration.
  2. You should activate certificates in the course from Studio in the Settings > Certificates.

Now, you can use the API. The API endpoint is protected with the same auth method as the Open edX platform. For generate a token, you can use the next endpoint:

  • POST /<lms_host>/oauth2/access_token/: Generate a token for the user. The content type of the request must be application/x-www-form-urlencoded.

    Body parameters

    • client_id: Client ID of the OAuth2 application. You can find it in the Django admin panel. Normally, it is login-service-client-id.
    • grant_type: Grant type of the OAuth2 application. Normally, it is password.
    • username: Username of the user.
    • password: Password of the user.
    • token_type: Type of the token. By default, it is bearer

    Alternatively, you can use a new OAuth2 application. You can create a new application in the Django admin panel. The body parameters are the same as the previous endpoint, but you must use the client_id and client_secret of the new application. The grant_type must be client_credentials.

    Response

    • access_token: Access token of the user. You must use this token in the Authorization header of the requests to the API.

Finally, you are ready to use the API. You must take into account that only users with django staff, course staff or course instructor role can use the API. The next endpoint are available:

  • GET /<lms_host>/platform-plugin-elm-credentials/<course_id>/api/credential-builder/: Generate a ZIP file with the credential(s) in ELMv3 format.

    Path parameters

    • course_id (Required): ID of the course.

    Query parameters

    • username (Optional): The username of the learner to generate the credential for. If it is not provided, all the learners who have a certificate will be used to generate the credentials. By default, it is None.
    • expires_at (Optional): Date of the expiration of the credential. It must be in the format YYYY-MM-DDTHH:mm:ss±hh:mm. This parameter modifies the properties validUntil and expirationDate of the ELMv3 format. By default, it is None.
    • to_file (Optional): If it is true, the response will be a ZIP file with the ELMv3 format. If it is false, the response will be a JSON with the ELMv3 format. By default, it is true.

IMPORTANT: Bulk download of credentials does not include staff or superuser users.

Configuring plugin settings

You can configure some settings for the plugin. The available settings are the following:

  • language_code: Language code of the credential. It is used to generate the Language and primaryLanguage property of the ELMv3 format. By default, the language defined by the Django setting LANGUAGE_CODE is used.
  • language_map: Map of the language code with the language. This settings is useful when the language defined in the language code is different from English or Spanish.
  • org_country_code: Country code of the organization. It is used to generate the countryCode property of the ELMv3 format. By default, it is ESP.
  • issuer_id: ID of the issuer. It is used to generate the issuer property of the ELMv3 format. By default, a random in-memory UUID is generated.

Default settings are defined for Unidigital project. If you want to change the settings, you can do this in two ways:

  1. You can configure the settings in a specific course using Other Course Settings in the Advanced Settings section in Studio.

    {
      ...
      "ELM_CREDENTIALS_DEFAULTS": {
        "language_code": "POR",
        "language_map": {"fr": "FRA", "de": "DEU"},
        "org_country_code": "PRT",
        "issuer_id": "8fb2a434-e46b-4fd9-80d1-ce7ff11c0048"
      }
    }
  2. You can configure the settings using a Django setting in the LMS.

    ELM_CREDENTIALS_DEFAULTS = {
      "language_code": "POR",
      "language_map": {"fr": "FRA", "de": "DEU"},
      "org_country_code": "PRT",
      "issuer_id": "8fb2a434-e46b-4fd9-80d1-ce7ff11c0048",
    }

The order of precedence is the following:

  1. Course settings
  2. Django settings
  3. Default settings

Testing JSON file

Test the API-generated JSON file using the EU credential builder. In step #3 (Upload), submit the JSON file created by the API and verify that the credential is valid.

Getting Help

If you're having trouble, we have discussion forums at discussions where you can connect with others in the community.

Our real-time conversations are on Slack. You can request a Slack invitation, then join our community Slack workspace.

For anything non-trivial, the best path is to open an issue in this repository with as many details about the issue you are facing as you can provide.

For more information about these options, see the Getting Help page.

License

The code in this repository is licensed under the AGPL 3.0 unless otherwise noted.

Please see LICENSE.txt for details.

Contributing

Contributions are very welcome. Please read How To Contribute for details.

This project is currently accepting all types of contributions, bug fixes, security fixes, maintenance work, or new features. However, please make sure to have a discussion about your new feature idea with the maintainers prior to beginning development to maximize the chances of your change being accepted. You can start a conversation by creating a new issue on this repo summarizing your idea.

Adding properties to the ELMv3 format

The current implementation has the minimum properties to build a credential under the format ELMv3. If you want to add more properties, you can do it following the next steps:

  1. Add the new properties in the serializers.py file. In this file, you will all models that are used in the API. Most of the properties require you create a new class that inherits from ConfigModel.
  2. Normally, you will also need to add the new properties in the CredentialBuilder class.
  3. You must take into account the ELMv3 format to add the new properties. Normally, properties have an id and a type.

Reporting Security Issues

Please do not report security issues in public. Please email security@edunext.co.

About

Open edx plugin that includes API to generate JSON files in ELMv3

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages