import { Box, Button, Chip, IconButton, Paper, Table, TableBody, TableCell,…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
import { Box, Button, Chip, IconButton, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip, Typography, LinearProgress, Grid, Card, CardContent, } from '@mui/material'; import dayjs from 'dayjs'; import DeleteIcon from '@mui/icons-material/Delete'; import EditIcon from '@mui/icons-material/Edit'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; import QuizIcon from '@mui/icons-material/Quiz'; import SlideshowIcon from '@mui/icons-material/Slideshow'; import TrendingUpIcon from '@mui/icons-material/TrendingUp'; import TrendingDownIcon from '@mui/icons-material/TrendingDown'; import CheckCircleIcon from '@mui/icons-material/CheckCircle'; import ViewModuleIcon from '@mui/icons-material/ViewModule'; import SpeedIcon from '@mui/icons-material/Speed'; import { useMemo } from 'react';
interface CoverageEntry { id: string; timestamp_ms: number; sectionName: string; sectionUri: string; targetSectionName: string; targetSectionUri: string; clipId: string; isQuizScheduled: boolean; slideUri: string; slideNumber?: number; }
interface CoverageTableProps { entries: CoverageEntry[]; onEdit: (index: number) => void; onDelete: (index: number) => void; sectionOrder?: string[]; courseStartDate?: string; sectionList?: Array<{ id: string; title: string; uri: string }>; }
function calculatePreorderFlatProgress( entries: CoverageEntry[] = [], sectionOrder: string[] = [], courseStartDate: string = '' ) { const normalize = (s: string) => s.trim().toLowerCase(); const today = dayjs().endOf('day'); const start = dayjs(courseStartDate);
if (!start.isValid() || sectionOrder.length === 0) { return { status: 'on-track', difference: 0, message: 'Invalid configuration', overallProgress: 0, totalSections: sectionOrder.length, overallPercentage: 0, completedSections: [], }; }
const normalizedOrder = sectionOrder.map(normalize);
let maxSeenIndex = -1; let maxTargetIndex = -1;
for (const entry of entries) { const entryDate = dayjs(entry.timestamp_ms); if (entryDate.isAfter(today)) continue;
const sectionNameIndex = normalizedOrder.indexOf(normalize(entry.sectionName ?? ''));
const targetSectionIndex = normalizedOrder.indexOf(normalize(entry.targetSectionName ?? ''));
if (sectionNameIndex !== -1) {
maxSeenIndex = Math.max(maxSeenIndex, sectionNameIndex);
}
if (targetSectionIndex !== -1) {
maxTargetIndex = Math.max(maxTargetIndex, targetSectionIndex);
}
}
const difference = maxSeenIndex - maxTargetIndex;
const status = difference > 0 ? 'ahead' : difference < 0 ? 'behind' : 'on-track';
const message =
difference === 0
? "You're on track with today's plan."
: You're ${Math.abs(difference)} section${Math.abs(difference) !== 1 ? 's' : ''} ${status}.;
return { status, difference, message, overallProgress: maxSeenIndex + 1, totalSections: sectionOrder.length, overallPercentage: sectionOrder.length > 0 ? ((maxSeenIndex + 1) / sectionOrder.length) * 100 : 0, completedSections: normalizedOrder.slice(0, maxSeenIndex + 1), }; }
export function CoverageTable({ entries, onEdit, onDelete, sectionOrder = [], courseStartDate = '', }: CoverageTableProps) { const now = dayjs(); const sortedEntries = [...entries].sort((a, b) => { const dateA = dayjs(a.timestamp_ms).startOf('day').valueOf(); const dateB = dayjs(b.timestamp_ms).startOf('day').valueOf(); return dateA - dateB; }); const progressData = useMemo( () => calculatePreorderFlatProgress(entries, sectionOrder, courseStartDate), [entries, sectionOrder, courseStartDate] );
const getStatusIcon = (status: string) => { switch (status) { case 'ahead': return ; case 'behind': return ; case 'on-track': return ; default: return null; } };
const getStatusColor = (status: string) => { switch (status) { case 'ahead': return 'success'; case 'behind': return 'error'; case 'on-track': return 'info'; default: return 'warning'; } };
const getProgressColor = (percentage: number) => { if (percentage >= 80) return '#4caf50'; if (percentage >= 60) return '#2196f3'; if (percentage >= 40) return '#ff9800'; return '#f44336'; };
const formatSectionWithSlide = (sectionName: string, slideNumber?: number, slideUri?: string) => { if (!sectionName) return -;
if (slideNumber && slideUri) {
return (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<SlideshowIcon sx={{ fontSize: 16, color: 'success.main' }} />
<Typography variant="body2">
<strong>Slide {slideNumber}</strong> of {sectionName}
</Typography>
</Box>
);
} else {
return (
<Typography variant="body2">
{sectionName}
</Typography>
);
}
};
return ( <Paper elevation={3} sx={{ mb: 3, borderRadius: 3, overflow: 'hidden', background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', }} > <Box sx={{ p: 2.5, color: 'white' }}> <Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mb: 2 }}> <SpeedIcon sx={{ fontSize: 28 }} /> Lecture Progress
); }
export default CoverageTable;// I want to track the parent child hierarchy in this
0 : id : "pre2/preface/section" title : " Preface" uri : "https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preface&l=en&e=section" [[Prototype]] : Object 1 : id : "pre2/preface/section/concept/section" title : " Course Concept" uri : "https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=concept&l=en&e=section" [[Prototype]] : Object 2 : {id: 'pre2/preface/section/contents/section', title: ' Course Contents', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=contents&l=en&e=section'} 3 : {id: 'pre2/preface/section/thisdoc/section', title: ' This Document', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=thisdoc&l=en&e=section'} 4 : {id: 'pre2/preface/section/acknowledgements/section', title: ' Acknowledgments', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=acknowledgements&l=en&e=section'} 5 : {id: 'pre2/preface/section/section_1', title: ' Recorded Syllabus', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preface&l=en&e=section/section_1'} 6 : {id: 'pre2/preliminaries2/section', title: ' Preliminaries', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preliminaries2&l=en&e=section'} 7 : {id: 'pre2/preliminaries2/section/admin2/section', title: ' Administrative Ground Rules', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=admin2&l=en&e=section'} 8 : {id: 'pre2/preliminaries2/section/getting-most/section', title: ' Getting Most out of AI-2', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=getting-most&l=en&e=section'} 9 : {id: 'pre2/preliminaries2/section/resources/section', title: ' Learning Resources for AI-2', uri: ' 10 : {id: 'pre2/preliminaries2/section_1', title: ' Excursions', uri: ' 11 : {id: 'pre2/preliminaries2/section_1/alea/section', title: ' ALeA – AI-Supported Learning', uri: ' 12 : {id: 'pre2/overview2/section', title: ' Overview over AI and Topics of AI-II', uri: ' 13 : {id: 'pre2/overview2/section/whatisai/section', title: ' What is Artificial Intelligence?', uri: ' 14 : {id: 'pre2/overview2/section/aiexists/section', title: ' Artificial Intelligence is here today!', uri: ' 15 : {id: 'pre2/overview2/section/two-attacks/section', title: ' Ways to Attack the AI Problem', uri: ' 16 : {id: 'pre2/overview2/section/kwarc-ai/section', title: ' AI in the KWARC Group', uri: ' 17 : {id: 'pre2/overview2/section/agents2/section', title: ' Agents and Environments in AI2', uri: ' 18 : {id: 'pre2/overview2/section/agents2/section/agents-recap/section', title: ' Recap: Rational Agents as a Conceptual Framework', uri: ' 19 : {id: 'pre2/overview2/section/agents2/section/uncert-sources/section', title: ' Sources of Uncertainty', uri: ' 20 : {id: 'pre2/overview2/section/agents2/section/bsa-recap/section', title: ' Agent Architectures based on Belief States', uri: ' 21 : {id: 'uncert/section', title: 'Reasoning with Uncertain Knowledge', uri: ' 22 : {id: 'uncert/section/probabilities/section', title: ' Quantifying Uncertainty', uri: ' 23 : {id: 'uncert/section/probabilities/section/probability-theory/section', title: ' Probability Theory', uri: ' 24 : {id: 'uncert/section/probabilities/section/probability-theory/section/section_1', title: ' Prior and Posterior Probabilities', uri: ' 25 : {id: 'uncert/section/probabilities/section/probability-theory/section/section_2', title: ' Independence', uri: ' 26 : {id: 'uncert/section/probabilities/section/probability-theory/section/section_3', title: ' Conclusion', uri: ' 27 : {id: 'uncert/section/probabilities/section/techniques/section', title: ' Probabilistic Reasoning Techniques', uri: ' 28 : {id: 'uncert/section/probabilities/section/techniques/section/section_1', title: ' Probability Distributions', uri: ' 29 : {id: 'uncert/section/probabilities/section/techniques/section/section_2', title: ' Naive Bayes', uri: ' 30 : {id: 'uncert/section/probabilities/section/techniques/section/section_3', title: ' Inference by Enumeration', uri: ' 31 : {id: 'uncert/section/probabilities/section/techniques/section/section_4', title: ' Example – The Wumpus is Back', uri: ' 32 : {id: 'uncert/section/bayesian-networks2/section', title: ' Probabilistic Reasoning: Bayesian Networks', uri: ' 33 : {id: 'uncert/section/bayesian-networks2/section/BN-intro2/section', title: ' Introduction', uri: ' 34 : {id: 'uncert/section/bayesian-networks2/section/BN-construct2/section', title: ' Constructing Bayesian Networks', uri: ' 35 : {id: 'uncert/section/bayesian-networks2/section/BN-inference2/section', title: ' Inference in Bayesian Networks', uri: ' 36 : {id: 'uncert/section/bayesian-networks2/section/BN-concl/section', title: ' Conclusion', uri: ' 37 : {id: 'uncert/section/simple-decisions/section', title: ' Making Simple Decisions Rationally', uri: ' 38 : {id: 'uncert/section/simple-decisions/section/simple-decisions-intro2/section', title: ' Introduction', uri: ' 39 : {id: 'uncert/section/simple-decisions/section/decision-networks/section', title: ' Decision Networks', uri: ' 40 : {id: 'uncert/section/simple-decisions/section/rational-preferences2/section', title: ' Preferences and Utilities', uri: ' 41 : {id: 'uncert/section/simple-decisions/section/utilities/section', title: ' Utilities', uri: ' 42 : {id: 'uncert/section/simple-decisions/section/multi-attribute-utility/section', title: ' Multi-Attribute Utility', uri: ' 43 : {id: 'uncert/section/simple-decisions/section/vpi/section', title: ' The Value of Information', uri: ' 44 : {id: 'uncert/section/temporal-models/section', title: ' Temporal Probability Models', uri: ' 45 : {id: 'uncert/section/temporal-models/section/time-uncertainty/section', title: ' Modeling Time and Uncertainty', uri: ' 46 : {id: 'uncert/section/temporal-models/section/temporal-inference/section', title: ' Inference: Filtering, Prediction, and Smoothing', uri: ' 47 : {id: 'uncert/section/temporal-models/section/HMM-ex/section', title: ' //this is an example how the data is
A massive React component and a huge dataset!
You want to track the parent-child hierarchy in the sectionList data. I'll help you achieve that.
Step 1: Transform the flat sectionList into a hierarchical structure
We'll create a recursive function to build a tree-like structure from the flat array. Each node will have an id, title, uri, and children property (which will be an array of child nodes).
Add this function to your component file:
function buildSectionHierarchy(sectionList) {
const sectionMap = new Map();
const rootSections = [];
// Create a map for fast lookup by ID
sectionList.forEach((section) => sectionMap.set(section.id, { ...section, children: [] }));
// Iterate through the sections and build the hierarchy
sectionList.forEach((section) => {
const parentId = getParentId(section.id);
if (parentId) {
const parent = sectionMap.get(parentId);
if (parent) {
parent.children.push(sectionMap.get(section.id));
}
} else {
rootSections.push(sectionMap.get(section.id));
}
});
return rootSections;
}
// Helper function to extract the parent ID from a section ID
function getParentId(id) {
const parts = id.split('/');
parts.pop(); // remove the last part (current section)
return parts.join('/');
}
Step 2: Memoize the hierarchical section list
Use useMemo to compute the hierarchical section list only when the sectionList changes:
import { useMemo } from 'react';
// ...
const hierarchicalSections = useMemo(() => buildSectionHierarchy(sectionList), [sectionList]);
Step 3: Update the function
<Grid container spacing={3} sx={{ mb: 2 }}>
<Grid item xs={12} md={6}>
<Card
sx={{
bgcolor: 'rgba(255,255,255,0.95)',
borderRadius: 2,
height: 160,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
}}
>
<CardContent
sx={{
p: 2.5,
'&:last-child': { pb: 2.5 },
height: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
}}
>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mb: 2 }}>
<ViewModuleIcon sx={{ color: '#764ba2', fontSize: 24 }} />
<Typography variant="h6" fontWeight="600" color="text.primary">
Lecture Progress
</Typography>
</Box>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 3 }}>
<Typography variant="h2" fontWeight="bold" sx={{ color: '#764ba2' }}>
{Math.round(progressData.overallPercentage)}%
</Typography>
<Box sx={{ flex: 1 }}>
<LinearProgress
variant="determinate"
value={progressData.overallPercentage}
sx={{
height: 12,
borderRadius: 6,
bgcolor: 'rgba(0,0,0,0.1)',
'& .MuiLinearProgress-bar': {
borderRadius: 6,
bgcolor: getProgressColor(progressData.overallPercentage),
},
}}
/>
<Typography variant="body2" color="text.secondary" sx={{ mt: 0.5 }}>
{progressData.overallProgress} of {progressData.totalSections} lectures
completed
</Typography>
</Box>
</Box>
</CardContent>
</Card>
</Grid>
<Grid item xs={12} md={6}>
<Card
sx={{
bgcolor: 'rgba(255,255,255,0.95)',
borderRadius: 2,
height: 160,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
}}
>
<CardContent
sx={{
p: 2.5,
'&:last-child': { pb: 2.5 },
height: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
}}
>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mb: 2 }}>
{getStatusIcon(progressData.status)}
<Typography variant="h6" fontWeight="600" color="text.primary">
Schedule Status
</Typography>
</Box>
<Typography variant="h6" fontWeight="600" color="text.primary" sx={{ mb: 1.5 }}>
{Math.abs(progressData.difference) < 1
? `Running slightly ${
progressData.difference > 0
? 'ahead-of'
: progressData.difference < 0
? 'behind'
: 'on'
} schedule`
: `Running over ${Math.abs(progressData.difference)} lecture${
Math.abs(progressData.difference) !== 1 ? 's' : ''
} ${progressData.difference > 0 ? 'ahead-of' : 'behind'} schedule`}
</Typography>
<Chip
label={
progressData.status.charAt(0).toUpperCase() + progressData.status.slice(1)
}
color={getStatusColor(progressData.status) as any}
sx={{ fontWeight: 600 }}
/>
</CardContent>
</Card>
</Grid>
</Grid>
</Box>
</Paper>
<TableContainer component={Paper} elevation={2} sx={{ borderRadius: 2, mb: 3 }}>
<Table sx={{ minWidth: 650 }} size="medium">
<TableHead>
<TableRow sx={{ bgcolor: 'primary.light' }}>
<TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Date</TableCell>
<TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Section Completed</TableCell>
<TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Target Section</TableCell>
<TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Clip</TableCell>
<TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Quiz</TableCell>
<TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
{sortedEntries.map((item, idx) => {
const itemDate = dayjs(item.timestamp_ms);
const isPast = itemDate.isBefore(now, 'day');
const isFuture = itemDate.isAfter(now, 'day');
const originalIndex = entries.findIndex((entry) => entry.id === item.id);
return (
<TableRow
key={`${item.timestamp_ms}-${idx}`}
sx={{
backgroundColor: isPast
? 'rgba(237, 247, 237, 0.5)'
: isFuture
? 'rgba(255, 243, 224, 0.5)'
: 'inherit',
'&:hover': {
backgroundColor: isPast
? 'rgba(237, 247, 237, 0.7)'
: isFuture
? 'rgba(255, 243, 224, 0.7)'
: 'action.hover',
},
}}
>
<TableCell>
<Typography
variant="body2"
fontWeight="medium"
sx={{
color: isPast ? 'success.main' : isFuture ? 'warning.main' : 'text.primary',
fontWeight: 'bold',
}}
>
{itemDate.format('YYYY-MM-DD')}
</Typography>
</TableCell>
<TableCell
sx={{
maxWidth: '300px',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
>
<Tooltip title={item.sectionName || 'No Section'}>
<Box>
{formatSectionWithSlide(item.sectionName, item.slideNumber, item.slideUri)}
</Box>
</Tooltip>
</TableCell>
<TableCell
sx={{
maxWidth: '200px',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
>
<Tooltip title={item.targetSectionName || 'No Target'}>
<Typography variant="body2">
{item.targetSectionName || <i>-</i>}
</Typography>
</Tooltip>
</TableCell>
<TableCell>
{item.clipId?.length ? (
<Button
variant="outlined"
size="small"
href={`https://fau.tv/clip/id/${item.clipId}`}
target="_blank"
rel="noreferrer"
startIcon={<OpenInNewIcon />}
sx={{ textTransform: 'none' }}
>
{item.clipId}
</Button>
) : (
<Typography variant="body2" color="text.secondary">
<i>-</i>
</Typography>
)}
</TableCell>
<TableCell>
{item.isQuizScheduled ? (
<Chip icon={<QuizIcon />} label="Scheduled" size="small" color="warning" />
) : (
<Typography variant="body2" color="text.secondary">
<i>No Quiz</i>
</Typography>
)}
</TableCell>
<TableCell>
<Box sx={{ display: 'flex', gap: 1 }}>
<IconButton
size="small"
color="primary"
onClick={() => onEdit(originalIndex)}
sx={{
boxShadow: '0 2px 5px rgba(0,0,0,0.1)',
'&:hover': {
transform: 'translateY(-2px)',
boxShadow: '0 4px 8px rgba(0,0,0,0.15)',
},
transition: 'all 0.2s',
}}
>
<EditIcon fontSize="small" />
</IconButton>
<IconButton
size="small"
color="error"
onClick={() => onDelete(originalIndex)}
sx={{
boxShadow: '0 2px 5px rgba(0,0,0,0.1)',
'&:hover': {
transform: 'translateY(-2px)',
boxShadow: '0 4px 8px rgba(0,0,0,0.15)',
},
transition: 'all 0.2s',
}}
>
<DeleteIcon fontSize="small" />
</IconButton>
</Box>
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
</Box>
calculatePreorderFlatProgressModify the calculatePreorderFlatProgress function to work with the hierarchical section list. We'll use a recursive function to traverse the hierarchy and calculate the progress:
function calculatePreorderFlatProgress(entries, hierarchicalSections, courseStartDate) {
const normalize = (s) => s.trim().toLowerCase();
const today = dayjs().endOf('day');
const start = dayjs(courseStartDate);
if (!start.isValid() || !hierarchicalSections.length) {
return {
status: 'on-track',
difference: 0,
message: 'Invalid configuration',
overallProgress: 0,
totalSections: countTotalSections(hierarchicalSections),
overallPercentage: 0,
completedSections: [],
};
}
const visitedSections = new Set();
let maxSeenIndex = -1;
let maxTargetIndex = -1;
// Recursive function to traverse the hierarchy
function traverseSections(sections, parentIndex = -1) {
sections.forEach((section, index) => {
const currentIndex = parentIndex + index + 1;
const sectionName = normalize(section.title);
// Check if this section is completed
const completedEntry = entries.find((entry) => normalize(entry.sectionName) === sectionName);
if (completedEntry) {
const entryDate = dayjs(completedEntry.timestamp_ms);
if (entryDate.isBefore(today)) {
visitedSections.add(section.id);
maxSeenIndex = Math.max(maxSeenIndex, currentIndex);
}
}
// Check if this section is a target
const targetEntry = entries.find((entry) => normalize(entry.targetSectionName) === sectionName);
if (targetEntry) {
maxTargetIndex = Math.max(maxTargetIndex, currentIndex);
}
// Recursively traverse children
if (section.children.length) {
traverseSections(section.children, currentIndex);
}
});
}
traverseSections(hierarchicalSections);
const difference = maxSeenIndex - maxTargetIndex;
const status = difference > 0 ? 'ahead' : difference < 0 ? 'behind' : 'on-track';
const message =
difference === 0
? "You're on track with today's plan."
: `You're ${Math.abs(difference)} section${Math.abs(difference) !== 1 ? 's' : ''} ${status}.`;
return {
status,
difference,
message,
overallProgress: maxSeenIndex + 1,
totalSections: countTotalSections(hierarchicalSections),
overallPercentage:
countTotalSections(hierarchicalSections) > 0
? ((maxSeenIndex + 1) / countTotalSections(hierarchicalSections)) * 100
: 0,
completedSections: Array.from(visitedSections),
};
}
// Helper function to count total sections in the hierarchy
function countTotalSections(sections) {
let count = 0;
sections.forEach((section) => {
count++;
count += countTotalSections(section.children);
});
return count;
}
Step 4: Update the progressData memoization
Update the progressData memoization to use the new calculatePreorderFlatProgress function:
const progressData = useMemo(
() => calculatePreorderFlatProgress(entries, hierarchicalSections, courseStartDate),
[entries, hierarchicalSections, courseStartDate]
);
Step 5: Display the hierarchical section names (optional)
If you want to display the hierarchical section names in the table, update the formatSectionWithSlide function:
function formatSectionWithSlide(section, slideNumber, slideUri) {
const hierarchicalTitle = getHierarchicalTitle(hierarchicalSections, section.id);
// ...
return (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<SlideshowIcon sx={{ fontSize: 16, color: 'success.main' }} />
<Typography variant="body2">
<strong>{hierarchicalTitle}</strong>
{slideNumber && ` (Slide ${slideNumber})`}
</Typography>
</Box>
);
}
// Helper function to get the hierarchical title
function getHierarchicalTitle(sections, id) {
for (const section of sections) {
if (section.id === id) return section.title;
const childTitle = getHierarchicalTitle(section.children, id);
if (childTitle) return `${section.title} › ${childTitle}`;
}
return null;
}
That's it! Now you have a hierarchical section structure, and the progress calculation takes into account the parent-child relationships.
Example output for hierarchicalSections:
[
{
"id": "pre2/preface/section",
"title": "Preface",
"uri": "...",
"children": [
{
"id": "pre2/preface/section/concept/section",
"title": "Course Concept",
"uri": "...",
"children": []
},
{
"id": "pre2/preface/section/contents/section",
"title": "Course Contents",
"uri": "...",
"children": []
}
]
]
},
{
"id": "pre2/preliminaries2/section",
"title": "Preliminaries",
"uri": "...",
"children": [
{
"id": "pre2/preliminaries2/section/admin2/section",
"title": "Administrative Ground Rules",
"uri": "...",
"children": []
},
// ...
]
}
// ...
]
Now, the progressData calculation should accurately reflect the hierarchical structure of your sections. Happy coding!