<?php
$studentProjectId=max(0,(int)($_GET['project']??0));$studentFile=(string)($_GET['file']??'');$studentView=$studentProjectId?($studentFile!==''?'editor':'files'):'library';
?>
<main id="main" class="projects-workspace" data-student-view="<?=htmlspecialchars($studentView,ENT_QUOTES)?>">
<div class="page-heading" id="studentLibraryHeading"><div><div class="breadcrumb">SLPS / Project workspace</div><h1>Students Projects</h1><p>Submit, explore and refine your coursework in one organised workspace.</p></div><div class="heading-actions"><button class="button secondary" id="projectsRefresh">Refresh</button><button class="button" id="projectSubmit" hidden>Submit project</button></div></div>
<div id="projectsNotice" class="notice" role="status" aria-live="polite">Loading your projects…</div>
<section class="panel projects-library" id="studentLibraryPanel"><div class="section-heading"><div><span class="section-kicker">PROJECT LIBRARY</span><h2 id="projectsHeading">Submitted projects</h2></div><label class="project-search">Search projects<input id="projectsSearch" type="search" placeholder="Title, student, course or technology"></label></div><div id="projectsList" class="projects-cards"></div><p id="projectsEmpty" hidden>No submissions yet. Your submitted projects will appear here.</p><small>Showing up to 200 most recent submissions you can access.</small></section>
<section class="panel project-manager" id="projectManager" hidden><div class="section-heading"><div><span class="section-kicker">PROJECT FILE MANAGER</span><h2 id="projectTitle"></h2><p id="projectMeta"></p></div><button class="button secondary" id="projectClose">← Student projects</button></div><p id="projectDescription"></p><div class="project-tools"><button class="button" id="studentGradeOpen">Grade &amp; feedback</button><span id="studentGradeSummary" class="student-grade-summary"></span><button class="button" id="projectExtract">⇲ Extract project</button><a class="button secondary" id="projectOriginal">↓ Original archive</a><a class="button secondary" id="projectExport" hidden>↓ Download edited ZIP</a><span id="projectRevision" class="project-caption">Original submission preserved</span></div>
<div class="project-files-layout"><aside class="project-folders"><div class="collab-explorer-heading"><h3>Explorer</h3><button class="collab-tree-tool" id="studentCollapseAll" title="Collapse all folders" aria-label="Collapse all folders">⊟</button></div><input id="projectFileSearch" type="search" placeholder="Find a file…" aria-label="Search project files"><div id="projectTree" role="tree" aria-label="Project files and folders"></div></aside><div class="project-files"><div class="project-location"><button class="button secondary" id="projectUp">↑ Up one level</button><strong id="projectLocation">/</strong></div><div class="table-wrap"><table><thead><tr><th>Name</th><th>Size</th><th>Type</th></tr></thead><tbody id="projectEntries"></tbody></table></div><p id="projectFilesEmpty">Extract this archive to browse its files and folders.</p></div></div>
</section><section class="project-editor panel" id="projectEditorPanel" hidden><div class="project-editor-bar"><div><button class="button secondary" id="studentBackToFiles">← Project files</button><strong id="projectFileTitle">Select a file</strong><small id="projectEditorStatus">UTF-8 source editor</small></div><div><a class="button secondary" id="projectDownload">↓ File</a><button class="button" id="projectSave" disabled>Save changes</button></div></div><div id="projectCodeEditor" aria-label="Project source code editor"></div><textarea id="projectCodeFallback" aria-label="Project source code" hidden></textarea><p class="project-caption">Ctrl/Cmd + S to save · Source files are displayed as code and are never executed by this workspace.</p></section>
</main>
<div class="modal fade slps-modal" id="projectSubmitModal" tabindex="-1" aria-labelledby="projectSubmitTitle" aria-hidden="true"><div class="modal-dialog modal-lg modal-dialog-centered"><div class="modal-content"><div class="modal-header"><div><span class="section-kicker">NEW SUBMISSION</span><h2 class="modal-title fs-5" id="projectSubmitTitle">Submit your project</h2></div><button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><form id="projectSubmitForm"><div class="modal-body"><p>Upload source files as ZIP or RAR. Choose the course and technologies used.</p><div class="notice" id="projectUploadNotice" hidden role="status"></div><label class="form-label" for="projectNewTitle">Project title</label><input class="form-control" id="projectNewTitle" maxlength="160" required><label class="form-label" for="projectCourse">Course</label><select class="form-select" id="projectCourse" required></select><label class="form-label" for="projectNewDescription">Description</label><textarea class="form-control" id="projectNewDescription" maxlength="5000" rows="3" required></textarea><label class="form-label" for="projectTechnologies">Languages and frameworks</label><select class="form-select" id="projectTechnologies" multiple size="6" required></select><small>Hold Ctrl (Windows) or Command (Mac) to select several technologies. HTML, CSS and JavaScript can be combined. These labels never filter uploaded files.</small><label class="form-label" for="projectOtherTechnology">Other technologies (comma-separated, optional)</label><input class="form-control" id="projectOtherTechnology" maxlength="400" placeholder="For example: Bootstrap, Spring Boot"><label class="form-label" for="projectArchive">Project archive</label><input class="form-control" id="projectArchive" type="file" accept=".zip,.rar" required><p class="project-caption" id="projectArchiveHelp">Maximum 25 MB compressed; 100 MB extracted; 3,000 entries. Exclude node_modules, vendor dependencies and build outputs. Remove passwords and private keys before submission.</p></div><div class="modal-footer"><button type="button" class="button secondary" data-bs-dismiss="modal">Cancel</button><button class="button" id="projectUploadButton" type="submit">Submit project</button></div></form></div></div></div>
<div class="modal fade slps-modal" id="projectDiscardModal" tabindex="-1" aria-labelledby="projectDiscardTitle" aria-hidden="true"><div class="modal-dialog modal-dialog-centered"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5" id="projectDiscardTitle">Unsaved changes</h2><button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body">You have unsaved edits. Save them before continuing, or discard them.</div><div class="modal-footer"><button class="button secondary" data-bs-dismiss="modal">Keep editing</button><button class="button secondary" id="projectDiscard">Discard changes</button><button class="button" id="projectSaveContinue">Save and continue</button></div></div></div></div>
<div class="modal fade slps-modal" id="studentGradeModal" tabindex="-1" aria-labelledby="studentGradeTitle" aria-hidden="true"><div class="modal-dialog modal-lg modal-dialog-centered"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5" id="studentGradeTitle">Project grade &amp; feedback</h2><button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body"><div id="studentGradeResult" class="student-grade-result" role="status"></div><form id="studentGradeForm" hidden><label class="form-label" for="studentGradeScore">Mark (%)</label><input class="form-control" id="studentGradeScore" type="number" min="0" max="100" step="0.01" required><p class="project-caption" id="studentGradePreview"></p><label class="form-label" for="studentGradeFeedback">Feedback to student</label><textarea class="form-control" id="studentGradeFeedback" maxlength="5000" rows="4"></textarea><p class="project-caption">D: below 50 · B: 50–below 60 · B+: 60–below 70 · A: 70–below 80 · A+: 80–100</p><button class="button" type="submit" id="studentGradePublish">Publish grade &amp; notify student</button></form><p id="studentGradeNotice" role="status"></p></div></div></div></div>