Guidance for building cloud application

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!!.

Thanks in advance
Guna Sekhar

Hi @Guna_Sekhar_Venkata

I’ve built a similar app and here’s how I did it:

  1. Build a multi-page app where each pages under the pages/ folder would constitute a unique question, thus you would have pages/, pages/, etc.
  2. Store responses from the input widgets to session state variables like st.session_state.q1, st.session_state.q2
  3. Finally, in the Results page you can aggregate the scores from the session state variables and display the final results.

Hope this helps!

Could share your app code for reference?

Hi @Guna_Sekhar_Venkata

I’m planning on making a shareable version, will share as soon as I get a chance.

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

Hi @Guna_Sekhar_Venkata

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 for Question 1, for Question 2, etc.

Here’s how I implemented the Next button (with a little weak and you can add the Previous button):

def display_button(q_number):
   pages_list = [‘’, ‘’, ‘’]

   if st.button("Nextㅤ", key=f'btn_{q_number}'):

The above function is a utility function that I placed in that I would then import into all the,, etc. pages. Next, for I would define a variable called q_number=1, for 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.

Hope this helps!

Tq @dataprofessor . I’ll give a try