1- import { Alert , CircularProgress , IconButton , Switch , TableContainer , Table , TableHead , TableRow , TableBody , TableCell , Paper , Tooltip , Typography } from '@mui/material' ;
1+ import { Alert , Box , CircularProgress , Chip , IconButton , Switch , TableContainer , Table , TableHead , TableRow , TableBody , TableCell , Paper , Tooltip , Typography } from '@mui/material' ;
22import { useState , useEffect } from 'react' ;
33import { getCookie } from '../../../src/utils.js' ;
44import DeleteIcon from '@mui/icons-material/Delete' ;
55import DragIndicatorIcon from '@mui/icons-material/DragIndicator' ;
66import ForwardToInboxOutlinedIcon from '@mui/icons-material/ForwardToInboxOutlined' ;
7+
78import { useAppContext } from '../../../src/render.jsx' ;
89
910
@@ -23,6 +24,8 @@ const ContentTable = ({ courseId, eventHandler, loaded = false }) => {
2324 const { apiBaseUrl, userRole, localeMessages, direction } = useAppContext ( ) ;
2425 const organizationId = localStorage . getItem ( 'activeOrganizationId' ) ;
2526 const canSendLesson = userRole === 'admin' || userRole === 'editor' ;
27+ const showQuizTwoAttemptNote = contentList . some ( ( content ) => content . type === 'quiz' && content . limited_attempts == true ) ;
28+ const showQuizUnlimitedAttemptsNote = contentList . some ( ( content ) => content . type === 'quiz' && content . limited_attempts == false ) ;
2629
2730 const formatPeriod = ( period ) => {
2831 if ( ! period ) {
@@ -233,8 +236,11 @@ const ContentTable = ({ courseId, eventHandler, loaded = false }) => {
233236 onMouseDown = { ( event ) => startDrag ( event , content . id ) }
234237 /> </ TableCell > }
235238 < TableCell align = { direction == 'rtl' ? 'right' : 'left' } > < Typography
239+ component = "span"
236240 onClick = { ( ) => { let event = { type : 'content_clicked' , content_id : content . id } ; eventHandler ( event ) ; } }
237- sx = { { cursor : 'pointer' , color : theme => theme . palette . mode === 'dark' ? theme . palette . secondary . main : theme . palette . secondary . dark } } > { content . title } </ Typography > </ TableCell >
241+ sx = { { cursor : 'pointer' , color : theme => theme . palette . mode === 'dark' ? theme . palette . secondary . main : theme . palette . secondary . dark } } > { content . title }
242+ { content . limited_attempts !== null && ( content . limited_attempts ? < Chip label = { localeMessages [ "two_attempts" ] } size = "small" sx = { ( theme ) => ( { ml : 1 , backgroundColor : theme . palette . mode === 'dark' ? 'rgba(255, 152, 0, 0.15)' : 'rgba(255, 203, 71, 0.5)' , color : theme . palette . mode === 'dark' ? '#FF9800' : '#9a4208' } ) }
243+ /> : < Chip label = { localeMessages [ "unlimited_attempts" ] } size = "small" sx = { ( theme ) => ( { ml : 1 , backgroundColor : theme . palette . mode === 'dark' ? 'rgba(76, 175, 80, 0.15)' : 'rgba(129, 199, 132, 0.5)' , color : theme . palette . mode === 'dark' ? '#4CAF50' : '#256029' } ) } /> ) } </ Typography > </ TableCell >
238244 < TableCell align = { direction == 'rtl' ? 'right' : 'left' } > { formatPeriod ( content . waiting_period ) } </ TableCell >
239245 < TableCell align = { direction == 'rtl' ? 'right' : 'left' } > { localeMessages [ content . type ] } </ TableCell >
240246 < TableCell align = { direction == 'rtl' ? 'right' : 'left' } > < Switch checked = { content . is_published } onChange = { ( ) => TogglePublishContent ( content . id , ! content . is_published ) } disabled = { userRole == 'viewer' } /> </ TableCell >
@@ -265,6 +271,30 @@ const ContentTable = ({ courseId, eventHandler, loaded = false }) => {
265271 </ TableBody >
266272 </ Table >
267273 </ TableContainer >
274+ { ( showQuizTwoAttemptNote || showQuizUnlimitedAttemptsNote ) && (
275+ < Box
276+ sx = { {
277+ mt : 1.5 ,
278+ px : 1.5 ,
279+ py : 1 ,
280+ borderRadius : 1 ,
281+ backgroundColor : 'action.hover' ,
282+ border : '1px solid' ,
283+ borderColor : 'divider' ,
284+ } }
285+ >
286+ { showQuizTwoAttemptNote && (
287+ < Typography component = "div" variant = "caption" color = "text.secondary" sx = { { display : 'block' } } >
288+ • < Box component = "span" sx = { { fontWeight : 600 } } > { localeMessages [ "two_attempts" ] } :</ Box > { localeMessages [ "quiz_2_attempts_sub_note" ] }
289+ </ Typography >
290+ ) }
291+ { showQuizUnlimitedAttemptsNote && (
292+ < Typography component = "div" variant = "caption" color = "text.secondary" sx = { { display : 'block' , mt : showQuizTwoAttemptNote ? 0.5 : 0 } } >
293+ • < Box component = "span" sx = { { fontWeight : 600 } } > { localeMessages [ "unlimited_attempts" ] } :</ Box > { localeMessages [ "quiz_unlimited_attempts_sub_note" ] }
294+ </ Typography >
295+ ) }
296+ </ Box >
297+ ) }
268298 </ >
269299 ) ;
270300}
0 commit comments