Download task_007/solution/code/index.html from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 8.24 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_007/solution/code/index.html
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_007/solution/code/index.html
-
curl -L -o index.html https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_007/solution/code/index.html
8.24 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Question System Admin</title> | |
| <style> | |
| * { box-sizing: border-box; } | |
| body { font-family: system-ui, sans-serif; margin: 0; background: #f6f8fa; color: #1f2328; } | |
| header { background: #24292f; color: #fff; padding: 16px 24px; } | |
| header h1 { margin: 0; font-size: 20px; } | |
| main { max-width: 960px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; } | |
| section { background: #fff; border: 1px solid #d0d7de; border-radius: 10px; padding: 16px 20px; } | |
| h2 { margin: 0 0 12px; font-size: 16px; } | |
| .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } | |
| input, select, button { padding: 6px 10px; border: 1px solid #c7ced6; border-radius: 6px; font-size: 14px; } | |
| button { background: #2563eb; color: #fff; border: none; cursor: pointer; } | |
| button.secondary { background: #6e7781; } | |
| button.danger { background: #cf222e; } | |
| ul { list-style: none; padding: 0; margin: 12px 0 0; } | |
| .q-item { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid #eaeef2; border-radius: 6px; margin-bottom: 8px; } | |
| .q-item .q-text { flex: 1; } | |
| .q-item[data-status="offline"] .q-text { color: #999; text-decoration: line-through; } | |
| .status-tag { font-size: 12px; color: #57606a; } | |
| .user-card { padding: 8px; border: 1px solid #eaeef2; border-radius: 6px; margin-bottom: 8px; } | |
| .hint { color: #57606a; font-size: 13px; } | |
| </style> | |
| </head> | |
| <body> | |
| <header><h1>Question System Admin</h1></header> | |
| <main data-testid="admin-dashboard"> | |
| <!-- ===== Question bank: upload / edit / offline (down-shelf) / delete ===== --> | |
| <section data-testid="question-bank"> | |
| <h2>Question Bank</h2> | |
| <div class="row"> | |
| <input data-testid="question-input" placeholder="Enter question text" aria-label="question text"> | |
| <button data-testid="upload-question">upload question</button> | |
| </div> | |
| <ul data-testid="question-list"></ul> | |
| <p class="hint" data-testid="question-count">Questions: 0</p> | |
| </section> | |
| <!-- ===== User management: basic info + answer records ===== --> | |
| <section data-testid="user-management"> | |
| <h2>User Management</h2> | |
| <div id="user-list"></div> | |
| </section> | |
| <!-- ===== Permission management: admin vs normal user ===== --> | |
| <section data-testid="permission-management"> | |
| <h2>Permission Management</h2> | |
| <div class="row"> | |
| <label for="role">current role:</label> | |
| <select data-testid="role-select" id="role"> | |
| <option value="admin" data-role="admin" selected>admin</option> | |
| <option value="normal user" data-role="normal user">normal user</option> | |
| </select> | |
| <span class="status-tag" data-testid="role-status" data-role="admin">role = admin</span> | |
| </div> | |
| <p class="hint">Admins can manage questions; normal users can only browse, so management controls are hidden.</p> | |
| </section> | |
| </main> | |
| <script> | |
| (function () { | |
| // ---- in-memory state ---- | |
| var questions = []; // {id, text, status, edited} | |
| var seq = 1; | |
| var users = [ | |
| { name: 'Alice', email: 'alice@example.com', records: ['Q1 ✓', 'Q2 ✗'] }, | |
| { name: 'Bob', email: 'bob@example.com', records: ['Q1 ✓'] } | |
| ]; | |
| var role = 'admin'; | |
| var listEl = document.querySelector('[data-testid="question-list"]'); | |
| var countEl = document.querySelector('[data-testid="question-count"]'); | |
| var inputEl = document.querySelector('[data-testid="question-input"]'); | |
| var uploadBtn = document.querySelector('[data-testid="upload-question"]'); | |
| var roleSelect = document.querySelector('[data-testid="role-select"]'); | |
| var roleStatus = document.querySelector('[data-testid="role-status"]'); | |
| function isAdmin() { return role === 'admin'; } | |
| function renderQuestions() { | |
| listEl.innerHTML = ''; | |
| questions.forEach(function (q) { | |
| var li = document.createElement('li'); | |
| li.className = 'q-item'; | |
| li.setAttribute('data-testid', 'question-item'); | |
| li.setAttribute('data-id', q.id); | |
| li.setAttribute('data-status', q.status); | |
| if (q.edited) li.setAttribute('data-edited', 'true'); | |
| var text = document.createElement('span'); | |
| text.className = 'q-text'; | |
| text.setAttribute('data-testid', 'question-text'); | |
| text.textContent = q.text + (q.edited ? ' [edited]' : ''); | |
| var tag = document.createElement('span'); | |
| tag.className = 'status-tag'; | |
| tag.textContent = q.status; | |
| var editBtn = document.createElement('button'); | |
| editBtn.className = 'secondary'; | |
| editBtn.setAttribute('data-testid', 'edit-question'); | |
| editBtn.textContent = 'edit'; | |
| editBtn.onclick = function () { | |
| if (!isAdmin()) return; | |
| var next = inputEl.value.trim(); | |
| q.text = next || q.text; | |
| q.edited = true; | |
| renderQuestions(); | |
| }; | |
| var offlineBtn = document.createElement('button'); | |
| offlineBtn.className = 'secondary'; | |
| offlineBtn.setAttribute('data-testid', 'offline-question'); | |
| offlineBtn.textContent = q.status === 'offline' ? 'online' : 'offline'; | |
| offlineBtn.onclick = function () { | |
| if (!isAdmin()) return; | |
| q.status = q.status === 'offline' ? 'online' : 'offline'; | |
| renderQuestions(); | |
| }; | |
| li.appendChild(text); | |
| li.appendChild(tag); | |
| li.appendChild(editBtn); | |
| li.appendChild(offlineBtn); | |
| // delete is an admin-only control | |
| var delBtn = document.createElement('button'); | |
| delBtn.className = 'danger'; | |
| delBtn.setAttribute('data-testid', 'delete-question'); | |
| delBtn.textContent = 'delete'; | |
| delBtn.onclick = function () { | |
| if (!isAdmin()) return; | |
| questions = questions.filter(function (x) { return x.id !== q.id; }); | |
| renderQuestions(); | |
| }; | |
| delBtn.style.display = isAdmin() ? '' : 'none'; | |
| li.appendChild(delBtn); | |
| editBtn.style.display = isAdmin() ? '' : 'none'; | |
| offlineBtn.style.display = isAdmin() ? '' : 'none'; | |
| listEl.appendChild(li); | |
| }); | |
| countEl.textContent = 'Questions: ' + questions.length; | |
| uploadBtn.style.display = isAdmin() ? '' : 'none'; | |
| inputEl.disabled = !isAdmin(); | |
| } | |
| function renderUsers() { | |
| var c = document.getElementById('user-list'); | |
| c.innerHTML = ''; | |
| users.forEach(function (u, index) { | |
| var card = document.createElement('div'); | |
| card.className = 'user-card'; | |
| card.setAttribute('data-testid', 'user-card'); | |
| card.setAttribute('data-user-id', String(u.id ?? index)); | |
| var info = document.createElement('div'); | |
| info.textContent = u.name + ' · ' + u.email; | |
| card.appendChild(info); | |
| u.records.forEach(function (r) { | |
| var rec = document.createElement('div'); | |
| rec.className = 'status-tag'; | |
| rec.setAttribute('data-testid', 'answer-record'); | |
| rec.setAttribute('data-answer-record', 'true'); | |
| rec.textContent = 'answer record: ' + r; | |
| card.appendChild(rec); | |
| }); | |
| c.appendChild(card); | |
| }); | |
| } | |
| document.querySelector('[data-testid="upload-question"]').onclick = function () { | |
| if (!isAdmin()) return; | |
| var text = inputEl.value.trim(); | |
| if (!text) return; | |
| questions.push({ id: seq++, text: text, status: 'online', edited: false }); | |
| inputEl.value = ''; | |
| renderQuestions(); | |
| }; | |
| roleSelect.onchange = function () { | |
| role = roleSelect.value; | |
| roleStatus.textContent = 'role = ' + role; | |
| roleStatus.setAttribute('data-role', role); | |
| renderQuestions(); // re-render so admin-only controls reflect the role | |
| }; | |
| window.__setUsers = function (nextUsers) { | |
| users = structuredClone(nextUsers); | |
| renderUsers(); | |
| }; | |
| // seed one question so the dashboard is non-empty on load | |
| questions.push({ id: seq++, text: 'Sample question', status: 'online', edited: false }); | |
| renderQuestions(); | |
| renderUsers(); | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |