Package: tutor-discovery
This is a plugin forTutorthat integrates theCourse Discoveryapplication in an Open edX platform. it is useful for integration with, for example,Ecommerceor an external course catalog.InstallationThis 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 discoveryThen, to enable this plugin, run:tutor plugins enable discoveryRestart and initialize your platform with:tutor local launchOperationsCreating a userThe discovery user interface will be available athttp://discovery.local.edly.iofor a local test instance, and atDISCOVERY_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 createsuperuserThen, you must login with this user athttp://discovery.local.edly.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 configurationDiscovery uses separate indices for different models (the names are: course, course_run, person and program by default). And you can overwrite theses
names by configuringDISCOVERY_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-nameRe-indexing coursestutor local run discovery ./manage.py refresh_course_metadata --partner_code=openedx
tutor local run discovery ./manage.py update_index --disable-change-limitCaching programsIn order to cache programs in the LMS, you will need to manually create a catalog integration. Make sure you use staff user for the below command. Iflms_catalog_service_useris not a staff user, then make it a staff user in your LMS User model. 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_userThen run the below command, this command will cause errors every time as it tries to cache programs from all sites that are added to your LMS sites model:tutor local run lms ./manage.py lms cache_programsIf you don’t want the errors, then make use of an extra argument to the command .i.e.--domain. This argument will be equal tolocal.edly.ioif you are running tutor local andlocal.edly.io:8000if you are running tutor dev::tutor local run lms ./manage.py lms cache_programs –domain=”local.edly.io”
or
tutor dev run lms ./manage.py lms cache_programs –domain=”local.edly.io:8000”This last step should be performed every time you create new or make changes to existing programs.Install extra requirementsIn 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 discoveryDebuggingTo 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/ discoveryYou can then access the development server athttp://discovery.local.edly.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.devTroubleshootingThis Tutor plugin is maintained by Muhammad Faraz Maqsood fromEdly. Community support is available from the officialOpen edX forum. Do you need help with this plugin? See thetroubleshootingsection from the Tutor documentation.Max retries exceeded with urlWhen running in production with HTTPS enabled, you may face this error during theinitphase oftutor 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/hostsfile 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.LicenseThis work is licensed under the terms of theGNU Affero General Public License (AGPL).