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
<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>
); }
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
To display the parent-child hierarchy for section names in the CoverageTable, we'll leverage the sectionList prop, which provides the full hierarchical structure including the indented titles.
Here's the plan:
CoverageTable, we'll use useMemo to create a Map that quickly allows us to find a section's full details (including its hierarchical title) by its uri.formatSectionWithSlide function (and introduce a helper) to use this lookup map. Instead of just displaying sectionName, it will attempt to find the corresponding entry in sectionList using sectionUri and display its title property, which inherently includes the hierarchical indentation. This will be applied to both "Section Completed" and "Target Section" columns.Here's the updated CoverageTable component:
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; // Add sectionUri to interface
targetSectionName: string;
targetSectionUri: string; // Add targetSectionUri to interface
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 }>; // Existing prop
}
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;
// Note: This calculation uses sectionName/targetSectionName for simplicity
// and relies on sectionOrder being a flat list of these names.
// If progress needed to be based on hierarchical IDs, this would need
// significant re-architecting, which is outside the scope of this request.
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 = '',
sectionList = [], // Destructure sectionList prop
}: 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]
);
// Create a map for quick lookup of section details by URI
const sectionLookupMap = useMemo(() => {
return new Map(sectionList.map(sec => [sec.uri, sec]));
}, [sectionList]);
const getStatusIcon = (status: string) => {
switch (status) {
case 'ahead':
return <TrendingUpIcon />;
case 'behind':
return <TrendingDownIcon />;
case 'on-track':
return <CheckCircleIcon />;
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';
};
/**
* Retrieves the hierarchical title for a section using its URI from the lookup map.
* Falls back to the provided fallbackName if URI is not found or invalid.
*/
const getHierarchicalSectionTitle = (
sectionUri: string | undefined,
fallbackName: string
): string | React.ReactNode => {
if (!sectionUri) {
return fallbackName || <i>-</i>;
}
const sectionInfo = sectionLookupMap.get(sectionUri);
if (sectionInfo && sectionInfo.title) {
// The `title` property from sectionList already contains the desired indentation.
return sectionInfo.title;
}
return fallbackName || <i>-</i>;
};
const formatSectionWithSlide = (
sectionName: string,
slideNumber?: number,
slideUri?: string,
sectionUri?: string // Now expects sectionUri
) => {
// Get the hierarchical title using the URI, falling back to original sectionName
const displaySectionTitle = getHierarchicalSectionTitle(sectionUri, sectionName);
if (!displaySectionTitle) return <i>-</i>;
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 {displaySectionTitle}
</Typography>
</Box>
);
} else {
return (
<Typography variant="body2">
{displaySectionTitle}
</Typography>
);
}
};
return (
<Box>
<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 }} />
<Typography variant="h6" fontWeight="600">
Lecture Progress
</Typography>
</Box>
<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', // Removed this to allow multi-line for long titles
}}
>
<Tooltip title={item.sectionName || 'No Section'}>
<Box>
{formatSectionWithSlide(item.sectionName, item.slideNumber, item.slideUri, item.sectionUri)}
</Box>
</Tooltip>
</TableCell>
<TableCell
sx={{
maxWidth: '200px',
overflow: 'hidden',
textOverflow: 'ellipsis',
// whiteSpace: 'nowrap', // Removed this to allow multi-line for long titles
}}
>
<Tooltip title={item.targetSectionName || 'No Target'}>
<Typography variant="body2">
{getHierarchicalSectionTitle(item.targetSectionUri, item.targetSectionName)}
</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>
);
}
export default CoverageTable;