Spaces:
Sleeping
Sleeping
File size: 2,820 Bytes
c3ad400 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
import React from 'react';
import {
Card,
CardContent,
Typography,
Link,
Divider,
List,
ListItem,
ListItemText,
Radio,
RadioGroup,
FormControlLabel
} from '@mui/material';
function NodeContent({ node }) {
if (!node) return null;
return (
<Card>
<CardContent>
<Typography variant="h5" gutterBottom>
{node.title}
</Typography>
<Divider />
{/* 內容區 */}
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
內容
</Typography>
<div dangerouslySetInnerHTML={{ __html: node.content }} />
{/* 資源連結 */}
{node.resources && (
<>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
延伸資源
</Typography>
<List>
{node.resources.map((resource, index) => (
<ListItem key={index}>
<ListItemText>
<Link href={resource.url} target="_blank" rel="noopener noreferrer">
{resource.type}: {resource.url}
</Link>
</ListItemText>
</ListItem>
))}
</List>
</>
)}
{/* AI 對話記錄 */}
{node.aiChats && (
<>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
AI 對話記錄
</Typography>
<List>
{node.aiChats.map((chat, index) => (
<ListItem key={index}>
<ListItemText
primary={<strong>Q: {chat.question}</strong>}
secondary={`A: ${chat.answer}`}
/>
</ListItem>
))}
</List>
</>
)}
{/* 練習區 */}
{node.exercises && (
<>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
練習題
</Typography>
{node.exercises.map((exercise) => (
<div key={exercise.id}>
<Typography variant="subtitle1" gutterBottom>
{exercise.question}
</Typography>
{exercise.type === 'multiple_choice' && (
<RadioGroup name={exercise.id}>
{exercise.options.map((option, index) => (
<FormControlLabel
key={index}
value={index.toString()}
control={<Radio />}
label={option}
/>
))}
</RadioGroup>
)}
</div>
))}
</>
)}
</CardContent>
</Card>
);
}
export default NodeContent; |