Hi, I'm trying to implement teams. But I still haven't decided which is the best way to do it. For example: I want every teacher to create a classroom. And to that class add students. And then return the list of classrooms to the users and teachers. But what would be the best way to join the classroom with teams. 1. Save the $id of the team in the classroom model In this way, I would have to create a relationship (many to many ) Users-Classroom and I think that it would not be optimal since when obtaining the details of a user it would obtain the details of the classrooms. Maybe I could create a list of $ids of the teams to avoid getting data I don't want; But this would also be more complex because you would have to create more functions to edit this list. 2. Save the $id of the classroom in the team preferences In this way, it would have to obtain all the teams to which the user has access. But this would cause me problems if I later want to create a team for something else, such as user groups. It could perhaps be solved by creating a team preference. 3.Create the team with the $id=$id of the classroom I'm sorry but I'm a bit confused. If someone can guide me with the optimal way, I would appreciate it. Greetings
Hey,
First of all for the teams aspect are you planning to use Appwrite https://appwrite.io/docs/client/teams ?
Yes
Cool Let me go over it couple of minutes
So you have user And each of one of them can be either teacher or a student. no one can be both? Then you have Classes that each teacher can be a teacher within it and and student can learn?
That's means that any user should have a many-to-many relation ships with the classes
Did I got the idea correct?
Correct in everything, and yes only the teacher or the one who creates the classroom would have a role like admin
Okay
So this is the way I would go with it
I'll create Team for each class. Then each team will have three roles
- Owner
- Teacher
- Student
Then each teacher is added to a team and then assigned to class as Owner + Teacher. Each student is also added to a team and then assigned as Student.
So for example if we have 3 Teams
- Math
- Science
- Cooking
To get all the teacher in Math we can write (JavaScript but you can easily adapt to any other Appwrite client side SDKs)
const teamMembers = await teams.listMemberships('MathClassID',[
Query.search('role','teacher'),
])
and we want to get all the students in Math we can write
const teamMembers = await teams.listMemberships('MathClassID',[
Query.search('role','student'),
])
To get all users memberships and roles we can use the Server SDK as such
const memberships = await users.listMemberships('StudentID');
In case this student is in all classes we get something like this: Notice I've removed a lot of information from the object to make it easy to read
{
"total" : 3,
"memberships": [
{
"teamName": "Math",
"roles" : ["student"]
},
{
"teamName": "Science",
"roles" : ["student"]
},
{
"teamName": "Cooking",
"roles" : ["student"]
}
]
}
The only downside in the last step is that it can be used only in Server side SDK. But for that you can easily create a function.
Hope it makes sense
Great job friend, the structure seems good to me, but I still have a question where I would store the ClassID. Since, for example, each teacher creates his group-classroom of mathematics. There would come the doubt that i mentioned.
Ohh I got you
Missed that part
You can create more roles
So Let's say teach A Teaches Students 1,2 and 3 Math
Then teach A will be in the TeamMath
with the roles ['teacher','owner','teacherid']
And each student will have the roles ['student','teacherid']
;
By using the teacherid as role you can make sure that you'll create a unique lists of
- Teacher
- Topic
- Students For each class
Interesting, I hadn't thought of that way. I will implement it if it works for me. Thank you so much
Cool 👍
Recommended threads
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...
- What Query's are valid for GetDocument?
Documentation shows that Queries are valid here, but doesn't explain which queries are valid. At first I presumed this to be a bug, but before creating a githu...