Adding a django application to Open edX

Hello. I have a task which consists of adding an extension to openedx (endpoint). I would like to know how to setup the openedx in my local machine, adding a django application to create this endpoint. I read all the documentation of tutor but i didn’t know how to change the source code of the openedx.
Thank you

Hi @Scorpion197 , welcome to Open edX!

To use a local copy of the edx-platform source code in Tutor, you need to launch Tutor with a --mount argument, pointing to your local copy of the platform code.

But if you’re writing a plugin, you don’t need to modify edx-platform, you just need to install your plugin as a pip package into the edx-platform virtual environment, and the plugin architecture will take care of the rest. The best resource for doing local dev with Tutor is @kmccormick 's tutor quickdev plugin.

For a guide to writing Open edX plugins, see @lpm0073 post about Getting Started With Open edX Plugin Architecture - Blog. (Note: since this was written, that the open edx plugin architecture has been moved outside of edx-platform and into edx-django-utils plugins, but it works much the same.)

2 Likes

Is it possible to create a Django application and use it as a plugin ? this django application contains an endpoint secured with Oauth2 and logs a message to the lms logs

@Scorpion197 If it’s a standalone Django application, then it’s not strictly a “plugin”, it’s an “IDA” or Independent Django Application. These applications run on their own, outside of the Open edX environment, so they don’t have direct access to the code and methods in the platform. This can be a good solution, depending on your use case.

IDAs access Open edX via its the REST APIs – this is a maintainable, reliable way to loosely couple your application to the platform. You can see the available APIs on your running instance of Open edX under http://yourinstance.com/api-docs/. If there’s an API missing from the list that you need, then you can write a plugin to provide it.

References:

Okay thank you so if i want to add an endpoint which for example retrieves all the courses of a given user, i just need to create a Django application which uses edX rest APIs and that’s it right ?

I can send you the task i need to do if you want.

There’s already a REST API for this for the logged in user (or for any user if the current user is staff)… so why do you need to add an app that provides this functionality?

Sure, can you post the details here?

Thank you. here is the task:

Another platform that IBL is built on is Open edX.

Stand up an instance of Open edX using either the Dockerized Tutor release or our https://gallery.ecr.aws/ibleducation/ibl-edx-ce (architected using Tutor).
Develop an extension that exposes a REST API endpoint and saves a greeting from the user (secure this endpoint with OAuth2 in the same way that Open edX secures its other API endpoints). This endpoint should do the following things with the user-submitted greeting:
Log it (it should be visible in the platform’s LMS logs).
Save it in the database (the greeting should be visible from the Django Admin).
If the greeting is “hello”, then the view of this API endpoint should call the original greeting endpoint again with “goodbye” as the parameter. This is to make sure that you can write an Open edX view that can make an OAuth2-secured API call with a client ID, a client secret and an access token. Of course, if your code calls this endpoint with “hello” again then it’ll be recursive and things will crash.


Ahh… this is a recruitment exercise, not an application that a real user actually needs. So forgive me if I don’t spend any more time helping you here :slight_smile: I think I’ve sent all the references I have, so you’ve got what you need… best of luck to you!

hey @Scorpion197 did you make your task, becouse i need to do it too and i can’t stand up and instance of Open edX i have some troubles with it