This commit is contained in:
Ross
2025-12-08 11:51:36 +00:00
parent eb06e63f77
commit 9a3a8b932a
3 changed files with 178 additions and 17 deletions
+32 -3
View File
@@ -353,6 +353,27 @@ class ExamSearchSelectMultipleWidget:
<div id="exam_search_help_panel_{self.name}" class="card card-body mt-2 d-none" style="font-size:.9rem;">
<strong>Advanced search tips</strong>
<div class="mb-2 mt-2">
<strong class="small">Filters</strong>
<div class="d-flex gap-2 mt-1">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="filter_archive_{self.name}" />
<label class="form-check-label small" for="filter_archive_{self.name}">Archived only</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="filter_open_access_{self.name}" />
<label class="form-check-label small" for="filter_open_access_{self.name}">Open access only</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="filter_exam_mode_{self.name}" />
<label class="form-check-label small" for="filter_exam_mode_{self.name}">Exam mode only</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="filter_candidates_only_{self.name}" />
<label class="form-check-label small" for="filter_candidates_only_{self.name}">Candidates only</label>
</div>
</div>
</div>
<ul class="mb-0 mt-1">
<li>Basic: type any part of an exam's name, code or identifier (case-insensitive substring match).</li>
<li>Field-specific searches: prefix with <code>field:term</code> to restrict the search. Supported fields:
@@ -364,7 +385,6 @@ class ExamSearchSelectMultipleWidget:
<li><code>type:</code> — narrow to an exam type (e.g. <code>type:anatomy</code>).</li>
</ul>
</li>
<li>Type filter: use the dropdown to restrict results to a specific exam type in addition to your query.</li>
<li>To add exams, click the <em>Add</em> button beside a result. Use <em>Add all results</em> to import visible matches.</li>
<li>Wildcard: use <code>*</code> to broaden results; wildcards may return more results and are rate-limited.</li>
</ul>
@@ -396,8 +416,17 @@ class ExamSearchSelectMultipleWidget:
results.innerHTML = '';
return;
}}
const modelParam = defaultModel ? '&model=' + encodeURIComponent(defaultModel) : '';
const url = '{url}?field=' + encodeURIComponent(widgetFieldName) + '&q=' + encodeURIComponent(q) + modelParam;
const modelParam = defaultModel ? '&model=' + encodeURIComponent(defaultModel) : '';
const f_archive = document.getElementById('filter_archive_{self.name}');
const f_open = document.getElementById('filter_open_access_{self.name}');
const f_exam_mode = document.getElementById('filter_exam_mode_{self.name}');
const f_candidates = document.getElementById('filter_candidates_only_{self.name}');
let extra = '';
if (f_archive && f_archive.checked) extra += '&archive=1';
if (f_open && f_open.checked) extra += '&open_access=1';
if (f_exam_mode && f_exam_mode.checked) extra += '&exam_mode=1';
if (f_candidates && f_candidates.checked) extra += '&candidates_only=1';
const url = '{url}?field=' + encodeURIComponent(widgetFieldName) + '&q=' + encodeURIComponent(q) + modelParam + extra;
fetch(url)
.then(r => r.text())
.then(html => {{ results.innerHTML = html; }});