From ff6b8a8a48c2cd5597a63bda721ebbadbdd0ede5 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 22 Dec 2025 11:23:59 +0000 Subject: [PATCH] Add filtering functionality for CID and User candidates in exam view --- generic/templates/generic/exam_cids.html | 44 ++++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/generic/templates/generic/exam_cids.html b/generic/templates/generic/exam_cids.html index 75994107..102e1777 100644 --- a/generic/templates/generic/exam_cids.html +++ b/generic/templates/generic/exam_cids.html @@ -15,6 +15,9 @@
CID candidates ({{ cid_user_count }})
+
+ +
{% if cid_users %}
    @@ -37,13 +40,6 @@
    {{ cid.name }}
    Email: {{ cid.email }}
-
- {% if cid.login_email_sent %} - Email sent - {% else %} - Not sent - {% endif %} -
{% endfor %} @@ -59,6 +55,9 @@
User candidates ({{ user_user_count }})
+
+ +
{% if user_users %}
    {% for user in user_users %} @@ -148,6 +147,37 @@ } }catch(e){ console.error(e); } }); + + // Filtering helpers + function normalizeText(s){ return (s||'').toString().toLowerCase(); } + + function filterList(inputElem, listSelector){ + const q = normalizeText(inputElem.value.trim()); + document.querySelectorAll(listSelector).forEach(function(li){ + const text = normalizeText(li.textContent); + if(!q || text.indexOf(q) !== -1){ + li.style.display = ''; + } else { + li.style.display = 'none'; + } + }); + } + + const cidFilter = document.getElementById('cid-filter'); + if(cidFilter){ + cidFilter.addEventListener('input', function(){ + // target CID list items only (left column) + filterList(cidFilter, '.col-lg-6:first-of-type .list-group-item'); + }); + } + + const userFilter = document.getElementById('user-filter'); + if(userFilter){ + userFilter.addEventListener('input', function(){ + // target user list items only (right column) + filterList(userFilter, '.col-lg-6:nth-of-type(2) .list-group-item, .col-lg-6:nth-of-type(2) .list-group-item.d-flex'); + }); + } }); {% endblock %}