Lashtw commited on
Commit
03f1b1b
·
verified ·
1 Parent(s): 69e4fbd

Upload 9 files

Browse files
Files changed (1) hide show
  1. src/services/classroom.js +22 -0
src/services/classroom.js CHANGED
@@ -493,6 +493,28 @@ export async function getUser(userId) {
493
  * Removes a user from the classroom (Kick)
494
  * @param {string} userId
495
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  export async function removeUser(userId) {
497
  if (!userId) return;
498
  await deleteDoc(doc(db, USERS_COLLECTION, userId));
 
493
  * Removes a user from the classroom (Kick)
494
  * @param {string} userId
495
  */
496
+ /**
497
+ * Subscribes to a single user's progress for real-time updates
498
+ * @param {string} userId
499
+ * @param {Function} callback (progressMap) => void
500
+ * @returns {Function} unsubscribe
501
+ */
502
+ export function subscribeToUserProgress(userId, callback) {
503
+ const q = query(
504
+ collection(db, PROGRESS_COLLECTION),
505
+ where("userId", "==", userId)
506
+ );
507
+
508
+ return onSnapshot(q, (snapshot) => {
509
+ const progressMap = {};
510
+ snapshot.forEach(doc => {
511
+ const data = doc.data();
512
+ progressMap[data.challengeId] = data;
513
+ });
514
+ callback(progressMap);
515
+ });
516
+ }
517
+
518
  export async function removeUser(userId) {
519
  if (!userId) return;
520
  await deleteDoc(doc(db, USERS_COLLECTION, userId));