sls/resources/views/interview/index.blade.php
2026-07-21 13:47:36 +05:30

507 lines
27 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Candidate Live Assessment Portal | SingleLogin</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
<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&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<style>
:root {
--bg-color: #0b0f19;
--card-bg: rgba(15, 23, 42, 0.65);
--card-border: rgba(255, 255, 255, 0.22);
--accent-primary: #6366f1;
--accent-secondary: #0078d4;
--text-main: #ffffff;
--text-muted: #d1d5db;
}
/* Scrollbars */
html, body, *, ::-webkit-scrollbar {
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, 0.4) rgba(15, 23, 42, 0.35);
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-track {
background: rgba(15, 23, 42, 0.35);
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.4);
border-radius: 10px;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Instrument Sans', sans-serif;
background-color: var(--bg-color);
color: var(--text-main);
min-height: 100vh;
display: flex;
flex-direction: column;
}
.navbar {
height: 70px;
background: rgba(15, 23, 42, 0.8);
backdrop-filter: blur(16px);
border-bottom: 1px solid var(--card-border);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 4%;
position: sticky;
top: 0;
z-index: 100;
}
.btn-nav {
color: #e5e7eb;
text-decoration: none;
font-size: 0.85rem;
font-weight: 500;
padding: 8px 16px;
border-radius: 8px;
border: 1px solid var(--card-border);
background: rgba(255, 255, 255, 0.03);
transition: all 0.25s ease;
}
.btn-nav:hover {
background: rgba(255, 255, 255, 0.08);
color: white;
}
.assessment-card {
background: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 20px;
padding: 28px;
backdrop-filter: blur(20px);
box-shadow: 0 20px 40px rgba(0,0,0,0.4);
margin-bottom: 24px;
}
.table-responsive {
overflow-x: auto;
width: 100%;
}
.users-table {
width: 100%;
border-collapse: collapse;
font-size: 0.85rem;
text-align: left;
}
.users-table th {
padding: 12px 16px;
border-bottom: 1px solid var(--card-border);
color: var(--text-muted);
font-size: 0.75rem;
text-transform: uppercase;
}
.users-table td {
padding: 14px 16px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
vertical-align: middle;
}
.badge {
display: inline-flex;
align-items: center;
padding: 4px 8px;
border-radius: 9999px;
font-size: 0.7rem;
font-weight: 600;
}
.admin-modal {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(11, 15, 25, 0.85);
backdrop-filter: blur(12px);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
opacity: 0;
pointer-events: none;
transition: all 0.3s ease;
}
.admin-modal.active {
opacity: 1;
pointer-events: auto;
}
.admin-modal-content {
background-color: #151b2c;
border: 1px solid var(--card-border);
border-radius: 20px;
width: 90%;
max-width: 900px;
padding: 28px;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
color: white;
max-height: 90vh;
overflow-y: auto;
}
.form-input {
width: 100%;
padding: 10px 12px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--card-border);
border-radius: 8px;
color: white;
font-size: 0.85rem;
outline: none;
}
</style>
</head>
<body>
<!-- Header Navbar -->
<header class="navbar">
<div style="display: flex; align-items: center; gap: 12px;">
<div style="width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #6366f1 0%, #0078d4 100%); display: flex; align-items: center; justify-content: center; font-weight: 700;">
</div>
<div>
<h1 style="font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 700; color: white; margin: 0;">Candidate Live Assessment Portal</h1>
<div style="font-size: 0.7rem; color: var(--text-muted);">Proctored IDE & Code Submissions</div>
</div>
</div>
<div style="display: flex; gap: 12px;">
@if(Auth::user()->isAdmin())
<a href="{{ route('admin.dashboard') }}" class="btn-nav" style="border-color: #818cf8; color: #818cf8;">Control Panel</a>
@endif
<a href="{{ route('onboarding.index') }}" class="btn-nav">Onboarding Hub</a>
<a href="{{ route('dashboard') }}" class="btn-nav">User Portal</a>
</div>
</header>
<main style="max-width: 1400px; width: 100%; margin: 30px auto; padding: 0 4%; flex: 1;">
@if(session('success'))
<div style="margin-bottom: 24px; background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #34d399; padding: 12px 20px; border-radius: 12px; font-size: 0.9rem;">
{{ session('success') }}
</div>
@endif
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;">
<div>
<h2 style="font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 700; color: white; margin: 0;">Live Interview Assessments</h2>
<div style="font-size: 0.8rem; color: var(--text-muted);">Temporary Candidate Access, Real-Time Proctored IDE, and Unique Code Records</div>
</div>
<button onclick="document.getElementById('create-interview-modal').classList.add('active')" class="btn-nav" style="background-color: var(--accent-primary); color: white; border-color: transparent; font-weight: 600; padding: 10px 18px; cursor: pointer;">
+ Schedule Candidate Interview
</button>
</div>
<div class="assessment-card">
<div class="table-responsive">
<table class="users-table">
<thead>
<tr>
<th>Candidate & Temp Pass</th>
<th>Unique Submission ID</th>
<th>Status & Validity</th>
<th>Language</th>
<th>Proctoring Alerts</th>
<th style="text-align: right;">Review & Actions</th>
</tr>
</thead>
<tbody>
@forelse($interviews as $inv)
@php
$logs = $inv->proctor_logs ?? [];
$tabSwitches = count(array_filter($logs, fn($l) => ($l['type'] ?? '') === 'tab_switch'));
$focusLost = count(array_filter($logs, fn($l) => ($l['type'] ?? '') === 'focus_lost'));
$gazeAlerts = count(array_filter($logs, fn($l) => ($l['type'] ?? '') === 'gaze_anomaly'));
@endphp
<tr>
<td>
<div>
<strong style="color: white; font-size: 0.9rem;">{{ $inv->candidate_name }}</strong>
<div style="font-size: 0.75rem; color: var(--text-muted);">{{ $inv->candidate_email }} &bull; {{ $inv->candidate_phone }}</div>
<div style="margin-top: 4px; display: flex; flex-direction: column; gap: 4px;">
<div style="font-size: 0.75rem; color: #a7f3d0; background: rgba(16,185,129,0.1); padding: 2px 8px; border-radius: 6px; display: inline-block;">
🔑 Temp Pass: <strong>{{ $inv->temp_password }}</strong>
</div>
<div style="font-size: 0.7rem; color: #38bdf8;">
🌐 Login URL: <a href="{{ route('interview.candidate.login') }}" target="_blank" style="color: #38bdf8; text-decoration: underline;">{{ route('interview.candidate.login') }}</a>
</div>
</div>
</div>
</td>
<td>
<code style="background: rgba(255,255,255,0.06); padding: 4px 8px; border-radius: 6px; color: #38bdf8; font-size: 0.75rem;">
{{ $inv->submission_unique_id }}
</code>
</td>
<td>
@if($inv->isExpired())
<span class="badge" style="background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3);">
EXPIRED
</span>
@elseif($inv->status === 'completed')
<span class="badge" style="background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3);">
COMPLETED
</span>
@elseif($inv->isActiveTimeline())
<span class="badge" style="background: rgba(16,185,129,0.2); color: #34d399; border: 1px solid rgba(16,185,129,0.4);">
TIMELINE LIVE
</span>
@else
<span class="badge" style="background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3);">
SCHEDULED
</span>
@endif
<div style="font-size: 0.7rem; color: var(--text-muted); margin-top: 4px;">
Timeline: {{ ($inv->scheduled_at ?? $inv->created_at)->format('M d, H:i') }} &ndash; {{ $inv->expires_at->format('H:i') }}
</div>
</td>
<td>
<span class="badge" style="background: rgba(255,255,255,0.05); color: white; border: 1px solid var(--card-border); text-transform: uppercase;">
{{ $inv->language }}
</span>
</td>
<td>
<div style="display: flex; flex-direction: column; gap: 2px; font-size: 0.75rem;">
<span style="color: {{ $tabSwitches > 0 ? '#ef4444' : 'var(--text-muted)' }}; font-weight: {{ $tabSwitches > 0 ? '700' : '400' }};">
🔴 Tab Switches: {{ $tabSwitches }}
</span>
<span style="color: {{ $focusLost > 0 ? '#fbbf24' : 'var(--text-muted)' }};">
🟡 Focus Loss / Overlay: {{ $focusLost }}
</span>
<span style="color: {{ $gazeAlerts > 0 ? '#f43f5e' : 'var(--text-muted)' }};">
👁️ Eye Gaze Anomaly: {{ $gazeAlerts }}
</span>
</div>
</td>
<td style="text-align: right; white-space: nowrap;">
<button onclick="openReviewModal({{ $inv->id }}, '{{ addslashes($inv->candidate_name) }}', '{{ $inv->submission_unique_id }}')" class="btn-nav" style="background: rgba(99,102,241,0.15); color: #818cf8; border-color: rgba(99,102,241,0.3); font-weight: 600; padding: 6px 12px; margin-right: 4px; cursor: pointer;">
🔍 Review Code & Proctor Logs
</button>
<a href="{{ route('interview.room', $inv->submission_unique_id) }}" target="_blank" class="btn-nav" style="padding: 6px 10px; font-size: 0.75rem;">
Open IDE Link
</a>
</td>
</tr>
@empty
<tr>
<td colspan="6" style="text-align: center; color: var(--text-muted); padding: 30px;">
No candidate interview sessions found. Click "+ Schedule Candidate Interview" above to create one.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</main>
<!-- Modal: Schedule Candidate Interview -->
<div id="create-interview-modal" class="admin-modal">
<div class="admin-modal-content" style="max-width: 600px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<h3 style="font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 700; color: white; margin: 0;">Schedule Candidate Assessment</h3>
<button onclick="document.getElementById('create-interview-modal').classList.remove('active')" style="background:none; border:none; color:var(--text-muted); font-size:1.5rem; cursor:pointer;">&times;</button>
</div>
<form action="{{ route('interview.store') }}" method="POST">
@csrf
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;">
<div>
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:4px; font-weight:500;">Candidate Name <span style="color:#ef4444;">*</span></label>
<input type="text" name="candidate_name" required placeholder="e.g. John Doe" class="form-input">
</div>
<div>
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:4px; font-weight:500;">Candidate Email <span style="color:#ef4444;">*</span></label>
<input type="email" name="candidate_email" required placeholder="john@gmail.com" class="form-input">
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 14px;">
<div>
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:4px; font-weight:500;">Phone Number <span style="color:#ef4444;">*</span></label>
<input type="text" name="candidate_phone" required placeholder="9876543210" class="form-input">
</div>
<div>
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:4px; font-weight:500;">Start Time (Timeline)</label>
<input type="datetime-local" name="scheduled_at" value="{{ now()->format('Y-m-d\TH:i') }}" class="form-input" style="background: #151b2c;">
</div>
<div>
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:4px; font-weight:500;">Access Duration <span style="color:#ef4444;">*</span></label>
<select name="valid_hours" required class="form-input" style="background: #151b2c;">
<option value="1">1 Hour</option>
<option value="2" selected>2 Hours</option>
<option value="4">4 Hours</option>
<option value="12">12 Hours</option>
<option value="24">24 Hours</option>
</select>
</div>
</div>
<div style="margin-bottom: 14px;">
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:4px; font-weight:500;">Coding Language <span style="color:#ef4444;">*</span></label>
<select name="language" required class="form-input" style="background: #151b2c;">
<option value="python">Python 3</option>
<option value="cpp">C++ (GCC)</option>
<option value="c">C (GCC)</option>
<option value="java">Java 15</option>
<option value="php">PHP 8.2 / Laravel</option>
<option value="javascript">JavaScript (Node.js)</option>
</select>
</div>
<div style="margin-bottom: 16px;">
<label style="display:block; font-size:0.75rem; color:var(--text-muted); margin-bottom:6px; font-weight:500;">Assign Internal Interviewers / Panelists</label>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 120px; overflow-y: auto; background: rgba(0,0,0,0.3); padding: 10px; border-radius: 8px; border: 1px solid var(--card-border);">
@foreach($interviewers as $usr)
<label style="display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: white; cursor: pointer;">
<input type="checkbox" name="assigned_interviewers[]" value="{{ $usr->id }}" style="accent-color: #6366f1;">
{{ $usr->name }} ({{ $usr->email }})
</label>
@endforeach
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;">
<button type="button" onclick="document.getElementById('create-interview-modal').classList.remove('active')" class="btn-nav">Cancel</button>
<button type="submit" class="btn-nav" style="background: var(--accent-primary); color: white; border-color: transparent; font-weight: 600;">Create Session & Password</button>
</div>
</form>
</div>
</div>
<!-- Modal: Live Review & Code Inspection -->
<div id="review-modal" class="admin-modal">
<div class="admin-modal-content">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 12px;">
<div>
<h3 id="modal-cand-name" style="font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 700; color: white; margin: 0;">Review Candidate Session</h3>
<div id="modal-cand-uid" style="font-size: 0.75rem; color: #38bdf8;"></div>
</div>
<button onclick="document.getElementById('review-modal').classList.remove('active')" style="background:none; border:none; color:var(--text-muted); font-size:1.5rem; cursor:pointer;">&times;</button>
</div>
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px;">
<!-- Left: Code Editor & Execution Output -->
<div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<span style="font-size: 0.8rem; font-weight: 600; color: white;">Submitted Code Solution:</span>
<span id="modal-code-lang" class="badge" style="background: rgba(99,102,241,0.2); color: #818cf8; font-size: 0.65rem;">PYTHON</span>
</div>
<pre id="modal-code-display" style="background: #090d16; border: 1px solid var(--card-border); border-radius: 10px; padding: 14px; font-family: monospace; font-size: 0.8rem; color: #e2e8f0; max-height: 250px; overflow-y: auto; white-space: pre-wrap; margin-bottom: 14px;"></pre>
<span style="font-size: 0.8rem; font-weight: 600; color: white;">Execution Stdout / Stderr Output:</span>
<pre id="modal-output-display" style="background: #050811; border: 1px solid var(--card-border); border-radius: 10px; padding: 12px; font-family: monospace; font-size: 0.75rem; color: #34d399; max-height: 120px; overflow-y: auto; white-space: pre-wrap;"></pre>
</div>
<!-- Right: Proctoring Logs & Silent Warning Sender -->
<div>
<span style="font-size: 0.8rem; font-weight: 600; color: white;">Proctoring Violation Audit:</span>
<div id="modal-logs-display" style="background: rgba(0,0,0,0.3); border: 1px solid var(--card-border); border-radius: 10px; padding: 10px; max-height: 200px; overflow-y: auto; margin-bottom: 14px; font-size: 0.7rem; color: var(--text-muted);">
No proctoring violations recorded.
</div>
<!-- Silent Warning Form -->
<div style="background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25); border-radius: 12px; padding: 12px;">
<div style="font-size: 0.75rem; color: #fca5a5; font-weight: 600; margin-bottom: 6px;">Send Silent Warning to Candidate:</div>
<input type="text" id="warning-input" placeholder="e.g. Please keep your camera centered." class="form-input" style="font-size: 0.75rem; margin-bottom: 8px;">
<button onclick="sendSilentWarning()" class="btn-nav" style="width: 100%; background: #ef4444; color: white; border: none; font-size: 0.75rem; font-weight: 600; padding: 6px; cursor: pointer;">
🚨 Send Warning Message
</button>
</div>
</div>
</div>
<div style="display: flex; justify-content: flex-end;">
<button type="button" onclick="document.getElementById('review-modal').classList.remove('active')" class="btn-nav">Close</button>
</div>
</div>
</div>
<script>
let currentInterviewId = null;
function openReviewModal(id, name, uid) {
currentInterviewId = id;
document.getElementById('modal-cand-name').innerText = name;
document.getElementById('modal-cand-uid').innerText = 'Unique Submission ID: ' + uid;
document.getElementById('review-modal').classList.add('active');
// Fetch live poll data
fetch(`{{ route('interview.poll', ':id') }}`.replace(':id', id))
.then(r => r.json())
.then(data => {
document.getElementById('modal-code-lang').innerText = (data.submitted_language || 'UNKNOWN').toUpperCase();
document.getElementById('modal-code-display').innerText = data.submitted_code || '// Candidate has not submitted code yet.';
document.getElementById('modal-output-display').innerText = data.code_output || 'No execution output.';
let logsHtml = '';
if (data.proctor_logs && data.proctor_logs.length > 0) {
data.proctor_logs.forEach(l => {
let icon = '🔴';
if (l.type === 'focus_lost') icon = '🟡';
if (l.type === 'gaze_anomaly') icon = '👁️';
logsHtml += `<div style="margin-bottom:6px; border-bottom:1px solid rgba(255,255,255,0.05); padding-bottom:4px;">
<strong>${icon} ${l.type.toUpperCase()}:</strong> ${l.details || ''}
<div style="font-size:0.65rem; color:#94a3b8;">${new Date(l.timestamp).toLocaleTimeString()}</div>
</div>`;
});
} else {
logsHtml = '<div style="color:#34d399;">✅ Zero proctoring violations recorded.</div>';
}
document.getElementById('modal-logs-display').innerHTML = logsHtml;
});
}
function sendSilentWarning() {
const msg = document.getElementById('warning-input').value.trim();
if (!msg || !currentInterviewId) return;
fetch(`{{ route('interview.warning', ':id') }}`.replace(':id', currentInterviewId), {
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) {
alert('Silent warning sent to candidate screen!');
document.getElementById('warning-input').value = '';
}
});
}
</script>
</body>
</html>