Hi
I have made an application to the bangladeshi researcher. Its basically like mcqs selection at last they will get the probability score. Now he is asking that he needs one question per one page like quiz application type and at last the users able to see the probability score. Do we have any custom component for making this into real? I’m requesting you guys to provide any suggestions!!.
Build a multi-page app where each pages under the pages/ folder would constitute a unique question, thus you would have pages/question1.py, pages/question2.py, etc.
Store responses from the input widgets to session state variables like st.session_state.q1, st.session_state.q2
Finally, in the Results page you can aggregate the scores from the session state variables and display the final results.
Hi @dataprofessor . You mentioned that you have used pages. But for navigating to the first page to second page have you created any button like next and previous?
Hi @dataprofessor . If possible please release a sharable version as soon as possible. Because i’m working under an researcher. He is asking me continously, but i don’t know how to implement.
Thanks in advance
I’ll share the code soon but I’ll need to make the content generic as currently it is used internally.
In the meantime, let me provide you with the pseudo-code on how to implement. You asked about the Next/Previous button.
What I did was create a multi-page app and inherently this means that we’ll need to create a pages/ folder where all the multiple pages of the questions would go. Such as q1.py for Question 1, q2.py for Question 2, etc.
Here’s how I implemented the Next button (with a little weak and you can add the Previous button):
The above function is a utility function that I placed in utilities.py that I would then import into all the q1.py, q2.py, etc. pages. Next, for q1.py I would define a variable called q_number=1, for q2.py I would define q_number=2, etc. This would allow the Next button to bring us to the next page from the pages_list variable.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.