feat: add Leren learning page for content generation and feedback, and create TestManager admin component
This commit is contained in:
@@ -9,17 +9,25 @@ import { motion, AnimatePresence } from 'framer-motion';
|
||||
|
||||
const TestManager = () => {
|
||||
const [topics, setTopics] = useState([]);
|
||||
const [questionCounts, setQuestionCounts] = useState({});
|
||||
const [selectedTopic, setSelectedTopic] = useState(null);
|
||||
const [questions, setQuestions] = useState([]);
|
||||
const [loadingTopicId, setLoadingTopicId] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
const loadData = () => {
|
||||
const allTopics = storage.get('kb:topics', []);
|
||||
const loadData = async () => {
|
||||
const allTopics = await db.getTopics();
|
||||
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) {
|
||||
setQuestions(getTopicQuestionBank(selectedTopic.id));
|
||||
setQuestions(await getTopicQuestionBank(selectedTopic.id));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -157,8 +165,7 @@ const TestManager = () => {
|
||||
)}
|
||||
|
||||
{topics.map(topic => {
|
||||
const bank = getTopicQuestionBank(topic.id);
|
||||
const count = bank.length;
|
||||
const count = questionCounts[topic.id] || 0;
|
||||
const isLoading = loadingTopicId === topic.id;
|
||||
|
||||
return (
|
||||
|
||||
@@ -91,7 +91,7 @@ const Leren = () => {
|
||||
setError(null);
|
||||
try {
|
||||
const newTopic = await generateCustomTopic(customTopicQuery);
|
||||
setAllTopics(storage.get('kb:topics', []));
|
||||
setAllTopics(await db.getTopics());
|
||||
setCustomTopicQuery('');
|
||||
handleOpenTopic(newTopic);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user