feat: quiz plugin in lesson
This commit is contained in:
@@ -77,7 +77,6 @@ const valuePropPassed = computed(() => 'value' in attrs)
|
|||||||
const value = computed({
|
const value = computed({
|
||||||
get: () => (valuePropPassed.value ? attrs.value : props.modelValue),
|
get: () => (valuePropPassed.value ? attrs.value : props.modelValue),
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
console.log(val?.value, valuePropPassed.value)
|
|
||||||
return (
|
return (
|
||||||
val?.value &&
|
val?.value &&
|
||||||
emit(valuePropPassed.value ? 'change' : 'update:modelValue', val?.value)
|
emit(valuePropPassed.value ? 'change' : 'update:modelValue', val?.value)
|
||||||
|
|||||||
26
frontend/src/components/QuizBlock.vue
Normal file
26
frontend/src/components/QuizBlock.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<Quiz v-if="user.data" :quizName="quiz"></Quiz>
|
||||||
|
<div v-else class="border rounded-md text-center py-20">
|
||||||
|
<div>
|
||||||
|
{{ __('Please login to access the quiz.') }}
|
||||||
|
</div>
|
||||||
|
<Button @click="redirectToLogin()" class="mt-2">
|
||||||
|
<span>
|
||||||
|
{{ __('Login') }}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { inject } from 'vue'
|
||||||
|
import { Button } from 'frappe-ui'
|
||||||
|
import Quiz from '@/components/Quiz.vue'
|
||||||
|
|
||||||
|
const user = inject('$user')
|
||||||
|
const props = defineProps({
|
||||||
|
quiz: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -265,7 +265,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const course = computed(() => {
|
/* const course = computed(() => {
|
||||||
return {
|
return {
|
||||||
title: courseResource.doc?.title || '',
|
title: courseResource.doc?.title || '',
|
||||||
short_introduction: courseResource.doc?.short_introduction || '',
|
short_introduction: courseResource.doc?.short_introduction || '',
|
||||||
@@ -284,6 +284,21 @@ const course = computed(() => {
|
|||||||
currency: courseResource.doc?.currency || '',
|
currency: courseResource.doc?.currency || '',
|
||||||
image: courseResource.doc?.image || null,
|
image: courseResource.doc?.image || null,
|
||||||
}
|
}
|
||||||
|
}) */
|
||||||
|
|
||||||
|
const course = reactive({
|
||||||
|
title: '',
|
||||||
|
short_introduction: '',
|
||||||
|
description: '',
|
||||||
|
video_link: '',
|
||||||
|
course_image: null,
|
||||||
|
tags: '',
|
||||||
|
published: false,
|
||||||
|
upcoming: false,
|
||||||
|
disable_self_learning: false,
|
||||||
|
paid_course: false,
|
||||||
|
course_price: '',
|
||||||
|
currency: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const getTags = computed(() => {
|
const getTags = computed(() => {
|
||||||
@@ -291,21 +306,6 @@ const getTags = computed(() => {
|
|||||||
? courseResource.doc.tags.split(', ')
|
? courseResource.doc.tags.split(', ')
|
||||||
: tags.value?.split(', ')
|
: tags.value?.split(', ')
|
||||||
})
|
})
|
||||||
/*
|
|
||||||
const course = reactive({
|
|
||||||
title: '',
|
|
||||||
short_introduction: '',
|
|
||||||
description: '',
|
|
||||||
video_link: '',
|
|
||||||
course_image: null,
|
|
||||||
tags: "",
|
|
||||||
published: false,
|
|
||||||
upcoming: false,
|
|
||||||
disable_self_learning: false,
|
|
||||||
paid_course: false,
|
|
||||||
course_price: '',
|
|
||||||
currency: '',
|
|
||||||
}) */
|
|
||||||
|
|
||||||
const courseCreationResource = createResource({
|
const courseCreationResource = createResource({
|
||||||
url: 'frappe.client.insert',
|
url: 'frappe.client.insert',
|
||||||
@@ -321,7 +321,6 @@ const courseCreationResource = createResource({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const submitCourse = () => {
|
const submitCourse = () => {
|
||||||
console.log(courseResource.doc?.modified)
|
|
||||||
if (courseResource.doc) {
|
if (courseResource.doc) {
|
||||||
courseResource.setValue.submit(
|
courseResource.setValue.submit(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="h-screen text-base">
|
<div class="h-screen text-base">
|
||||||
|
<div class="grid grid-cols-[75%,25%] h-full">
|
||||||
|
<div>
|
||||||
<header
|
<header
|
||||||
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
|
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
|
||||||
>
|
>
|
||||||
<Breadcrumbs :items="breadcrumbs" />
|
<Breadcrumbs :items="breadcrumbs" />
|
||||||
|
<Button variant="solid" @click="saveLesson()">
|
||||||
|
{{ __('Save') }}
|
||||||
|
</Button>
|
||||||
</header>
|
</header>
|
||||||
<div class="w-7/12 mx-auto py-5">
|
<div class="w-5/6 mx-auto py-5">
|
||||||
<div class="flex items-center justify-between mb-5">
|
<div class="flex items-center justify-between mb-5">
|
||||||
<div class="text-lg font-semibold">
|
<div class="text-lg font-semibold">
|
||||||
{{ __('Lesson Details') }}
|
{{ __('Lesson Details') }}
|
||||||
</div>
|
</div>
|
||||||
<Button variant="solid" @click="saveLesson()">
|
|
||||||
{{ __('Save') }}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
<FormControl v-model="lesson.title" label="Title" class="mb-4" />
|
<FormControl v-model="lesson.title" label="Title" class="mb-4" />
|
||||||
<FormControl
|
<FormControl
|
||||||
@@ -24,7 +26,10 @@
|
|||||||
<label class="block text-xs text-gray-600 mb-1">
|
<label class="block text-xs text-gray-600 mb-1">
|
||||||
{{ __('Instructor Notes') }}
|
{{ __('Instructor Notes') }}
|
||||||
</label>
|
</label>
|
||||||
<div id="instructor-notes" class="border rounded-md px-10 py-3"></div>
|
<div
|
||||||
|
id="instructor-notes"
|
||||||
|
class="border rounded-md px-10 py-3"
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<label class="block text-xs text-gray-600 mb-1">
|
<label class="block text-xs text-gray-600 mb-1">
|
||||||
@@ -34,6 +39,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="border-l px-5 pt-5">
|
||||||
|
<div class="text-lg font-semibold">
|
||||||
|
{{ __('Components') }}
|
||||||
|
</div>
|
||||||
|
<div class="mt-5">
|
||||||
|
<div class="flex">
|
||||||
|
<Link
|
||||||
|
v-model="quiz"
|
||||||
|
class="flex-1"
|
||||||
|
doctype="LMS Quiz"
|
||||||
|
:label="__('Select a Quiz')"
|
||||||
|
/>
|
||||||
|
<Button @click="addQuiz()" class="self-end ml-2">
|
||||||
|
<template #icon>
|
||||||
|
<Plus class="h-4 w-4 stroke-1.5" />
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
@@ -43,18 +70,16 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
createDocumentResource,
|
createDocumentResource,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { computed, reactive, onMounted, inject } from 'vue'
|
import { computed, reactive, onMounted, inject, ref } from 'vue'
|
||||||
import EditorJS from '@editorjs/editorjs'
|
import EditorJS from '@editorjs/editorjs'
|
||||||
import Header from '@editorjs/header'
|
|
||||||
import Paragraph from '@editorjs/paragraph'
|
|
||||||
import List from '@editorjs/list'
|
|
||||||
import Embed from '@editorjs/embed'
|
|
||||||
import YouTubeVideo from '../utils/youtube.js'
|
|
||||||
import { createToast } from '../utils'
|
import { createToast } from '../utils'
|
||||||
|
import Link from '@/components/Controls/Link.vue'
|
||||||
|
import { Plus } from 'lucide-vue-next'
|
||||||
|
import { getEditorTools } from '../utils'
|
||||||
|
|
||||||
let editor
|
let editor
|
||||||
let editLessonResource
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
|
const quiz = ref(null)
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
courseName: {
|
courseName: {
|
||||||
@@ -85,38 +110,6 @@ const renderEditor = (holder) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const getEditorTools = () => {
|
|
||||||
return {
|
|
||||||
header: Header,
|
|
||||||
youtube: YouTubeVideo,
|
|
||||||
paragraph: {
|
|
||||||
class: Paragraph,
|
|
||||||
inlineToolbar: true,
|
|
||||||
config: {
|
|
||||||
preserveBlank: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
list: List,
|
|
||||||
embed: {
|
|
||||||
class: Embed,
|
|
||||||
config: {
|
|
||||||
services: {
|
|
||||||
youtube: true,
|
|
||||||
vimeo: true,
|
|
||||||
codepen: true,
|
|
||||||
slides: {
|
|
||||||
regex:
|
|
||||||
/https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
|
||||||
embedUrl:
|
|
||||||
'https://docs.google.com/presentation/d/e/<%= remote_id %>/embed',
|
|
||||||
html: "<iframe width='100%' height='300' frameborder='0' allowfullscreen='true'></iframe>",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const lesson = reactive({
|
const lesson = reactive({
|
||||||
title: '',
|
title: '',
|
||||||
include_in_preview: false,
|
include_in_preview: false,
|
||||||
@@ -135,7 +128,13 @@ const lessonDetails = createResource({
|
|||||||
auto: true,
|
auto: true,
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
if (data.lesson) {
|
if (data.lesson) {
|
||||||
createEditResource(data)
|
Object.keys(data.lesson).forEach((key) => {
|
||||||
|
lesson[key] = data.lesson[key]
|
||||||
|
})
|
||||||
|
lesson.include_in_preview = data.include_in_preview ? true : false
|
||||||
|
editor.isReady.then(() => {
|
||||||
|
editor.render(JSON.parse(data.lesson.content))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -154,24 +153,16 @@ const newLessonResource = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const createEditResource = (data) => {
|
const editLesson = createResource({
|
||||||
editLessonResource = createDocumentResource({
|
url: 'frappe.client.set_value',
|
||||||
|
makeParams(values) {
|
||||||
|
return {
|
||||||
doctype: 'Course Lesson',
|
doctype: 'Course Lesson',
|
||||||
name: data.lesson,
|
name: values.lesson,
|
||||||
auto: true,
|
fieldname: lesson,
|
||||||
onSuccess(data) {
|
}
|
||||||
Object.keys(data).forEach((key) => {
|
|
||||||
lesson[key] = data[key]
|
|
||||||
})
|
|
||||||
lesson.include_in_preview = data.include_in_preview ? true : false
|
|
||||||
console.log(editor)
|
|
||||||
console.log(editor.isReady)
|
|
||||||
editor.isReady.then(() => {
|
|
||||||
editor.render(JSON.parse(data.content))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
const lessonReference = createResource({
|
const lessonReference = createResource({
|
||||||
url: 'frappe.client.insert',
|
url: 'frappe.client.insert',
|
||||||
@@ -192,11 +183,10 @@ const lessonReference = createResource({
|
|||||||
const saveLesson = () => {
|
const saveLesson = () => {
|
||||||
editor.save().then((outputData) => {
|
editor.save().then((outputData) => {
|
||||||
lesson.content = JSON.stringify(outputData)
|
lesson.content = JSON.stringify(outputData)
|
||||||
console.log(editLessonResource?.doc?.modified)
|
if (lessonDetails.data?.lesson) {
|
||||||
if (editLessonResource?.doc) {
|
editLesson.submit(
|
||||||
editLessonResource.setValue.submit(
|
|
||||||
{
|
{
|
||||||
...lesson,
|
lesson: lessonDetails.data.lesson.name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
validate() {
|
validate() {
|
||||||
@@ -249,6 +239,20 @@ const validateLesson = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addQuiz = () => {
|
||||||
|
if (quiz.value) {
|
||||||
|
editor.blocks.insert(
|
||||||
|
'quiz',
|
||||||
|
{
|
||||||
|
quiz: quiz.value,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
editor.blocks.getBlocksCount()
|
||||||
|
)
|
||||||
|
quiz.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const showToast = (title, text, icon) => {
|
const showToast = (title, text, icon) => {
|
||||||
createToast({
|
createToast({
|
||||||
title: title,
|
title: title,
|
||||||
@@ -275,9 +279,9 @@ const breadcrumbs = computed(() => {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if (editLessonResource?.doc) {
|
if (lessonDetails?.data?.lesson) {
|
||||||
crumbs.push({
|
crumbs.push({
|
||||||
label: editLessonResource.doc.title,
|
label: lessonDetails.data.lesson.title,
|
||||||
route: {
|
route: {
|
||||||
name: 'Lesson',
|
name: 'Lesson',
|
||||||
params: {
|
params: {
|
||||||
@@ -289,7 +293,7 @@ const breadcrumbs = computed(() => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
crumbs.push({
|
crumbs.push({
|
||||||
label: editLessonResource?.doc ? 'Edit Lesson' : 'Create Lesson',
|
label: lessonDetails?.data?.lesson ? 'Edit Lesson' : 'Create Lesson',
|
||||||
route: {
|
route: {
|
||||||
name: 'CreateLesson',
|
name: 'CreateLesson',
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
@@ -115,11 +115,7 @@
|
|||||||
v-for="content in JSON.parse(lesson.data.content).blocks"
|
v-for="content in JSON.parse(lesson.data.content).blocks"
|
||||||
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6"
|
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6"
|
||||||
>
|
>
|
||||||
<div v-if="content.type == 'paragraph'">
|
<div id="editor"></div>
|
||||||
<div>
|
|
||||||
{{ content.data.text }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
@@ -147,17 +143,7 @@
|
|||||||
></iframe>
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="block.includes('{{ Quiz')">
|
<div v-else-if="block.includes('{{ Quiz')">
|
||||||
<Quiz v-if="user.data" :quizName="getId(block)"></Quiz>
|
<Quiz :quiz="getId(block)" />
|
||||||
<div v-else class="border rounded-md text-center py-20">
|
|
||||||
<div>
|
|
||||||
{{ __('Please login to access the quiz.') }}
|
|
||||||
</div>
|
|
||||||
<Button @click="redirectToLogin()" class="mt-2">
|
|
||||||
<span>
|
|
||||||
{{ __('Login') }}
|
|
||||||
</span>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="block.includes('{{ Video')">
|
<div v-else-if="block.includes('{{ Video')">
|
||||||
<video controls width="100%" controlsList="nodownload">
|
<video controls width="100%" controlsList="nodownload">
|
||||||
@@ -191,17 +177,7 @@
|
|||||||
<div v-else v-html="markdown.render(block)"></div>
|
<div v-else v-html="markdown.render(block)"></div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="lesson.data.quiz_id">
|
<div v-if="lesson.data.quiz_id">
|
||||||
<Quiz v-if="user.data" :quizName="getId(block)"></Quiz>
|
<Quiz :quiz="lesson.data.quiz_id" />
|
||||||
<div v-else class="border rounded-md text-center py-20">
|
|
||||||
<div>
|
|
||||||
{{ __('Please login to access the quiz.') }}
|
|
||||||
</div>
|
|
||||||
<Button @click="redirectToLogin()" class="mt-2">
|
|
||||||
<span>
|
|
||||||
{{ __('Login') }}
|
|
||||||
</span>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-20">
|
<div class="mt-20">
|
||||||
@@ -241,17 +217,20 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { createResource, Breadcrumbs, Button } from 'frappe-ui'
|
import { createResource, Breadcrumbs, Button } from 'frappe-ui'
|
||||||
import { computed, watch, ref, inject } from 'vue'
|
import { computed, watch, ref, inject, createApp } from 'vue'
|
||||||
import CourseOutline from '@/components/CourseOutline.vue'
|
import CourseOutline from '@/components/CourseOutline.vue'
|
||||||
import UserAvatar from '@/components/UserAvatar.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import MarkdownIt from 'markdown-it'
|
import MarkdownIt from 'markdown-it'
|
||||||
import { ChevronLeft, ChevronRight } from 'lucide-vue-next'
|
import { ChevronLeft, ChevronRight } from 'lucide-vue-next'
|
||||||
import Quiz from '@/components/Quiz.vue'
|
|
||||||
import Discussions from '@/components/Discussions.vue'
|
import Discussions from '@/components/Discussions.vue'
|
||||||
|
import Quiz from '@/components/QuizBlock.vue'
|
||||||
|
import { getEditorTools } from '../utils'
|
||||||
|
import EditorJS from '@editorjs/editorjs'
|
||||||
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
let editor
|
||||||
|
|
||||||
const markdown = new MarkdownIt({
|
const markdown = new MarkdownIt({
|
||||||
html: true,
|
html: true,
|
||||||
@@ -285,15 +264,28 @@ const lesson = createResource({
|
|||||||
},
|
},
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
|
console.log(data)
|
||||||
if (data.membership)
|
if (data.membership)
|
||||||
current_lesson.submit({
|
current_lesson.submit({
|
||||||
name: data.membership.name,
|
name: data.membership.name,
|
||||||
lesson_name: data.name,
|
lesson_name: data.name,
|
||||||
})
|
})
|
||||||
|
renderEditor()
|
||||||
markProgress(data)
|
markProgress(data)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const renderEditor = () => {
|
||||||
|
if (lesson.data?.content) {
|
||||||
|
editor = new EditorJS({
|
||||||
|
holder: 'editor',
|
||||||
|
tools: getEditorTools(),
|
||||||
|
data: JSON.parse(lesson.data.content),
|
||||||
|
readOnly: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const markProgress = (data) => {
|
const markProgress = (data) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!data.progress) progress.submit()
|
if (!data.progress) progress.submit()
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { toast } from 'frappe-ui'
|
import { toast } from 'frappe-ui'
|
||||||
import { useDateFormat, useTimeAgo } from '@vueuse/core'
|
import { useDateFormat, useTimeAgo } from '@vueuse/core'
|
||||||
import { BookOpen, Users, TrendingUp, Briefcase } from 'lucide-vue-next'
|
import { BookOpen, Users, TrendingUp, Briefcase } from 'lucide-vue-next'
|
||||||
|
import { Quiz } from '@/utils/quiz'
|
||||||
|
import Header from '@editorjs/header'
|
||||||
|
import Paragraph from '@editorjs/paragraph'
|
||||||
|
import List from '@editorjs/list'
|
||||||
|
import Embed from '@editorjs/embed'
|
||||||
|
|
||||||
export function createToast(options) {
|
export function createToast(options) {
|
||||||
toast({
|
toast({
|
||||||
@@ -64,6 +69,37 @@ export function getFileSize(file_size) {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEditorTools() {
|
||||||
|
return {
|
||||||
|
header: Header,
|
||||||
|
quiz: Quiz,
|
||||||
|
paragraph: {
|
||||||
|
class: Paragraph,
|
||||||
|
inlineToolbar: true,
|
||||||
|
config: {
|
||||||
|
preserveBlank: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
list: List,
|
||||||
|
embed: {
|
||||||
|
class: Embed,
|
||||||
|
config: {
|
||||||
|
services: {
|
||||||
|
youtube: true,
|
||||||
|
vimeo: true,
|
||||||
|
codepen: true,
|
||||||
|
slides: {
|
||||||
|
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
||||||
|
embedUrl:
|
||||||
|
'https://docs.google.com/presentation/d/e/<%= remote_id %>/embed',
|
||||||
|
html: "<iframe width='100%' height='300' frameborder='0' allowfullscreen='true'></iframe>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getTimezones() {
|
export function getTimezones() {
|
||||||
return [
|
return [
|
||||||
'Pacific/Midway',
|
'Pacific/Midway',
|
||||||
|
|||||||
58
frontend/src/utils/quiz.js
Normal file
58
frontend/src/utils/quiz.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import QuizBlock from '@/components/QuizBlock.vue'
|
||||||
|
import { createApp } from 'vue'
|
||||||
|
import { usersStore } from '../stores/user'
|
||||||
|
import translationPlugin from '../translation'
|
||||||
|
|
||||||
|
export class Quiz {
|
||||||
|
static get toolbox() {
|
||||||
|
return {
|
||||||
|
title: 'Quiz',
|
||||||
|
icon: `<img src="/assets/lms/icons/quiz.svg" width="15" height="15">`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor({ data, api, readOnly }) {
|
||||||
|
this.data = data
|
||||||
|
this.readOnly = readOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
static get isReadOnlySupported() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
this.wrapper = document.createElement('div')
|
||||||
|
if (this.data) {
|
||||||
|
let renderedQuiz = this.renderQuiz(this.data.quiz)
|
||||||
|
if (!this.readOnly) {
|
||||||
|
this.wrapper.innerHTML = renderedQuiz
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.wrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
renderQuiz(quiz) {
|
||||||
|
if (this.readOnly) {
|
||||||
|
const app = createApp(QuizBlock, {
|
||||||
|
quiz: quiz, // Pass quiz content as prop
|
||||||
|
})
|
||||||
|
app.use(translationPlugin)
|
||||||
|
const { userResource } = usersStore()
|
||||||
|
app.provide('$user', userResource)
|
||||||
|
app.mount(this.wrapper)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return `<div class='border rounded-md p-10 text-center'>
|
||||||
|
<span class="font-medium">
|
||||||
|
Quiz: ${quiz}
|
||||||
|
</span>
|
||||||
|
</div>`
|
||||||
|
}
|
||||||
|
|
||||||
|
save(blockContent) {
|
||||||
|
console.log(blockContent)
|
||||||
|
return {
|
||||||
|
quiz: this.data.quiz,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
export default class YouTubeVideo {
|
|
||||||
constructor({ data }) {
|
|
||||||
this.data = data
|
|
||||||
}
|
|
||||||
|
|
||||||
static get toolbox() {
|
|
||||||
return {
|
|
||||||
title: 'YouTube Video',
|
|
||||||
icon: `<img src="/assets/lms/icons/video.svg" width="15" height="15">`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
this.wrapper = document.createElement('div')
|
|
||||||
if (this.data && this.data.youtube) {
|
|
||||||
$(this.wrapper).html(this.render_youtube(this.data.youtube))
|
|
||||||
} else {
|
|
||||||
this.render_youtube_dialog()
|
|
||||||
}
|
|
||||||
return this.wrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
render_youtube_dialog() {
|
|
||||||
let me = this
|
|
||||||
let youtubedialog = new frappe.ui.Dialog({
|
|
||||||
title: __('YouTube Video'),
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
fieldname: 'youtube',
|
|
||||||
fieldtype: 'Data',
|
|
||||||
label: __('YouTube Video ID'),
|
|
||||||
reqd: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldname: 'instructions_section_break',
|
|
||||||
fieldtype: 'Section Break',
|
|
||||||
label: __('Instructions:'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldname: 'instructions',
|
|
||||||
fieldtype: 'HTML',
|
|
||||||
label: __('Instructions'),
|
|
||||||
options: __(
|
|
||||||
'Enter the YouTube Video ID. The ID is the part of the URL after <code>watch?v=</code>. For example, if the URL is <code>https://www.youtube.com/watch?v=QH2-TGUlwu4</code>, the ID is <code>QH2-TGUlwu4</code>'
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
primary_action_label: __('Insert'),
|
|
||||||
primary_action(values) {
|
|
||||||
youtubedialog.hide()
|
|
||||||
me.youtube = values.youtube
|
|
||||||
$(me.wrapper).html(me.render_youtube(values.youtube))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
youtubedialog.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
render_youtube(youtube) {
|
|
||||||
return `<iframe width="100%" height="400"
|
|
||||||
src="https://www.youtube.com/embed/${youtube}"
|
|
||||||
title="YouTube video player"
|
|
||||||
frameborder="0"
|
|
||||||
style="border-radius: var(--border-radius-lg); margin: 1rem 0;"
|
|
||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
||||||
allowfullscreen>
|
|
||||||
</iframe>`
|
|
||||||
}
|
|
||||||
|
|
||||||
validate(savedData) {
|
|
||||||
return !savedData.youtube || !savedData.youtube.trim() ? false : true
|
|
||||||
}
|
|
||||||
|
|
||||||
save(block_content) {
|
|
||||||
return {
|
|
||||||
youtube: this.data.youtube || this.youtube,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ class LMSBatch(Document):
|
|||||||
|
|
||||||
def send_confirmation_mail(self):
|
def send_confirmation_mail(self):
|
||||||
for student in self.students:
|
for student in self.students:
|
||||||
if not student.confirmation_email_sent:
|
outgoing_email_account = frappe.get_cached_value(
|
||||||
|
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
|
||||||
|
)
|
||||||
|
if not student.confirmation_email_sent and outgoing_email_account:
|
||||||
self.send_mail(student)
|
self.send_mail(student)
|
||||||
student.confirmation_email_sent = 1
|
student.confirmation_email_sent = 1
|
||||||
|
|
||||||
|
|||||||
@@ -1758,12 +1758,17 @@ def get_lesson_creation_details(course, chapter, lesson):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if lesson_name:
|
if lesson_name:
|
||||||
lesson_details = frappe.db.get_value("Course Lesson", lesson_name, [""])
|
lesson_details = frappe.db.get_value(
|
||||||
|
"Course Lesson",
|
||||||
|
lesson_name,
|
||||||
|
["name", "title", "include_in_preview", "body", "content", "instructor_notes"],
|
||||||
|
as_dict=1,
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"course_title": frappe.db.get_value("LMS Course", course, "title"),
|
"course_title": frappe.db.get_value("LMS Course", course, "title"),
|
||||||
"chapter": frappe.db.get_value(
|
"chapter": frappe.db.get_value(
|
||||||
"Course Chapter", chapter_name, ["title", "name"], as_dict=True
|
"Course Chapter", chapter_name, ["title", "name"], as_dict=True
|
||||||
),
|
),
|
||||||
"lesson": lesson_name if lesson_name else None,
|
"lesson": lesson_details if lesson_name else None,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user