OppiaMobile Community

REST API to get course structure and content

Hi All,

[This is a follow up to earlier email conversation - the basic background is to be able to access the course structure and content via a REST API service ]

For the actual course content (ie the html), this isn’t currently stored in the Oppia server database. This html content is only stored in the zip file that is uploaded (into the uploads directory on the server).

To get all the actual course content into the Oppia database, I think there are 2 possible approaches here:

Option 1
As part of the process when the course is uploaded (either via the webform in the Oppia dashboard or via the API) and add a field to the activity model to store the activity html.

Option 2
Again on upload via webform or API, unpack the zip file into a directory, the API can then read/serve these files or the file content.

I’m not totally sure myself which is going to be the best of these options, but suspect that option 1 would be best, as reading from the database is likely to be quicker than opening and reading files (as in option 2).

A couple of things to look out for here will be around how images and css are referenced or provided via the course structure/content API.


I guess this is very important feature in the terms of Oppia app custom designing

We are trying to targeting Oppia Mobile App for the Android Tablets and We have customized the app dimensions and new designs are being implemented but course is downloaded in zip format and html pages are loaded in WebViews so customization of Oppia becomes somehow little difficult.

The Idea is to have multiple skins of the Oppia app with single back office. :slight_smile:

Thanks @farazahmed (and for being first person to post in this new community site, excluding me!)

I wonder though if you’re assuming that the users will be online when they access the courses, or are you looking to make a lot of API requests in one go when the course is ‘downloaded’ - so then rather than (say) downloading a single zip file, the download process would make X many API requests?

I recall a skype discussion I had with Sidra a little while back and so can understand that you’re trying to move away from just having the webviews. I wonder though if you might run into difficulties later if, for example, trying to parse the html files to display different parts of the activity in different ways.

I guess a lot of this is all historical, and as a result of us using Moodle pages for the creation of most of the content (so outputting to html then makes sense).

So we could look at all this from a different angle… for example another approach could be to have the whole content in xml files instead, the Open University uses this approach for their course content using their own XML format/definition (see: https://www.open.edu/openlearn/money-business/financial-accounting-and-reporting/altformat-ouxml for an example). Then the XML can be output in many different formats (eg to plain html, or parsing this to display with different Android UI elements).

Long term I think that would be a better approach for Oppia, but is requires a really big overhaul of how all the courses are created/authored etc - and would be very significant effort to do this.

BTW… if you have some ideas for updated Oppia app designs etc, then please feel free to post in the UI & UX category (https://community.oppia-mobile.org/c/ui-and-ux), I put a topic up in there the other day about tablet optimised designs.

Anyway, just my thoughts on this!

Thanks Alex for your quick response.
as you suggested below for other approach
“Open University uses this approach for their course content using their own XML format/definition (see: https://www.open.edu/openlearn/money-business/financial-accounting-and-reporting/altformat-ouxml for an example). Then the XML can be output in many different formats (eg to plain html, or parsing this to display with different Android UI elements).”

So we need to add content in XML in moodle then export to Oppia and the downloaded files will contain XML content ? or any document related to above approach ?

The way the Open Uni manages this is to use an XML tools to develop the content, it then gets transformed/imported into Moodle format, or to print/pdf etc or whatever other format they want to use. So it’s quite a different approach to using Moodle for writing the content initially.

I’ll need to write up a little bit more about this approach when I have bit more time !

I followed up on this in it’s own topic, see: Alternative approach for course authoring

Thank you Alex for starting this thread. We are actually looking out to make changes where it just not only help us but help all the people who are working in this domain and can face the same issues. We are currently trying to make changes in user interface to give health workers a good user experience. I also conducted a workshop with old and new interface and realised there is dire need to make it user friendly so that health workers can explore this app on their own - especially now we are trying to scale it in different regions of Pakistan. Currently the state is, service returns zip file url in which html pages are placed and shows web view in app which is hard to customise and difficult to create better user experience. In my opinion we can revamp the webservices, where developers have flexibility, it might help us in future for further development.

Hi Alex,

We tried to add custom CSS in theme related changes where we had created a CSS block and that CSS block is being used in moodle content but CSS class is not applying on content.

I am following This approach but unfortunately its not working for me.

any thoughts ?

Hi @farazahmed,
I think what that CCS stuff is doing is just changing the CSS in the Moodle theme that you’re using. When Oppia exports the course, it doesn’t export any extra CSS from the Moodle theme, so that’s why it won’t be getting exported to display in the Oppia app.
To add extra CSS (or javascript) when the course is exported from Moodle to Oppia, you’ll need to add an extra folder and CSS etc in the export block code (under the ‘styles’ directory). There are a couple of example/core ones here: https://github.com/DigitalCampus/moodle-block_oppia_mobile_export/tree/master/styles - so you could make a copy of one of these and update that.
Then when you export from the Oppia block in Moodle, make sure to select the right stylesheet to use.
Hope that helps,

Hi Alex,
Thanks for the response.
Okay what I have got from above is:

Add custom CSS classes and apply those classes in the content and while exporting to oppia, need to add that customized css style, it will be rendered on oppia application ?

Yes, that’s right!

sent from email:

I have successfully added css in CSS theme which is also showing on moodle but as you suggested that for oppia mobile we need to modify or add css file inside the styles directory but I guess for adding new file I need to go to the CPanel where the moodle is deployed, for example in our case it is deployed over the AWS instance then I need to go there and create files ?

I can’t see any option to add new css files from the moodle theme, I went to Theme and also in advance theme settings but it only allows us to put custom css in the theme which can’t be exported as you suggested on community.

Yes, for adding the custom CSS to be exported with the Moodle course, you’ll need to go into the file structure on the Moodle site, under /blocks/oppia_mobile_export/styles to add a new css file and resources dir.