Enhance submission tracking by adding first and last name data attributes for candidates, improving badge tooltip information in the submitted candidates list.
This commit is contained in:
@@ -159,14 +159,18 @@
|
||||
// data attributes for cid/user. Then insert a small badge on matching list items.
|
||||
// Collect submitted identifiers first to avoid duplicate processing
|
||||
const submittedEls = document.querySelectorAll('#submitted-candidates [data-cid], #submitted-candidates [data-user]');
|
||||
const submittedCids = new Set();
|
||||
const submittedUsers = new Set();
|
||||
// Build maps of submitted identifiers -> their timestamps so we
|
||||
// can attach tooltip text to the badges we create below.
|
||||
const submittedCids = new Map();
|
||||
const submittedUsers = new Map();
|
||||
submittedEls.forEach(function(el){
|
||||
try{
|
||||
const cid = el.dataset && el.dataset.cid ? el.dataset.cid.toString() : null;
|
||||
const user = el.dataset && el.dataset.user ? el.dataset.user.toString() : null;
|
||||
if(cid && cid !== 'None') submittedCids.add(cid);
|
||||
if(user && user !== 'None') submittedUsers.add(user);
|
||||
const first = el.dataset && el.dataset.first ? el.dataset.first.toString() : '';
|
||||
const last = el.dataset && el.dataset.last ? el.dataset.last.toString() : '';
|
||||
if(cid && cid !== 'None') submittedCids.set(cid, {first:first, last:last});
|
||||
if(user && user !== 'None') submittedUsers.set(user, {first:first, last:last});
|
||||
}catch(e){ console.error('highlightSubmitted collect error', e); }
|
||||
});
|
||||
|
||||
@@ -177,9 +181,15 @@
|
||||
const link = li.querySelector && li.querySelector('.cid-link');
|
||||
const text = (link && link.textContent) ? link.textContent.trim() : (li.textContent||'').trim();
|
||||
if(submittedCids.has(text) && !li.querySelector('.submitted-badge')){
|
||||
const info = submittedCids.get(text) || {first:'', last:''};
|
||||
const badge = document.createElement('span');
|
||||
badge.className = 'submitted-badge badge bg-success ms-2';
|
||||
badge.textContent = 'Submitted';
|
||||
if(info.first || info.last){
|
||||
const title = `Submitted\nFirst: ${info.first}\nLast: ${info.last}`;
|
||||
badge.setAttribute('title', title);
|
||||
badge.setAttribute('data-bs-toggle', 'tooltip');
|
||||
}
|
||||
if(link && link.parentNode){
|
||||
link.parentNode.appendChild(badge);
|
||||
} else {
|
||||
@@ -198,9 +208,15 @@
|
||||
for(const user of submittedUsers){
|
||||
if(txt.indexOf(user) !== -1){
|
||||
if(!li.querySelector('.submitted-badge')){
|
||||
const info = submittedUsers.get(user) || {first:'', last:''};
|
||||
const badge = document.createElement('span');
|
||||
badge.className = 'submitted-badge badge bg-success ms-2';
|
||||
badge.textContent = 'Submitted';
|
||||
if(info.first || info.last){
|
||||
const title = `Submitted\nFirst: ${info.first}\nLast: ${info.last}`;
|
||||
badge.setAttribute('title', title);
|
||||
badge.setAttribute('data-bs-toggle', 'tooltip');
|
||||
}
|
||||
const nameEl = li.querySelector('.fw-bold') || li.querySelector('a') || li;
|
||||
nameEl.appendChild(badge);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</thead>
|
||||
<tbody id="submitted-candidates">
|
||||
{% for user_data in user_exam_data %}
|
||||
<tr data-cid="{{ user_data.cid_user }}" data-user="{{ user_data.user_user }}">
|
||||
<tr data-cid="{{ user_data.cid_user }}" data-user="{{ user_data.user_user }}" data-first="{{ user_data.start_time|default_if_none:'' }}" data-last="{{ user_data.end_time|default_if_none:'' }}">
|
||||
<td class="fw-bold">{{ user_data.cid_user }}</td>
|
||||
<td>{{ user_data.user_user }}</td>
|
||||
<td class="text-nowrap small text-muted">{{ user_data.start_time }}</td>
|
||||
|
||||
Reference in New Issue
Block a user