Régis Behmo dbcf969a7a chore: handle nightly version numbers
Here, we make it possible to add a "-nightly" suffix to the package
version. This suffix will find its way to the Docker image tags. Thus,
the nightly branch will have different image tags. This will resolve
some confusion, as image tags are currently identical in nightly and
master.
2023-05-26 16:28:10 +02:00
🌅
2019-07-11 13:44:16 +08:00
2022-12-12 19:23:02 +01:00
🌅
2019-07-11 13:44:16 +08:00
2019-07-11 16:32:59 +08:00
2023-05-17 10:24:21 +02:00
2022-12-12 19:23:02 +01:00

Course Discovery plugin for `Tutor <https://docs.tutor.overhang.io>`_
=====================================================================

This is a plugin for `Tutor <https://docs.tutor.overhang.io>`_ that integrates the `Course Discovery <https://github.com/edx/course-discovery/>`__ application in an Open edX platform. it is useful for integration with, for example, `Ecommerce <https://github.com/edx/ecommerce>`__ or an external course catalog.

Installation
------------

This plugin requires tutor>=3.6.0. If you have installed tutor from a pre-compiled binary, it already comes bundled with the discovery plugin. Otherwise::

    tutor plugins install discovery

Then, to enable this plugin, run::

    tutor plugins enable discovery

You will have to re-generate the environment::

    tutor config save

Then, run migrations::

    tutor local init

This last step is unnecessary if you run instead ``tutor local launch``.

Operations
----------

Creating a user
~~~~~~~~~~~~~~~

The discovery user interface will be available at http://discovery.local.overhang.io for a local test instance, and at ``DISCOVERY_HOST`` (by default: http(s)://discovery.<your lms host>) in production. In order to run commands from the UI, a user must be created::

    tutor local run discovery ./manage.py createsuperuser

Then, you must login with this user at http://discovery.local.overhang.io/admin.

Alternatively, you can login with oauth2 using a pre-existing user created on the LMS/CMS by accessing http(s)://discovery.<your lms host>/login. To do so, the proper domain names must exist and point to the production server.

Index configuration
~~~~~~~~~~~~~~~~~~~

Discovery uses separate indices for different models (the names are: course, course_run, person and program by default). And you can overwrite theses
names by configuring ``DISCOVERY_INDEX_OVERRIDES``::

    DISCOVERY_INDEX_OVERRIDES:
      course_discovery.apps.course_metadata.search_indexes.documents.course: your-course-index-name
      course_discovery.apps.course_metadata.search_indexes.documents.course_run: your-course-run-index-name
      course_discovery.apps.course_metadata.search_indexes.documents.person: your-person-index-name
      course_discovery.apps.course_metadata.search_indexes.documents.program: your-program-index-name

Re-indexing courses
~~~~~~~~~~~~~~~~~~~

::

    tutor local run discovery ./manage.py refresh_course_metadata --partner_code=openedx
    tutor local run discovery ./manage.py update_index --disable-change-limit

Caching programs
~~~~~~~~~~~~~~~~

In order to cache programs in the LMS, you will need to manually create a catalog integration. This step should be performed just once::

    tutor local run lms ./manage.py lms create_catalog_integrations --enabled \
        --internal_api_url="" \
        --service_username=lms_catalog_service_user

Then::

    tutor local run lms ./manage.py lms cache_programs

This last step should be performed every time you create new or make changes to existing programs.

Install extra requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~

In order to install extra requirements, use DISCOVERY_EXTRA_PIP_REQUIREMENTS and re-build the docker image.::

  tutor config save \
    --set 'DISCOVERY_EXTRA_PIP_REQUIREMENTS=["git+https://github.com/myusername/myplugin"]'

Then, build the image, pointing to your fork if necessary::

  tutor images build discovery

Debugging
---------

To debug the course discovery service, you are encouraged to mount the course-discovery repo from the host in the development container:

    tutor dev start --mount /path/to/course-discovery/ discovery

You can then access the development server at http://discovery.local.overhang.io:8381. Feel free to add breakpoints (``import pdb; pdb.set_trace()``) anywhere in your source code to debug your application.

Once a local repository is mounted in the image, you will have to install nodejs dependencies and collect static assets::

    tutor dev run discovery npm install --development
    tutor dev run discovery make static.dev

Troubleshooting
---------------

This Tutor plugin is maintained by Régis Behmo from `Overhang.IO <https://overhang.io>`__. Community support is available from the official `Open edX forum <https://discuss.openedx.org>`__. Do you need help with this plugin? See the `troubleshooting <https://docs.tutor.overhang.io/troubleshooting.html>`__ section from the Tutor documentation.


`Max retries exceeded with url`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When running in production with HTTPS enabled, you may face this error during the `init` phase of `tutor local launch`:

```
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='<LMS_HOST>', port=443): Max retries exceeded with url: /api/courses/v1/courses/?page=1&page_size=10&username=discovery
```

This error may be due to an incorrect DNS resolution of the LMS DNS record. With some cloud providers (for instance: [DigitalOcean](https://digitalocean.com/)) the `/etc/hosts` file on the host automatically contains the following entry::

    127.0.1.1 <LMS HOST>

This entry may be present if you named your server with the LMS hostname.

License
-------

This work is licensed under the terms of the `GNU Affero General Public License (AGPL) <https://github.com/overhangio/tutor/blob/master/LICENSE.txt>`_.
Description
Course Discovery plugin for Tutor
Readme 412 KiB
Languages
Python 67.2%
Dockerfile 24.2%
Makefile 8.6%