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 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 (
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user