Spaces:
Running
Running
Upload 9 files
Browse files- src/services/auth.js +5 -1
- src/views/InstructorView.js +23 -22
src/services/auth.js
CHANGED
|
@@ -130,7 +130,11 @@ export async function checkInstructorPermission(user) {
|
|
| 130 |
|
| 131 |
if (snap.exists()) {
|
| 132 |
const data = snap.data();
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
return data;
|
| 135 |
}
|
| 136 |
|
|
|
|
| 130 |
|
| 131 |
if (snap.exists()) {
|
| 132 |
const data = snap.data();
|
| 133 |
+
try {
|
| 134 |
+
await updateDoc(instructorRef, { lastLogin: serverTimestamp() });
|
| 135 |
+
} catch (e) {
|
| 136 |
+
console.warn("Failed to update lastLogin (likely permission), proceeding anyway.", e);
|
| 137 |
+
}
|
| 138 |
return data;
|
| 139 |
}
|
| 140 |
|
src/views/InstructorView.js
CHANGED
|
@@ -340,37 +340,38 @@ export function setupInstructorEvents() {
|
|
| 340 |
// Utility for cleaning prompt indentation
|
| 341 |
function stripIndent(str) {
|
| 342 |
if (!str) return '';
|
| 343 |
-
// 1. Split into lines
|
| 344 |
-
let lines = str.split('\n');
|
| 345 |
|
| 346 |
-
//
|
| 347 |
-
|
| 348 |
-
lines.shift();
|
| 349 |
-
}
|
| 350 |
|
| 351 |
-
//
|
| 352 |
-
while (
|
| 353 |
-
|
| 354 |
}
|
| 355 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
if (lines.length === 0) return '';
|
| 357 |
|
| 358 |
-
//
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
const
|
| 363 |
-
|
| 364 |
-
|
|
|
|
|
|
|
| 365 |
|
| 366 |
-
if (minIndent ===
|
| 367 |
|
| 368 |
-
//
|
| 369 |
return lines.map(line => {
|
| 370 |
-
if (line.length
|
| 371 |
-
|
| 372 |
-
}
|
| 373 |
-
return line;
|
| 374 |
}).join('\n');
|
| 375 |
}
|
| 376 |
|
|
|
|
| 340 |
// Utility for cleaning prompt indentation
|
| 341 |
function stripIndent(str) {
|
| 342 |
if (!str) return '';
|
|
|
|
|
|
|
| 343 |
|
| 344 |
+
// 1. Normalize line endings
|
| 345 |
+
str = str.replace(/\r\n/g, '\n');
|
|
|
|
|
|
|
| 346 |
|
| 347 |
+
// 2. Remove initial empty lines
|
| 348 |
+
while (str.startsWith('\n')) {
|
| 349 |
+
str = str.slice(1);
|
| 350 |
}
|
| 351 |
|
| 352 |
+
// 3. Remove trailing whitespaces
|
| 353 |
+
str = str.trimEnd();
|
| 354 |
+
|
| 355 |
+
// 4. Split
|
| 356 |
+
const lines = str.split('\n');
|
| 357 |
if (lines.length === 0) return '';
|
| 358 |
|
| 359 |
+
// 5. Find common indent
|
| 360 |
+
let minIndent = null;
|
| 361 |
+
for (const line of lines) {
|
| 362 |
+
if (line.trim().length === 0) continue; // Skip empty lines
|
| 363 |
+
const currentIndent = line.match(/^\s*/)[0].length;
|
| 364 |
+
if (minIndent === null || currentIndent < minIndent) {
|
| 365 |
+
minIndent = currentIndent;
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
|
| 369 |
+
if (minIndent === null) return str; // All lines empty
|
| 370 |
|
| 371 |
+
// 6. Build result
|
| 372 |
return lines.map(line => {
|
| 373 |
+
if (line.trim().length === 0) return '';
|
| 374 |
+
return line.slice(minIndent);
|
|
|
|
|
|
|
| 375 |
}).join('\n');
|
| 376 |
}
|
| 377 |
|