fix: lesson youtube video issue

This commit is contained in:
Jannat Patel
2024-04-15 12:35:27 +05:30
parent a62b754d28
commit 16570469e6
4 changed files with 25 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
<div v-if="youtube">
<iframe
class="youtube-video"
:src="getYouTubeVideoSource(youtube)"
:src="getYouTubeVideoSource(youtube.split('/').pop())"
width="100%"
height="400"
frameborder="0"
@@ -54,6 +54,7 @@
</div>
<div v-else v-html="markdown.render(block)"></div>
</div>
{{ quizId }}
<div v-if="quizId">
<Quiz :quiz="quizId" />
</div>

View File

@@ -27,7 +27,7 @@
<div v-if="quiz.doc.time" class="leading-relaxed">
{{
__(
'The quiz has a time limit.For each question you will be given { 0} seconds.'
'The quiz has a time limit.For each question you will be given {0} seconds.'
).format(quiz.doc.time)
}}
</div>

View File

@@ -208,6 +208,16 @@ const lessonReference = createResource({
const convertToJSON = (lessonData) => {
let blocks = []
if (lessonData.youtube) {
let youtubeID = lessonData.youtube.split('/').pop()
blocks.push({
type: 'embed',
data: {
service: 'youtube',
embed: `https://www.youtube.com/embed/${youtubeID}`,
},
})
}
lessonData.body.split('\n').forEach((block) => {
if (block.includes('{{ YouTubeVideo')) {
let youtubeID = block.match(/\(["']([^"']+?)["']\)/)[1]
@@ -291,6 +301,16 @@ const convertToJSON = (lessonData) => {
})
}
})
if (lessonData.quizId) {
blocks.push({
type: 'quiz',
data: {
quiz: lessonData.quizId,
},
})
}
return blocks
}

View File

@@ -1769,6 +1769,8 @@ def get_lesson_creation_details(course, chapter, lesson):
"content",
"instructor_notes",
"instructor_content",
"youtube",
"quiz_id",
],
as_dict=1,
)