need help implementing a feature that allows users to join a group using a randomly generated code (similar to Google Classroom). Can someone help me?

Hello, everyone. I’m facing an issue in the development of my project and I’d like to know if anyone can help me. The idea is that, when creating a group, a random code is generated so that students can use it to join the group, similar to Google Classroom. So far, we’ve managed to implement group creation and code generation (it is saved in Firebase along with the group name), but we’re struggling to make it allow students to join when the code is entered. If needed, I can share the .aia file.

Yes, please share your relevant blocks, and in this case your aia project may also be useful (as long as it is not stuffed full of media assets :wink: )

I’ll explain a few things so you can better understand, as I’m Brazilian and the variables are in Portuguese.

  1. The two main screens where I’m having doubts are "telaCriarGrupo" and "telaDepoisDeLogar".
  2. The "telaCriarGrupo" screen is responsible for creating the groups, and the "telaDepoisDeLogar" screen is responsible for authenticating the code so that the user can join the group. Another important screen is "telaGrupoOficial", which displays the group with its name and code for users.
  3. The other screens are not as relevant to my current question.
  4. Keep in mind that the goal of the project is for teachers to create groups where they can post questions for students who joined the group to answer (my partner is working on the functionality for the questions, so it’s not included in this file).
    projetoFinal.aia (349.3 KB)
    image
    The Firebase is like this.

Not quite sure where your problem is? You have created a code for a group. What is next?

How will a student get this code?
Do all students have viable email addresses they can use ?
What will they do with the code, in order to join a group?
Will there be a separate app for students ?
How do you propose they access the questions set for the group ?

The teacher will provide the code to the students so they can access the group. The problem is that I don’t know how to verify the code so that when the user enters it in the textbox, they can join the group.
There won’t be a separate app. I’m still going to create a function with a switch for "teacher" (teachers will have pre-existing email and password credentials provided by the educational institution) and "student." When the login is successful and the teacher switch is on, the user will be directed to the teacher screen. When the student switch is on, the same happens, but in this case, the user is directed to the student screen.
The questions have IDs that are linked to the groups.

Student enters "science"
The app fetches the code from firebase (not shown to student)
Student enters the code they have been given in the textbox
The app compares what the student has entered with the fetched code
If true, then student can then continue...

Okay, but how do I fetch a specific piece of data from Firebase to display it to the user? I want to generalize the group data so that every time a group is created by a teacher, the student can access it using the code. I find it very confusing to manipulate and store data in Firebase.

Perhaps a data structure like this:

image

I will get to the blocks in a minute


Okay, thank you. My biggest difficulty is thinking about what to put in these red circles because I want all the group tags, not just one as shown in the image.

OK, a structure more like this:

image

You can then call back all the groups by name and by code.

Some example blocks to get you going...

(I used a label to display output, but you would normally assign the dictionary output to a variable, and manipulate from there)

image
I organized the groups like you showed. However, how do I check which group the code entered by the user belongs to? In this fixed image, for example, there are three groups (sociology, web, and history). If the user enters the code for one of the three, they should enter the corresponding group. But how do I do this if in App Inventor you have to pre-define which tag the value will be pulled from?

I explained above how I believe a student would gain access to a groups questions ?

The student needs to be given the name of the group they are to join, and the code, then if they sign in successfully (match codes) they then have access to the questions for that group.

How do you see it working ?

And what tag do I put in GetValue for this to happen?

If the group is science, then this:

image

returns the code to the app.

Student then types in the code they were given for science. If this matches the code from Firebase for science then the student has successfully "joined" the group.

Now they can use the code again to get the questions:

image

This how you would add a question to a code:

image

You will have to add them individually using the Firebase component, if you are to properly use the firebase structure as intended.

If you want to get serious with Firebase, then see here: