testing mode going on

This commit is contained in:
subhajit 2026-07-21 16:49:58 +05:30
parent 167090816e
commit 5b61495e35
10 changed files with 1526 additions and 405 deletions

View File

@ -309,6 +309,23 @@ public function sendWarning(Request $request, $id)
return response()->json(['success' => true, 'warning' => $warning]);
}
/**
* Send Real-Time Chat Message from Candidate to Interviewer/HR.
*/
public function candidateSendMessage(Request $request, $id)
{
$interview = Interview::findOrFail($id);
$request->validate(['message' => 'required|string|max:500']);
$warning = InterviewWarning::create([
'interview_id' => $interview->id,
'message' => $request->message,
'sent_by' => null, // null sent_by indicates candidate sender
]);
return response()->json(['success' => true, 'warning' => $warning]);
}
/**
* Live Sync Candidate Code (before submission).
*/
@ -385,6 +402,7 @@ public function getPollData($id)
return response()->json([
'status' => $interview->status,
'call_status' => $interview->call_status ?? 'idle',
'submitted_code' => $interview->submitted_code,
'submitted_language' => $interview->submitted_language,
'code_output' => $interview->code_output,
@ -398,6 +416,17 @@ public function getPollData($id)
]);
}
/**
* Update Interview Call Session Status (active, idle, ended).
*/
public function updateCallStatus(Request $request, $id)
{
$interview = Interview::findOrFail($id);
$status = $request->input('call_status', 'idle');
$interview->update(['call_status' => $status]);
return response()->json(['success' => true, 'call_status' => $status]);
}
/**
* Save Candidate Silent Video Recording Blob / Snapshot Stream.
*/
@ -416,4 +445,75 @@ public function uploadRecording(Request $request, $id)
return response()->json(['success' => false, 'message' => 'No video payload received']);
}
/**
* Generate Comprehensive Executive Candidate Evaluation & Behavioral Report (PDF View).
*/
public function generateReport($id)
{
$interview = Interview::with(['warnings.sender'])->findOrFail($id);
$logs = $interview->proctor_logs ?? [];
$tabSwitches = 0;
$focusLosses = 0;
$gazeAnomalies = 0;
$pasteEvents = 0;
foreach ($logs as $l) {
$type = $l['type'] ?? '';
if ($type === 'tab_switch') $tabSwitches++;
if ($type === 'focus_lost') $focusLosses++;
if ($type === 'gaze_anomaly') $gazeAnomalies++;
if ($type === 'paste_event') $pasteEvents++;
}
$totalViolations = count($logs);
// Calculate Integrity Score %
if ($totalViolations === 0) {
$integrityScore = 100;
$integrityLabel = 'Exceptional Integrity';
$integrityColor = '#10b981';
} elseif ($totalViolations <= 2) {
$integrityScore = 85;
$integrityLabel = 'Low Behavioral Risk';
$integrityColor = '#06b6d4';
} elseif ($totalViolations <= 5) {
$integrityScore = 60;
$integrityLabel = 'Moderate Integrity Concern';
$integrityColor = '#f59e0b';
} else {
$integrityScore = 25;
$integrityLabel = 'High Malpractice Risk';
$integrityColor = '#ef4444';
}
// Calculate Technical Code Score
$codeScore = 0;
if (!empty($interview->submitted_code)) {
$codeScore += 50;
if (!empty($interview->code_output) && !str_contains(strtolower($interview->code_output), 'error')) {
$codeScore += 40;
} else {
$codeScore += 20;
}
if (!empty($interview->candidate_notes) || !empty($interview->candidate_drawing)) {
$codeScore += 10;
}
}
$codeScore = min(100, $codeScore);
return view('interview.report', compact(
'interview',
'logs',
'tabSwitches',
'focusLosses',
'gazeAnomalies',
'pasteEvents',
'integrityScore',
'integrityLabel',
'integrityColor',
'codeScore'
));
}
}

View File

@ -29,6 +29,7 @@ class Interview extends Model
'candidate_drawing',
'blocked_ip',
'created_by',
'call_status',
];
protected $casts = [

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('interviews', function (Blueprint $table) {
$table->string('call_status')->default('idle')->after('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('interviews', function (Blueprint $table) {
$table->dropColumn('call_status');
});
}
};

View File

@ -388,12 +388,6 @@
</div>
Sign in with Microsoft
</a>
<div class="divider">OR</div>
<a href="{{ route('interview.candidate.login') }}" class="btn btn-primary" style="text-decoration: none; background: linear-gradient(135deg, #6366f1 0%, #0078d4 100%);">
Candidate Assessment Login
</a>
</div>
</div>

View File

@ -874,7 +874,7 @@
</button>
@if($user->hasActiveInterviewZone())
<a href="{{ route('interview.index') }}" class="nav-action-btn" style="background: rgba(16, 185, 129, 0.15); color: #34d399; border-color: rgba(16, 185, 129, 0.35); text-decoration: none;" title="Active Interview Zone">
<a href="{{ route('interview.index') }}" target="_blank" class="nav-action-btn" style="background: rgba(16, 185, 129, 0.15); color: #34d399; border-color: rgba(16, 185, 129, 0.35); text-decoration: none;" title="Active Interview Zone">
Interview Zone <span style="font-size: 0.65rem; background: #10b981; color: white; padding: 2px 6px; border-radius: 999px; margin-left: 4px; font-weight: 700;">LIVE</span>
</a>
@endif

View File

@ -10,9 +10,10 @@
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Instrument+Sans:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<!-- Monaco Code Editor Loader & PeerJS Realtime WebRTC Call -->
<!-- Monaco Code Editor Loader & PeerJS Realtime WebRTC Call & SweetAlert2 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs/loader.min.js"></script>
<script src="https://unpkg.com/peerjs@1.5.2/dist/peerjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
:root {
@ -127,6 +128,8 @@
.webcam-box {
width: 100%;
height: 180px;
min-height: 180px;
flex-shrink: 0;
background: #000;
border-radius: 12px;
border: 2px solid var(--card-border);
@ -229,6 +232,10 @@
<button onclick="submitSolution()" class="btn-ide btn-ide-primary">
Submit Final Solution
</button>
<button onclick="candidateLogoutAction()" class="btn-ide" style="background: rgba(239,68,68,0.2); border-color: #ef4444; color: #fca5a5; font-weight: 700;">
🚪 Logout
</button>
</div>
</header>
@ -342,12 +349,31 @@
<button id="toggle-cam-btn" onclick="toggleCam()" class="btn-ide" style="flex: 1; padding: 8px; font-size: 0.75rem; background: rgba(16,185,129,0.2); border-color: #10b981;">
📷 Cam On
</button>
<button id="leave-call-btn" onclick="candidateLeaveCall()" class="btn-ide" style="padding: 8px; font-size: 0.75rem; background: rgba(239,68,68,0.2); border-color: #ef4444; color: #fca5a5;" title="Leave 2-Way Call">
🚪 Leave Call
</button>
</div>
<button id="share-screen-btn" onclick="startScreenShare()" class="btn-ide btn-ide-run" style="width: 100%; padding: 10px; font-size: 0.8rem; background: linear-gradient(135deg, #6366f1 0%, #0078d4 100%);">
🖥️ Share Screen with Interviewer
</button>
</div>
<!-- 2-Way Real-Time Chat Container with Interviewer/Panelist -->
<div style="background: rgba(15,23,42,0.8); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px; margin-top: 10px;">
<div style="font-size: 0.8rem; font-weight: 700; color: white; margin-bottom: 8px; display: flex; align-items: center; gap: 6px;">
💬 Live Chat with Interviewer
</div>
<div id="candidate-chat-history" style="background: #050811; border: 1px solid var(--card-border); border-radius: 10px; padding: 8px; height: 130px; overflow-y: auto; font-size: 0.72rem; margin-bottom: 8px;">
<div style="color: #94a3b8; font-style: italic; text-align: center; padding-top: 40px;">No messages yet. Send a message below.</div>
</div>
<div style="display: flex; gap: 6px;">
<input type="text" id="candidate-chat-input" placeholder="Type message to panelist..." onkeydown="if(event.key==='Enter') sendCandidateMessage()" class="form-input" style="font-size: 0.75rem; background: #0b0f19; border: 1px solid var(--card-border); padding: 6px 10px; flex: 1;">
<button onclick="sendCandidateMessage()" class="btn-ide" style="padding: 6px 10px; font-size: 0.75rem; background: #6366f1; border: none; font-weight: 600;">
Send
</button>
</div>
</div>
</div>
</div>
@ -494,59 +520,207 @@ function logViolation(type, details) {
});
}
// 4. WebRTC Real-Time 2-Way Interview Call Setup
// 4. WebRTC Real-Time 2-Way Interview Call Setup (Dual Signaling: BroadcastChannel + PeerJS)
let localMediaStream = null;
let peerInstance = null;
let candidatePeerConnection = null;
let screenShareStream = null;
let isMicEnabled = true;
let isCamEnabled = true;
let activeCallInstance = null;
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => {
localMediaStream = stream;
document.getElementById('webcam').srcObject = stream;
initPeerCall();
})
.catch(err => {
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
.then(stream => {
localMediaStream = stream;
document.getElementById('webcam').srcObject = stream;
initPeerCall();
});
const callSigChannel = new BroadcastChannel('webrtc_call_' + interviewId);
callSigChannel.onmessage = async (event) => {
const msg = event.data;
if (!msg) return;
if (msg.type === 'interviewer_joined' || msg.type === 'offer') {
if (msg.offer && msg.sender !== 'candidate') {
await handleInterviewerOffer(msg.offer);
} else if (localMediaStream) {
sendOfferToInterviewer();
}
} else if (msg.type === 'answer' && msg.sender !== 'candidate' && candidatePeerConnection) {
await candidatePeerConnection.setRemoteDescription(new RTCSessionDescription(msg.answer));
} else if (msg.type === 'ice-candidate' && msg.sender !== 'candidate' && candidatePeerConnection && msg.candidate) {
try {
await candidatePeerConnection.addIceCandidate(new RTCIceCandidate(msg.candidate));
} catch(e) {}
} else if (msg.type === 'end_call_all') {
candidateLeaveCall();
}
};
async function createCandidatePeerConnection() {
if (candidatePeerConnection) return candidatePeerConnection;
candidatePeerConnection = new RTCPeerConnection({
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: 'stun:stun2.l.google.com:19302' }
]
});
function initPeerCall() {
if (localMediaStream) {
localMediaStream.getTracks().forEach(track => {
candidatePeerConnection.addTrack(track, localMediaStream);
});
}
candidatePeerConnection.ontrack = (event) => {
const remoteVideo = document.getElementById('interviewer-video');
const placeholder = document.getElementById('interviewer-video-placeholder');
if (remoteVideo && event.streams[0]) {
remoteVideo.srcObject = event.streams[0];
remoteVideo.play().catch(e => console.log(e));
}
if (placeholder) placeholder.style.display = 'none';
document.getElementById('call-status-badge').innerText = 'CONNECTED';
document.getElementById('call-status-badge').style.background = 'rgba(16,185,129,0.3)';
document.getElementById('call-status-badge').style.color = '#34d399';
};
candidatePeerConnection.onicecandidate = (event) => {
if (event.candidate) {
callSigChannel.postMessage({ type: 'ice-candidate', candidate: event.candidate, sender: 'candidate' });
}
};
return candidatePeerConnection;
}
async function sendOfferToInterviewer() {
const pc = await createCandidatePeerConnection();
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);
callSigChannel.postMessage({ type: 'offer', offer: offer, sender: 'candidate' });
}
async function handleInterviewerOffer(offer) {
const pc = await createCandidatePeerConnection();
await pc.setRemoteDescription(new RTCSessionDescription(offer));
const answer = await pc.createAnswer();
await pc.setLocalDescription(answer);
callSigChannel.postMessage({ type: 'answer', answer: answer, sender: 'candidate' });
}
function initCandidatePeer() {
if (typeof Peer === 'undefined') return;
const peerId = 'cand_' + interviewId;
peerInstance = new Peer(peerId);
if (peerInstance) {
try { peerInstance.destroy(); } catch(e) {}
}
peerInstance = new Peer(peerId, {
config: {
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: 'stun:stun2.l.google.com:19302' }
]
}
});
peerInstance.on('open', id => {
console.log('Candidate WebRTC Peer Registered:', id);
});
// Answer incoming call from Interviewer
peerInstance.on('call', call => {
call.answer(localMediaStream);
activeCallInstance = call;
const sendStream = localMediaStream || new MediaStream();
call.answer(sendStream);
call.on('stream', remoteStream => {
const remoteVideo = document.getElementById('interviewer-video');
const placeholder = document.getElementById('interviewer-video-placeholder');
if (remoteVideo) remoteVideo.srcObject = remoteStream;
if (remoteVideo) {
remoteVideo.srcObject = remoteStream;
remoteVideo.play().catch(e => console.log(e));
}
if (placeholder) placeholder.style.display = 'none';
document.getElementById('call-status-badge').innerText = 'CONNECTED';
document.getElementById('call-status-badge').style.background = 'rgba(16,185,129,0.3)';
document.getElementById('call-status-badge').style.color = '#34d399';
});
call.on('close', () => {
const placeholder = document.getElementById('interviewer-video-placeholder');
if (placeholder) placeholder.style.display = 'flex';
document.getElementById('call-status-badge').innerText = 'READY';
candidateLeaveCall();
});
});
}
initCandidatePeer();
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => {
localMediaStream = stream;
const vid = document.getElementById('webcam');
if (vid) {
vid.muted = true;
vid.srcObject = stream;
vid.play().catch(e => console.log(e));
}
callSigChannel.postMessage({ type: 'candidate_ready' });
})
.catch(err => {
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
.then(stream => {
localMediaStream = stream;
const vid = document.getElementById('webcam');
if (vid) {
vid.muted = true;
vid.srcObject = stream;
vid.play().catch(e => console.log(e));
}
callSigChannel.postMessage({ type: 'candidate_ready' });
});
});
function candidateLogoutAction() {
if (typeof Swal !== 'undefined') {
Swal.fire({
title: 'Logout of Assessment?',
text: 'Are you sure you want to exit the Candidate Assessment Room?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#ef4444',
cancelButtonColor: '#475569',
confirmButtonText: 'Yes, Logout'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = "{{ route('interview.candidate.login') }}";
}
});
} else {
if (confirm('Logout of Assessment?')) {
window.location.href = "{{ route('interview.candidate.login') }}";
}
}
}
function candidateLeaveCall() {
if (activeCallInstance) {
try { activeCallInstance.close(); } catch(e) {}
activeCallInstance = null;
}
const remoteVideo = document.getElementById('interviewer-video');
if (remoteVideo) remoteVideo.srcObject = null;
const placeholder = document.getElementById('interviewer-video-placeholder');
if (placeholder) placeholder.style.display = 'flex';
const badge = document.getElementById('call-status-badge');
if (badge) {
badge.innerText = 'DISCONNECTED (LEAVE)';
badge.style.background = 'rgba(239,68,68,0.2)';
badge.style.color = '#fca5a5';
}
}
function toggleMic() {
if (!localMediaStream) return;
const audioTracks = localMediaStream.getAudioTracks();
@ -627,20 +801,69 @@ function analyzeCameraFrame() {
}
}
// 5. Silent Warning Polling
setInterval(() => {
// 5. 2-Way Real-Time Chat Message Polling (No popup alerts!)
function pollCandidateChat() {
fetch(`{{ route('interview.poll', $interview->id) }}`)
.then(r => r.json())
.then(data => {
const chatHistory = document.getElementById('candidate-chat-history');
if (!chatHistory) return;
if (data.call_status === 'ended') {
candidateLeaveCall();
const badge = document.getElementById('call-status-badge');
if (badge) {
badge.innerText = 'CALL ENDED BY HOST';
badge.style.background = 'rgba(239,68,68,0.2)';
badge.style.color = '#fca5a5';
}
}
if (data.warnings && data.warnings.length > 0) {
const lastWarn = data.warnings[data.warnings.length - 1];
document.getElementById('warning-text').innerText = lastWarn.message;
const banner = document.getElementById('warning-banner');
banner.style.display = 'block';
setTimeout(() => { banner.style.display = 'none'; }, 6000);
let html = '';
data.warnings.forEach(w => {
const isInterviewer = w.sent_by !== null;
const senderName = isInterviewer ? (w.sender ? w.sender.name : 'Interviewer / Panelist') : 'You (Candidate)';
const badgeColor = isInterviewer ? '#6366f1' : '#38bdf8';
const bgColor = isInterviewer ? 'rgba(99,102,241,0.1)' : 'rgba(56,189,248,0.1)';
html += `<div style="margin-bottom:8px; background:${bgColor}; padding:8px 10px; border-radius:8px; border-left:3px solid ${badgeColor};">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:4px;">
<strong style="color:${badgeColor}; font-size:0.75rem;">${senderName}</strong>
<span style="font-size:0.65rem; color:#94a3b8;">${new Date(w.created_at || Date.now()).toLocaleTimeString()}</span>
</div>
<div style="color: #ffffff !important; font-size:0.85rem; font-weight:500; line-height:1.4;">${w.message}</div>
</div>`;
});
chatHistory.innerHTML = html;
chatHistory.scrollTop = chatHistory.scrollHeight;
}
});
}, 5000);
}
setInterval(pollCandidateChat, 3000);
pollCandidateChat();
function sendCandidateMessage() {
const input = document.getElementById('candidate-chat-input');
const msg = input.value.trim();
if (!msg) return;
input.value = '';
fetch(`{{ route('interview.candidate.send-message', $interview->id) }}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({ message: msg })
})
.then(r => r.json())
.then(res => {
if (res.success) {
pollCandidateChat();
}
});
}
// --- NOTEPAD & CANVAS DRAWING HANDLERS ---
let notesTimeout = null;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,406 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Executive Evaluation Report - {{ $interview->candidate_name }} | SingleLogin</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--primary: #0f172a;
--accent: #6366f1;
--text-dark: #0f172a;
--text-muted: #64748b;
--card-bg: #f8fafc;
--border: #e2e8f0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Instrument Sans', sans-serif;
background-color: #f1f5f9;
color: var(--text-dark);
line-height: 1.5;
padding: 40px 20px;
}
.report-container {
max-width: 900px;
margin: 0 auto;
background: white;
border-radius: 16px;
box-shadow: 0 20px 40px rgba(0,0,0,0.08);
border: 1px solid var(--border);
padding: 40px;
position: relative;
}
.header-bar {
display: flex;
justify-content: space-between;
align-items: flex-start;
border-bottom: 2px solid var(--accent);
padding-bottom: 20px;
margin-bottom: 24px;
}
.brand-title {
font-family: 'Outfit', sans-serif;
font-size: 1.6rem;
font-weight: 800;
color: var(--primary);
display: flex;
align-items: center;
gap: 10px;
}
.report-badge {
background: rgba(99,102,241,0.1);
color: var(--accent);
font-size: 0.75rem;
font-weight: 700;
padding: 4px 12px;
border-radius: 999px;
text-transform: uppercase;
}
.meta-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
background: var(--card-bg);
border-radius: 12px;
padding: 16px;
border: 1px solid var(--border);
margin-bottom: 28px;
}
.meta-item label {
display: block;
font-size: 0.7rem;
text-transform: uppercase;
font-weight: 700;
color: var(--text-muted);
margin-bottom: 4px;
}
.meta-item span {
font-weight: 700;
font-size: 0.9rem;
color: var(--primary);
}
.score-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 28px;
}
.score-card {
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 14px;
padding: 20px;
position: relative;
}
.score-val {
font-family: 'Outfit', sans-serif;
font-size: 2.4rem;
font-weight: 800;
margin-top: 6px;
}
.section-heading {
font-family: 'Outfit', sans-serif;
font-size: 1.1rem;
font-weight: 700;
color: var(--primary);
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
}
.audit-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 28px;
font-size: 0.8rem;
}
.audit-table th {
background: #f1f5f9;
color: var(--text-muted);
font-weight: 700;
text-align: left;
padding: 10px;
border-bottom: 1px solid var(--border);
}
.audit-table td {
padding: 10px;
border-bottom: 1px solid #edf2f7;
}
.code-box {
background: #0f172a;
color: #38bdf8;
border-radius: 12px;
padding: 18px;
font-family: 'Fira Code', monospace;
font-size: 0.8rem;
white-space: pre-wrap;
margin-bottom: 20px;
max-height: 300px;
overflow-y: auto;
}
.output-box {
background: #050811;
color: #34d399;
border-radius: 10px;
padding: 14px;
font-family: 'Fira Code', monospace;
font-size: 0.75rem;
white-space: pre-wrap;
margin-bottom: 28px;
}
.print-btn {
position: fixed;
bottom: 30px;
right: 30px;
background: var(--accent);
color: white;
border: none;
padding: 14px 28px;
border-radius: 999px;
font-weight: 700;
font-size: 0.9rem;
box-shadow: 0 10px 25px rgba(99,102,241,0.4);
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
z-index: 100;
}
@media print {
body {
background: white;
padding: 0;
}
.report-container {
box-shadow: none;
border: none;
max-width: 100%;
padding: 0;
}
.print-btn {
display: none;
}
}
</style>
</head>
<body>
<button onclick="window.print()" class="print-btn">
📥 Download / Print Executive PDF Report
</button>
<div class="report-container">
<!-- Header -->
<div class="header-bar">
<div>
<div class="brand-title">
SingleLogin Enterprise Assessment
</div>
<div style="font-size: 0.8rem; color: var(--text-muted); margin-top: 4px;">
Candidate Technical Competency & Behavioral Audit Report
</div>
</div>
<div style="text-align: right;">
<span class="report-badge">Executive Summary</span>
<div style="font-size: 0.7rem; color: var(--text-muted); margin-top: 6px;">
Report ID: RPT-{{ $interview->submission_unique_id }}
</div>
<div style="font-size: 0.7rem; color: var(--text-muted);">
Date: {{ now()->format('M d, Y - H:i:s T') }}
</div>
</div>
</div>
<!-- Meta Grid -->
<div class="meta-grid">
<div class="meta-item">
<label>Candidate Name</label>
<span>{{ $interview->candidate_name }}</span>
</div>
<div class="meta-item">
<label>Email Address</label>
<span style="font-size: 0.8rem;">{{ $interview->candidate_email }}</span>
</div>
<div class="meta-item">
<label>Language & Tech</label>
<span>{{ strtoupper($interview->language) }}</span>
</div>
<div class="meta-item">
<label>Assessment Status</label>
<span style="color: {{ $interview->status === 'completed' ? '#10b981' : ($interview->status === 'blocked' ? '#ef4444' : '#6366f1') }};">
{{ strtoupper($interview->status) }}
</span>
</div>
</div>
<!-- Scores Summary Grid -->
<div class="score-grid">
<!-- Behavioral Integrity Score -->
<div class="score-card" style="border-left: 5px solid {{ $integrityColor }};">
<div style="font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;">
🛡️ Behavioral Integrity Rating
</div>
<div class="score-val" style="color: {{ $integrityColor }};">
{{ $integrityScore }}%
</div>
<div style="font-size: 0.8rem; font-weight: 700; color: {{ $integrityColor }}; margin-top: 4px;">
{{ $integrityLabel }}
</div>
<div style="font-size: 0.7rem; color: var(--text-muted); margin-top: 6px;">
Recorded Violations: <strong>{{ count($logs) }} incident(s)</strong>
</div>
</div>
<!-- Technical Score -->
<div class="score-card" style="border-left: 5px solid #6366f1;">
<div style="font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;">
💻 Technical Code Competency
</div>
<div class="score-val" style="color: #6366f1;">
{{ $codeScore }} / 100
</div>
<div style="font-size: 0.8rem; font-weight: 700; color: #6366f1; margin-top: 4px;">
{{ $codeScore >= 80 ? 'Strong Technical Match' : ($codeScore >= 50 ? 'Moderate Competency' : 'Needs Further Review') }}
</div>
<div style="font-size: 0.7rem; color: var(--text-muted); margin-top: 6px;">
Solution Code: <strong>{{ !empty($interview->submitted_code) ? 'Submitted' : 'Pending' }}</strong>
</div>
</div>
</div>
<!-- Proctoring Violation Metrics & Breakdown -->
<div class="section-heading">
🔍 Behavioral Audit & Proctoring Incident Breakdown
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;">
<div style="background: var(--card-bg); padding: 12px; border-radius: 10px; border: 1px solid var(--border); text-align: center;">
<div style="font-size: 1.2rem; font-weight: 800; color: #ef4444;">{{ $tabSwitches }}</div>
<div style="font-size: 0.65rem; color: var(--text-muted); font-weight: 700;">Tab Switches</div>
</div>
<div style="background: var(--card-bg); padding: 12px; border-radius: 10px; border: 1px solid var(--border); text-align: center;">
<div style="font-size: 1.2rem; font-weight: 800; color: #f59e0b;">{{ $focusLosses }}</div>
<div style="font-size: 0.65rem; color: var(--text-muted); font-weight: 700;">Focus Lost</div>
</div>
<div style="background: var(--card-bg); padding: 12px; border-radius: 10px; border: 1px solid var(--border); text-align: center;">
<div style="font-size: 1.2rem; font-weight: 800; color: #38bdf8;">{{ $gazeAnomalies }}</div>
<div style="font-size: 0.65rem; color: var(--text-muted); font-weight: 700;">Gaze Anomalies</div>
</div>
<div style="background: var(--card-bg); padding: 12px; border-radius: 10px; border: 1px solid var(--border); text-align: center;">
<div style="font-size: 1.2rem; font-weight: 800; color: #818cf8;">{{ $pasteEvents }}</div>
<div style="font-size: 0.65rem; color: var(--text-muted); font-weight: 700;">Code Pastes</div>
</div>
</div>
@if(count($logs) > 0)
<table class="audit-table">
<thead>
<tr>
<th>Timestamp</th>
<th>Violation Category</th>
<th>Audit Details</th>
</tr>
</thead>
<tbody>
@foreach($logs as $log)
<tr>
<td style="color: var(--text-muted);">{{ \Carbon\Carbon::parse($log['timestamp'])->format('H:i:s T') }}</td>
<td><strong>{{ strtoupper($log['type']) }}</strong></td>
<td>{{ $log['details'] ?? 'Incident flagged by proctoring engine.' }}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div style="background: rgba(16,185,129,0.1); color: #10b981; padding: 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; margin-bottom: 28px;">
Zero proctoring violations or malpractice detected during the session.
</div>
@endif
<!-- Code Solution Block -->
<div class="section-heading">
💻 Submitted Code Solution ({{ strtoupper($interview->submitted_language ?? $interview->language) }})
</div>
<div class="code-box">
{{ $interview->submitted_code ?? '// No code solution submitted by candidate.' }}
</div>
<!-- Code Output Block -->
<div class="section-heading">
🖥️ Engine Execution Stdout Output
</div>
<div class="output-box">
{{ $interview->code_output ?? 'No execution output recorded.' }}
</div>
<!-- Candidate Notes & Drawing Section -->
@if(!empty($interview->candidate_notes) || !empty($interview->candidate_drawing))
<div class="section-heading">
📝 Workspace Artifacts (Scratchpad Notes & Architecture Drawing)
</div>
<div style="background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 28px;">
@if(!empty($interview->candidate_notes))
<div style="font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px;">CANDIDATE NOTES:</div>
<pre style="font-family: monospace; font-size: 0.8rem; background: white; padding: 10px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 12px;">{{ $interview->candidate_notes }}</pre>
@endif
@if(!empty($interview->candidate_drawing))
<div style="font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px;">CANDIDATE DRAWING DIAGRAM:</div>
<img src="{{ $interview->candidate_drawing }}" alt="Candidate Drawing" style="max-width: 100%; max-height: 250px; border-radius: 8px; border: 1px solid var(--border);" />
@endif
</div>
@endif
<!-- Panel Sign-Off Block -->
<div style="border-top: 2px solid var(--border); padding-top: 20px; display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;">
HR & Lead Panel Approval
</div>
<div style="font-weight: 700; font-size: 0.9rem; color: var(--primary); margin-top: 4px;">
SingleLogin Enterprise HR Board
</div>
</div>
<div style="text-align: right;">
<div style="font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;">
Final Recommendation
</div>
<div style="font-weight: 800; font-size: 1rem; color: {{ $integrityScore >= 80 && $codeScore >= 50 ? '#10b981' : '#ef4444' }};">
{{ $integrityScore >= 80 && $codeScore >= 50 ? 'RECOMMENDED FOR HIRE' : 'REQUIRES FURTHER REVIEW / FLAGGED' }}
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -35,6 +35,7 @@
Route::post('/candidate/sync-code/{id}', [InterviewController::class, 'syncCandidateCode'])->name('interview.candidate.sync-code');
Route::post('/candidate/notes/{id}', [InterviewController::class, 'saveCandidateNotes'])->name('interview.candidate.notes');
Route::post('/candidate/drawing/{id}', [InterviewController::class, 'saveCandidateDrawing'])->name('interview.candidate.drawing');
Route::post('/candidate/send-message/{id}', [InterviewController::class, 'candidateSendMessage'])->name('interview.candidate.send-message');
// User Dashboard Portal (requires authenticated user)
Route::middleware(['auth', 'role:user', 'verify-ms-session'])->group(function () {
@ -67,6 +68,8 @@
Route::get('/interviews/{id}/poll', [InterviewController::class, 'getPollData'])->name('interview.poll');
Route::post('/interviews/{id}/regenerate-password', [InterviewController::class, 'regeneratePassword'])->name('interview.regenerate-password');
Route::post('/interviews/{id}/block-candidate', [InterviewController::class, 'blockCandidate'])->name('interview.block-candidate');
Route::get('/interviews/{id}/report', [InterviewController::class, 'generateReport'])->name('interview.report');
Route::post('/interviews/{id}/call-status', [InterviewController::class, 'updateCallStatus'])->name('interview.call-status');
});
// Admin Control Panel (requires admin role)

View File

@ -265,4 +265,37 @@ public function test_candidate_notes_drawing_saving_and_interviewer_password_reg
'temp_password' => $interview->temp_password,
])->assertSessionHas('error');
}
public function test_executive_candidate_evaluation_pdf_report_generation(): void
{
$hr = User::create([
'name' => 'Report Viewer HR',
'email' => 'hrreport@company.com',
'role' => 'admin',
]);
$interview = Interview::create([
'candidate_name' => 'Rachel Candidate',
'candidate_email' => 'rachel@gmail.com',
'candidate_phone' => '9666655555',
'temp_password' => 'Pass-666555',
'expires_at' => now()->addHours(2),
'language' => 'python',
'status' => 'completed',
'submission_unique_id' => 'rachel-candidate_9666655555_1752000005',
'submitted_code' => 'def solve(): return 42',
'code_output' => 'Result: 42',
'candidate_notes' => 'Complexity analysis: O(1)',
]);
$response = $this->actingAs($hr)->get(route('interview.report', $interview->id));
$response->assertStatus(200)
->assertSee('Rachel Candidate')
->assertSee('rachel@gmail.com')
->assertSee('Executive Summary')
->assertSee('Behavioral Integrity Rating')
->assertSee('Technical Code Competency')
->assertSee('Complexity analysis: O(1)');
}
}