Poured most of the morning into this…finally ready to reach out for some help!
Quiz question.
3 random item’s pictures (out of several) are generated from the database and shown in a repeating group.
1 of these item’s (audio file) is also generated from the database (question).
The user listens to the audio file and matches to the correct one of the 3 items.
Having trouble with 3 things:
Making sure the 1 item (audio) that’s pulled from the database matches 1 of the 3 items in the repeating group (in random order)
Matching the 1 item to its counterpart in the repeating group and creating a result because of it.
Refreshing all the data when clicking ‘next’ - aka, summoning more items from the database.
Just can’t get my head around this at all; it should be really straightforward. I’ve tried everything from creating custom states to ‘intersecting’ things that are displayed. Any help would be appreciated!
Here’s the working example (obvs, not working though!):
Not sure I completely understand but, could you not in the repeating group ‘do a search’ finding the correct answer. Then use ‘merged with’ to find 2 random answers that are not correct.
Have a look now. For #1, I added a random sorting to your repeating group of answers and I changed the expression of question group to select a random item from the repeating group’s list of vocabs.
#2 and #3 already seemed to be working so I have not done anything with them.
Hey,
Cheers for the reply!
I thought that would work, too. Only problem is, that it sticks the ‘answer’ in the same position every time - it’s always the first item of the repeating group. Ideally, I need it to appear randomly throughout the 3 options!
Cheers for the reply! I thought this would work, too. However…because the repeating group searches all of the items but only displays 3, it means that the question group can draw from items that can’t be seen by the user (if you know what I mean). Just refresh the page a couple of times and you’ll see that the question doesn’t match the answer for some of the cases!
I tried a solution for the question item to only pick from items 1-3 of the repeating group but this still didn’t work. Is there a way to pick ‘3 items only’ from the database to put in a repeating group?
Would this work it is abit hacky though. What about having a hidden repeating group somewere on the page. Search your items here using merged with. Then have the second repeating group which source is the first hidden group. Then use order random.
I think the problem is that you are not searching for 3 random records. You are searching for all records and ordering them in a random fashion. You need to search 3 random records only.
You could generate 3 random numbers selected from 1 to n (count of records in your “vocab” table. Hold these numbers in the 3 number states.
Then search your table for the items using the numbers as indexes being those the 3 numbers in your states.
Your resulting records in your repeating group will only have 3 items. Then your sound byte will have to be from one in the resulting search.
Does that help? There is likely other ways to accomplish this but I would have to test.
Thanks for the reply! This sounds good - struggling with putting the random numbers into states though, as well as searching for multiple indexes in the repeating group search. As well as setting some parameters so that the 3 random numbers are all different from each other! I’m using the random number generator - set up a working page here: https://bubble.io/page?type=page&name=random_numbers&id=for-forum&tab=tabs-1
Cracked it I think! The single item (question) did indeed need to search within the answer’s repeating group. To only select the items visible I used this expression:
That only sets parameters inside the 3 columns in the answers - hooray!
I see. Did you try simply changing the repeating group’s data source so that it is still sorted randomly but searches up to 3 items only? With this though, you would no longer be able to simple move to the next page as you were doing with the next button. Instead, when the next button is clicked, I would suggest loading the RG’s list of vocabs (or if you like, just the correct answer) into a custom state and adding a constraint to the RG’s data source to exclude items that are in the custom state.
Hey! Yeah that’s what I managed to work out (searching 3 items only, I used ‘items until’) so the randomizing part is working well.
Whenever I try to display data in the repeating group, as if to refresh it, it doesn’t randomly sort it (even though that’s applied). Not sure if this is a bug (not likely) or I’m doing it wrong (likely)!