Lashtw commited on
Commit
92eae8a
·
verified ·
1 Parent(s): 4829881

Upload 10 files

Browse files
Files changed (1) hide show
  1. src/views/InstructorView.js +38 -1
src/views/InstructorView.js CHANGED
@@ -115,7 +115,7 @@ export async function renderInstructorView() {
115
  <button id="btn-show-stage" class="bg-blue-600 hover:bg-blue-500 text-white font-bold py-3 px-8 rounded-xl flex items-center space-x-2 text-lg">
116
  <span>🖥️ 投放到大螢幕 (本機)</span>
117
  </button>
118
- <button id="btn-reject-task" class="bg-red-600 hover:bg-red-500 text-white font-bold py-3 px-8 rounded-xl flex items-center space-x-2 text-lg shadow-lg">
119
  <span>🛑 退回重做 (Reject)</span>
120
  </button>
121
  <!-- Future Feature: Send to Students -->
@@ -592,6 +592,42 @@ export function setupInstructorEvents() {
592
  }
593
  };
594
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  // Bind Reject Button Logic (Delegated)
596
  if (!window._rejectListenerAttached) {
597
  window._rejectListenerAttached = true;
@@ -633,6 +669,7 @@ export function setupInstructorEvents() {
633
  }
634
  });
635
  }
 
636
 
637
  let roomUnsubscribe = null;
638
  let currentInstructor = null;
 
115
  <button id="btn-show-stage" class="bg-blue-600 hover:bg-blue-500 text-white font-bold py-3 px-8 rounded-xl flex items-center space-x-2 text-lg">
116
  <span>🖥️ 投放到大螢幕 (本機)</span>
117
  </button>
118
+ <button id="btn-reject-task" onclick="window.rejectCurrentSubmission()" class="bg-red-600 hover:bg-red-500 text-white font-bold py-3 px-8 rounded-xl flex items-center space-x-2 text-lg shadow-lg">
119
  <span>🛑 退回重做 (Reject)</span>
120
  </button>
121
  <!-- Future Feature: Send to Students -->
 
592
  }
593
  };
594
 
595
+ // Global Reject Function
596
+ window.rejectCurrentSubmission = async () => {
597
+ const modal = document.getElementById('broadcast-modal');
598
+ if (!modal) return;
599
+
600
+ const userId = modal.dataset.userId;
601
+ const challengeId = modal.dataset.challengeId;
602
+ const roomCode = localStorage.getItem('vibecoding_room_code');
603
+
604
+ console.log('Reject attempt (Global) - Click details:', { dataset: modal.dataset, userId, challengeId, roomCode });
605
+
606
+ if (!userId || !challengeId) {
607
+ console.error('Missing userId or challengeId');
608
+ alert("錯誤:無法讀取學員資訊 (Missing ID)");
609
+ return;
610
+ }
611
+
612
+ if (confirm('確定要退回此學員的進度嗎?學員將需要重新作答。')) {
613
+ try {
614
+ const { resetProgress } = await import("../services/classroom.js");
615
+ const success = await resetProgress(userId, roomCode, challengeId);
616
+
617
+ if (success) {
618
+ alert('已成功退回,學員將需要重新作答。');
619
+ window.closeBroadcastModal();
620
+ } else {
621
+ alert('找不到該學員的進度紀錄,無法退回 (Document Not Found)。');
622
+ }
623
+ } catch (e) {
624
+ console.error("Reject failed:", e);
625
+ alert('退回失敗: ' + e.message);
626
+ }
627
+ }
628
+ };
629
+
630
+ /*
631
  // Bind Reject Button Logic (Delegated)
632
  if (!window._rejectListenerAttached) {
633
  window._rejectListenerAttached = true;
 
669
  }
670
  });
671
  }
672
+ */
673
 
674
  let roomUnsubscribe = null;
675
  let currentInstructor = null;