Quiz de preguntas rápidas desde CSV

Estoy realizando un quiz de preguntas rápidas basado en el de vaidrollteam.
Lo conseguí programar y funciona genial, pero decidí que la fuente de las preguntas fuera mediante un archivo csv y no consigo que funcione.

Esta captura recoge la estructura de listas de vaidrollteam para las preguntas y las respuestas.

En mi caso importo el CSV desde google sheets y lo cargo al iniciarse la pantalla.
1
Posteriormente genero una lista ge

Posteriormente creo una lista general con todos los datos ["pregunta","obcion1","obcion2","obcion3","RespuestaCorrecta"]
2

Mediante un proceso genero las listas de preguntas con índice 1 y la lista de respuestas con índice 3,4 y 5.

He mantenido el nombre de las listas, por lo que si se generan igual el resto debería funcionar, pero no lo hacen, me reporta "Pick random item: Attempt to pick a random element from an empty list" Por lo que intuyo que las listas deben estarse generando mal.

Me podrían ayudar.

Muchísimas gracias.

Good morning, I would really appreciate it if someone could help me. I can't manage to generate a list structure like this from a CSV file.

I need this structure.

The file comes from an Excel table like this:

If I open the CSV in Notepad, it looks like this.

csv1

Thank you very much.

image

You can use above blocks to make your list structure.
But I would not recommend this structure the questions and answers separated in two list, in this case, the shuffle function will be a challenger.

Use a dictionary instead, with the questions as keys, and their values as sub dictionaries with subkeys

  • correctanswer
  • answerList
  • question

I coded a CSV loader for the Witcher Bestiary a couple of weeks ago.

Search for it, or I would after breakfast.

Also see the last link in

The app works perfectly, but only with this block structure.

(https://community.appinventor.mit.edu/uploads/default/original/3X/d/4/d4a1699d83444fa77f5bbfaa054fe84319973881.jpeg)

The problem is that if I need to add 200 questions, I have to do it one by one along with the answers. That's why I imported them as a CSV from Google Sheets.

If I manage to get the structure above, the app will work.

So write your own blocks to load those global variables from the table you get from the incoming CSV text. Loop over each row , using the Add Item to List and Make a List blocks.

First of all, thank you for your responses. I greatly appreciate your input. It's very overwhelming to face these challenges alone when things don't work out.

I can't get it to work; it keeps reporting errors.

In this screenshot, we can see:

  1. When "jocs" starts:

    a. It calls Web1 and retrieves the CSV file from Google Sheets. (This works).
    b. Then, it creates a general variable for components with the buttons (previously, the list structure worked).
    c. It starts the process to call the next question (this used to work).

  2. When Web1 retrieves the text:

    a. We generate a general variable from the CSV table with the content.
    b. We call the "processing" process (where we generate the questions and answers).

  3. When the "processing" process runs:

    a. It generates one question for each element in the list with index 1.
    When displayed in a label, it looks like this:

    Preguntas

    b. I generate a list of answers by trimming from index 2 to 5.

  4. We create the random question, but it always reports this message.
    Pick random item: Attempt to pick a random element from an empty list
    In the local variable, when requesting a random question, it tells me that the list is empty.
    Tampoco me selecciona las preguntas.
    Select list item: Attempt to get item number 0, of the list [["Si", "No", "Puede ser"], ["Si", "No", "Puede ser"], ["Si", "No", "Puede ser"]]. The minimum valid item number is 1.

Would it help if I uploaded a screenshot of all the blocks? Whatever you think is best to assist me.
Thanks.

My quiz is based on the one published on YouTube by vaidrollteam, and it worked until I tried importing from Google Sheets.

Here index was set as zero. Check this variable. If you use any global variable, just initialise it with 1 or use one ticker to +1 if it is initi with 0

This error clearly says no list items was added inyo this variable. Pls verify the process

Until step 3 it was all good. So concentrate on setp 4 onwards

If possible add sample of your aia

(If your blocks are in eng it will be convenient to answer)

The questions are stored in a web service or in the assets?


Tools, Extensions and Newsletters powered by @techxsarthak
:eyes:Browse my extensions here. :loudspeaker: Subscribe to my MIT AI2 newsletter for free here.

You are having huge confusion at this procedure. Make clear actually what are you aiming for? Yo have designed complex one instead of making simpler one..

that globalCantidadDePreg.. is you initialized with the number 3 then why do designed blocks like this? also you have handled the procedure in wrong manner. Your procedures should go when web got text event but you added during initilise if so you will get such errors. Because without adding elements, items to the global list how can you run events or procedures or logic's?

First design or structure your logic sequentially or I may be wrong to understand your sequnace. Sorry if i am bad.

I import the questions from Google Sheets as a CSV file. Once in the app, the questions are placed in one list and the answers in another.

Thank you very, very much. I had managed to get the data structure, and it was strange that it didn’t work. After reading Spicy_Topics, I reviewed the structure and realized it was referencing other lists. For now, it’s working. I’ll continue with the project and see where I get stuck next. :rocket::muscle:

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