feat: show quiz in between videos

This commit is contained in:
Jannat Patel
2025-05-30 13:00:00 +05:30
parent ade47b4e83
commit 60334ca04a
6 changed files with 284 additions and 75 deletions

View File

@@ -28,20 +28,21 @@ export function timeAgo(date) {
export function formatTime(timeString) {
if (!timeString) return ''
const [hour, minute] = timeString.split(':').map(Number)
// Create a Date object with dummy values for day, month, and year
const dummyDate = new Date(0, 0, 0, hour, minute)
// Use Intl.DateTimeFormat to format the time in 12-hour format
const formattedTime = new Intl.DateTimeFormat('en-US', {
hour: 'numeric',
minute: 'numeric',
hour12: true,
}).format(dummyDate)
return formattedTime
}
export const formatSeconds = (time) => {
const minutes = Math.floor(time / 60)
const seconds = Math.floor(time % 60)
return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`
}
export function formatNumber(number) {
return number.toLocaleString('en-IN', {
maximumFractionDigits: 0,

View File

@@ -46,7 +46,13 @@ export class Upload {
if (this.isVideo(file.file_type)) {
const app = createApp(VideoBlock, {
file: file.file_url,
readOnly: this.readOnly,
saveQuizzes: (quizzes) => {
if (this.readOnly) return
this.data.quizzes = quizzes
},
})
app.use(translationPlugin)
app.mount(this.wrapper)
return
} else if (this.isAudio(file.file_type)) {
@@ -93,6 +99,7 @@ export class Upload {
return {
file_url: this.data.file_url,
file_type: this.data.file_type,
quizzes: this.data.quizzes || [],
}
}