feat: add Leren learning page for content generation and feedback, and create TestManager admin component
Some checks failed
On Push to Main / test (push) Has been cancelled
On Push to Main / publish (push) Has been cancelled
On Push to Main / deploy-dev (push) Has been cancelled

This commit is contained in:
RaymondVerhoef
2026-05-14 22:21:39 +02:00
parent 0673122536
commit e223836d7d
2 changed files with 14 additions and 7 deletions

View File

@@ -9,17 +9,25 @@ import { motion, AnimatePresence } from 'framer-motion';
const TestManager = () => { const TestManager = () => {
const [topics, setTopics] = useState([]); const [topics, setTopics] = useState([]);
const [questionCounts, setQuestionCounts] = useState({});
const [selectedTopic, setSelectedTopic] = useState(null); const [selectedTopic, setSelectedTopic] = useState(null);
const [questions, setQuestions] = useState([]); const [questions, setQuestions] = useState([]);
const [loadingTopicId, setLoadingTopicId] = useState(null); const [loadingTopicId, setLoadingTopicId] = useState(null);
const [error, setError] = useState(null); const [error, setError] = useState(null);
const loadData = () => { const loadData = async () => {
const allTopics = storage.get('kb:topics', []); const allTopics = await db.getTopics();
setTopics(allTopics); setTopics(allTopics);
const counts = {};
await Promise.all(allTopics.map(async t => {
const bank = await getTopicQuestionBank(t.id);
counts[t.id] = bank.length;
}));
setQuestionCounts(counts);
if (selectedTopic) { if (selectedTopic) {
setQuestions(getTopicQuestionBank(selectedTopic.id)); setQuestions(await getTopicQuestionBank(selectedTopic.id));
} }
}; };
@@ -157,8 +165,7 @@ const TestManager = () => {
)} )}
{topics.map(topic => { {topics.map(topic => {
const bank = getTopicQuestionBank(topic.id); const count = questionCounts[topic.id] || 0;
const count = bank.length;
const isLoading = loadingTopicId === topic.id; const isLoading = loadingTopicId === topic.id;
return ( return (

View File

@@ -91,7 +91,7 @@ const Leren = () => {
setError(null); setError(null);
try { try {
const newTopic = await generateCustomTopic(customTopicQuery); const newTopic = await generateCustomTopic(customTopicQuery);
setAllTopics(storage.get('kb:topics', [])); setAllTopics(await db.getTopics());
setCustomTopicQuery(''); setCustomTopicQuery('');
handleOpenTopic(newTopic); handleOpenTopic(newTopic);
} catch (e) { } catch (e) {