Ability for teacher to edit a student's gold/playername values in class page and 'block' students from the classroom
Editing gold values
For teacher class page, display gold as an editable text field (with input type number) with a pencil icon next to it.
Text field should become editable when you click the pencil icon, and the pencil icon is replaced with a 'Set gold' button that runs an appropriate Firestore mutation when clicked, and sets the text field back to non-editable (with a pencil icon).
You'll want to make sure the number field for gold is sanitized from bad inputs. An example of where this is already done in the app is the 'Max Completions' field when creating a repeatable!
Editing player name values
Same functionality as gold above, but no need to sanitize for a number input. Instead ensure the player name is not whitespace. CreateForumPostModal has a good 'containsnonwhitespacechars' function you can replicate
Block students from classroom:
The reason we're doing a banning strategy instead of a deleting strategy is because deletion will be very tedious; we would have to go through every place in our DB and delete references to the player, which is not easy. Plus a "deleted" student could just repetitively join the classroom.
Strategy:
Add a 'blockedUsers' list to the classroom document that holds user IDs of players that have been banned.
Add a "Block from classroom" button to player cards in teacher's class page that will add that player's ID to the 'blockedUsers' list (player and user IDs are the same)
Handling blocked students:
You will want to filter out blocked players from the list of players in class page for both teacher and student initially, so that they don't show up in leaderboard calculations and are not visible on student class page.
On teacher class page, display blocked students still but at the very bottom of class page. Also instead of the 'block from classroom' button, display a 'Unblock' button that will remove the player's ID from the 'blockedUsers' list
Handling a blocked user from their end:
In StudentView.tsx, if the player is on the blocked list, prevent them from viewing the classroom's page (return a 'you are blocked from this classroom' text instead)
In Home.tsx, if the user is on the classroom's banned list, do not display it
Accounting for blocked users in task/repeatables (tricky):
Creating new tasks/repeatables:
When creating a task, do not assign it to blocked users.
When creating a repeatable, do not assign it to blocked users.
You'll have to edit addTask and addRepeatable in mutations.js for this
Existing tasks/repeatables:
At the moment, we can leave any residual task/repeatable completion requests as-is and let the teacher reject/confirm them on their own
In TasksTableTeacher, ONLY for the display of the progress bar depicting completions of that task, filter out banned players in the calculation (do not actually mutate the assigned/completed/confirmed arrays in DB)
Player count:
In TeacherView and ClassStudent, subtract the length of the blockedUsers list from the playerList when displaying the number of total students.
Again it's important that we don't just remove the blocked player from the classroom's player list, because that will allow the blocked player to rejoin the classroom.
Class Page Expansions
Overview
Ability for teacher to edit a student's gold/playername values in class page and 'block' students from the classroom
Editing gold values
Editing player name values
CreateForumPostModal
has a good 'containsnonwhitespacechars' function you can replicateBlock students from classroom:
Strategy:
Handling blocked students:
StudentView.tsx
, if the player is on the blocked list, prevent them from viewing the classroom's page (return a 'you are blocked from this classroom' text instead)Home.tsx
, if the user is on the classroom's banned list, do not display itaddTask
andaddRepeatable
inmutations.js
for thisTasksTableTeacher
, ONLY for the display of the progress bar depicting completions of that task, filter out banned players in the calculation (do not actually mutate the assigned/completed/confirmed arrays in DB)TeacherView
andClassStudent
, subtract the length of theblockedUsers
list from theplayerList
when displaying the number of total students.