XBlock data transfer to models.py in another app

I am new to open edx and I am trying to create an Xblock for Vimeo Video. I could have used the xblock that was already available. But my company wants an XBlock that was available only to the firm.

I created an XBlock that uploads and displays the Vimeo Video. I am trying to get the XBlock to send the viewed duration of a video by a student. I used the player.on(‘timeupdate’) event to capture the data.

But I cant figure out how to store the data in my SQL database. I have the basic idea where I have create an API function which will send the data to a different app and it will be store by the models.py in that app.

I tried to understand how API works in XBlock, but I couldnt understand how to do it. Can someone please help how to successfully send data from the XBlock to the database. Any pointers are welcome.

Thanks in advance.

1 Like

@Bala open edX has built in mechanism to log/emit events from video player. You can follow this approach to emit an event where you need it.
Once event is emitted its data is going to be stored depending upon what type of backends you have set in EVENT_TRACKING_BACKENDS . There few built-in backends like for storing event json in tracking log file we have tracking_logs backend. If you want to store data in mysql you can define your own backend like this one and add that backend in EVENT_TRACKING_BACKENDS.

1 Like

Thank you Sir!

I will give it a try and let you know how it goes.