Spaces:
Running
Running
Upload 9 files
Browse files- src/services/classroom.js +6 -3
- src/views/InstructorView.js +1 -0
src/services/classroom.js
CHANGED
|
@@ -24,15 +24,18 @@ const CHALLENGES_COLLECTION = "challenges";
|
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Creates a new classroom room
|
|
|
|
|
|
|
| 27 |
* @returns {Promise<string>} The room code
|
| 28 |
*/
|
| 29 |
-
export async function createRoom() {
|
| 30 |
-
const roomCode = Math.floor(1000 + Math.random() * 9000).toString();
|
| 31 |
const roomRef = doc(db, ROOMS_COLLECTION, roomCode);
|
| 32 |
|
| 33 |
await setDoc(roomRef, {
|
| 34 |
createdAt: serverTimestamp(),
|
| 35 |
-
active: true
|
|
|
|
| 36 |
});
|
| 37 |
|
| 38 |
return roomCode;
|
|
|
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Creates a new classroom room
|
| 27 |
+
* @param {string} promotedCode - Optional custom code
|
| 28 |
+
* @param {string} hostName - Optional host name
|
| 29 |
* @returns {Promise<string>} The room code
|
| 30 |
*/
|
| 31 |
+
export async function createRoom(promotedCode = null, hostName = 'Unknown') {
|
| 32 |
+
const roomCode = promotedCode || Math.floor(1000 + Math.random() * 9000).toString();
|
| 33 |
const roomRef = doc(db, ROOMS_COLLECTION, roomCode);
|
| 34 |
|
| 35 |
await setDoc(roomRef, {
|
| 36 |
createdAt: serverTimestamp(),
|
| 37 |
+
active: true,
|
| 38 |
+
host: hostName
|
| 39 |
});
|
| 40 |
|
| 41 |
return roomCode;
|
src/views/InstructorView.js
CHANGED
|
@@ -14,6 +14,7 @@ export async function renderInstructorView() {
|
|
| 14 |
// Pre-fetch challenges for table headers
|
| 15 |
try {
|
| 16 |
cachedChallenges = await getChallenges();
|
|
|
|
| 17 |
} catch (e) {
|
| 18 |
console.error("Failed header load", e);
|
| 19 |
}
|
|
|
|
| 14 |
// Pre-fetch challenges for table headers
|
| 15 |
try {
|
| 16 |
cachedChallenges = await getChallenges();
|
| 17 |
+
window.cachedChallenges = cachedChallenges; // Expose for dashboard
|
| 18 |
} catch (e) {
|
| 19 |
console.error("Failed header load", e);
|
| 20 |
}
|