feat(sidebar): скрывать ссылки exam-prep при выключенном/недоступном треке
This commit is contained in:
@@ -885,6 +885,23 @@ async function hideDisabledFeatures() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exam-prep track links (/exam-prep/<key>): показываем только включённые
|
||||||
|
// (exam_tracks.enabled) и доступные пользователю треки. /api/exam-prep/tracks
|
||||||
|
// уже отдаёт enabled-треки, отфильтрованные по правам доступа.
|
||||||
|
const examLinks = document.querySelectorAll('[href^="/exam-prep/"]');
|
||||||
|
if (examLinks.length) {
|
||||||
|
try {
|
||||||
|
const data = await apiFetch('/api/exam-prep/tracks');
|
||||||
|
const allowed = new Set((data.tracks || []).map(t => t.exam_key));
|
||||||
|
examLinks.forEach(el => {
|
||||||
|
const m = (el.getAttribute('href') || '').match(/^\/exam-prep\/([^/?#]+)/);
|
||||||
|
if (m && !allowed.has(m[1])) el.style.display = 'none';
|
||||||
|
});
|
||||||
|
const cur = window.location.pathname.match(/^\/exam-prep\/([^/?#]+)/);
|
||||||
|
if (cur && !allowed.has(cur[1])) window.location.href = '/dashboard.html';
|
||||||
|
} catch { /* сеть/доступ недоступны — ссылки оставляем как есть */ }
|
||||||
|
}
|
||||||
|
|
||||||
// Student with no class — restrict to dashboard, homework, library, theory
|
// Student with no class — restrict to dashboard, homework, library, theory
|
||||||
if (feats._no_class) {
|
if (feats._no_class) {
|
||||||
const classOnlyHrefs = [
|
const classOnlyHrefs = [
|
||||||
|
|||||||
Reference in New Issue
Block a user