Streamlit to create an education app - seeking examples / interactive question and answer

Hi all. I am in the process of trying to use streamlit to build a training and development app for some staff. The app currently consists of 3 pages, 1 of these will link to data sources, the others are more text heavy defining concepts etc. I wondered if anyone knew of any examples where streamlit has been used for education and development purposes and would be happy to share (thank you!) - I’m particularly keen to see examples where an interactive “quiz” element has been included, though tbh anything would be useful (!). Thanks in advance.

Well @Mr.E, I once wrote a very flexible and general data capture solution for a company I worked for. I am unable to share the code as this stayed with the company.

But, if it helps you, the logic I used was as follows:

  1. I created a CSV file (template) that had the following columns:

a. Page name - self-explanatory (and to group all widgets page wise)
b. Field name - against which user-supplied data can be stored into a database, if/as required
c. Question - What the user is to be prompted on. Eg. ‘Please enter your name’
d. Widget Id - unique id auto generated internally after CSV file read, to act as a unique widget key
e. Widget name - eg. Selectbox, radio, etc. You can use all streamlit available widgets, and more (with html)
f. Widget options - this could be any option list that the widget needs. eg drop down list for radio widget, or colour for a text widget, etc.
g. RO - read only Boolean toggle for the widget that could be manipulated in the code, to allow / disallow entry
h. MS - Mandatory Status. Boolean toggle for the widget that could be manipulated in the code, for mandatory datapoints. If all MS datapoints are not filled, don’t mark survey as completed for a given user, etc.
i. WC - widget column - column # / position of that widget in a given row (for placement)
j. TW - total widgets per given column (for placement)
k. CC - code col, in case you want to further extend your code / widget functionality with eval statements
l. Answer - to store the user response against that widget, if it is a data widget. Eg selectbox, and not a plain display widget. This can also be used to store that starting base value (default) value for any data widget.

  1. You can iterate over this CSV and dynamically display / accept data, on the screen / from the user, respectively. You can use this for standard data capture, surveys, etc.
  2. Thus, you can externally create different templates for different surveys, etc., and pull them up as needed.
  3. Instead of a CSV, you can even use a JSON dictionary template, as per choice.
  4. If there are multiple pages in your CSV, you can display your page names in a sidebar, to serve as a kind of navigational index, to jump to a certain page. All the widgets for that page will get loaded via code.
  5. You can put all this behind an authentication system and allow users to only access the surveys that they are allowed to respond to.

You will have to invest time and effort to write all this. But start small, add bells & whistles later, the end is worth it.

Cheers

1 Like

Thanks @Shawn_Pereira - that’s really helpful, and definitely not an idea I had considered. Appreciate you laying out the approach so clearly, will have a go at trying this :+1:t2:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.