Spaces:
Running
Running
Upload 9 files
Browse files- src/views/InstructorView.js +53 -0
src/views/InstructorView.js
CHANGED
|
@@ -689,6 +689,7 @@ export function setupInstructorEvents() {
|
|
| 689 |
// Nav to Admin
|
| 690 |
if (navAdminBtn) {
|
| 691 |
navAdminBtn.addEventListener('click', () => {
|
|
|
|
| 692 |
window.location.hash = '#admin';
|
| 693 |
});
|
| 694 |
}
|
|
@@ -783,6 +784,35 @@ export function setupInstructorEvents() {
|
|
| 783 |
console.log("Hiding Modal and Setting Permissions...");
|
| 784 |
authModal.classList.add('hidden');
|
| 785 |
checkPermissions(instructorData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
} else {
|
| 787 |
console.warn("User logged in but not an instructor.");
|
| 788 |
// Show unauthorized message
|
|
@@ -1709,9 +1739,32 @@ export function setupInstructorEvents() {
|
|
| 1709 |
|
| 1710 |
if (tool === 'eraser') {
|
| 1711 |
currentMode = 'destination-out';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1712 |
} else {
|
| 1713 |
currentMode = 'source-over';
|
| 1714 |
currentPenColor = color;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1715 |
}
|
| 1716 |
updateCursorStyle();
|
| 1717 |
};
|
|
|
|
| 689 |
// Nav to Admin
|
| 690 |
if (navAdminBtn) {
|
| 691 |
navAdminBtn.addEventListener('click', () => {
|
| 692 |
+
localStorage.setItem('vibecoding_admin_referer', 'instructor');
|
| 693 |
window.location.hash = '#admin';
|
| 694 |
});
|
| 695 |
}
|
|
|
|
| 784 |
console.log("Hiding Modal and Setting Permissions...");
|
| 785 |
authModal.classList.add('hidden');
|
| 786 |
checkPermissions(instructorData);
|
| 787 |
+
|
| 788 |
+
// Auto-Restore Room View if exists
|
| 789 |
+
const savedRoomCode = localStorage.getItem('vibecoding_room_code');
|
| 790 |
+
if (savedRoomCode) {
|
| 791 |
+
console.log("Restoring Room Session:", savedRoomCode);
|
| 792 |
+
const roomInfo = document.getElementById('room-info');
|
| 793 |
+
const displayRoomCode = document.getElementById('display-room-code');
|
| 794 |
+
const createContainer = document.getElementById('create-room-container');
|
| 795 |
+
const dashboardContent = document.getElementById('dashboard-content');
|
| 796 |
+
|
| 797 |
+
// Restore UI
|
| 798 |
+
createContainer.classList.add('hidden');
|
| 799 |
+
roomInfo.classList.remove('hidden');
|
| 800 |
+
dashboardContent.classList.remove('hidden');
|
| 801 |
+
displayRoomCode.textContent = savedRoomCode;
|
| 802 |
+
|
| 803 |
+
// Re-subscribe locally using the existing updateDashboard logic if available,
|
| 804 |
+
// or we need to redefine the callback here.
|
| 805 |
+
// Since updateDashboard is inside createBtn scope, we can't mistakenly access it if it's not global.
|
| 806 |
+
// Wait, updateDashboard IS inside createBtn scope. That's a problem.
|
| 807 |
+
// We need to move updateDashboard out or duplicate the logic here.
|
| 808 |
+
// Duplicating logic for robustness:
|
| 809 |
+
subscribeToRoom(savedRoomCode, (data) => {
|
| 810 |
+
const users = Array.isArray(data) ? data : (data?.users ? Object.values(data.users) : []);
|
| 811 |
+
currentStudents = users;
|
| 812 |
+
renderTransposedHeatmap(users);
|
| 813 |
+
});
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
} else {
|
| 817 |
console.warn("User logged in but not an instructor.");
|
| 818 |
// Show unauthorized message
|
|
|
|
| 1739 |
|
| 1740 |
if (tool === 'eraser') {
|
| 1741 |
currentMode = 'destination-out';
|
| 1742 |
+
// Force larger eraser size (e.g., 3x current size or fixed large)
|
| 1743 |
+
// We'll multiply current selected size by 4 for better UX
|
| 1744 |
+
const multiplier = 4;
|
| 1745 |
+
// Store original explicitly if needed, but currentLineWidth is global.
|
| 1746 |
+
// We should dynamically adjust context lineWidth during draw, or just hack it here.
|
| 1747 |
+
// Hack: If we change currentLineWidth here, the UI size buttons might look wrong.
|
| 1748 |
+
// Better: Update cursor style only? No, actual draw needs it.
|
| 1749 |
+
// Let's set a separate 'actualWidth' used in draw, OR just change currentLineWidth temporarily?
|
| 1750 |
+
// Simpler: Just change it. When user clicks size button, it resets.
|
| 1751 |
+
// But if user clicks Pen back? We need to restore.
|
| 1752 |
+
// Let's rely on setPenTool being called with color.
|
| 1753 |
+
// When "Pen" is clicked, we usually don't call setPenTool with a saved size...
|
| 1754 |
+
// Actually, let's just use a large default for eraser, and keep currentLineWidth for Pen.
|
| 1755 |
+
// We need to change how draw() uses the width.
|
| 1756 |
+
// BUT, since we don't want to touch draw() deep inside:
|
| 1757 |
+
// We will hijack currentLineWidth.
|
| 1758 |
+
if (!window.savedPenWidth) window.savedPenWidth = currentLineWidth;
|
| 1759 |
+
currentLineWidth = window.savedPenWidth * 4;
|
| 1760 |
} else {
|
| 1761 |
currentMode = 'source-over';
|
| 1762 |
currentPenColor = color;
|
| 1763 |
+
// Restore pen width
|
| 1764 |
+
if (window.savedPenWidth) {
|
| 1765 |
+
currentLineWidth = window.savedPenWidth;
|
| 1766 |
+
window.savedPenWidth = null;
|
| 1767 |
+
}
|
| 1768 |
}
|
| 1769 |
updateCursorStyle();
|
| 1770 |
};
|