feat: quiz creation from lesson form
This commit is contained in:
@@ -91,7 +91,7 @@
|
|||||||
<div>
|
<div>
|
||||||
{{ option.label }}
|
{{ option.label }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-if="option.label != option.description"
|
||||||
class="text-xs text-gray-700"
|
class="text-xs text-gray-700"
|
||||||
v-html="option.description"
|
v-html="option.description"
|
||||||
></div>
|
></div>
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ 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(valuePropPassed.value)
|
||||||
return (
|
return (
|
||||||
val?.value &&
|
val?.value &&
|
||||||
emit(valuePropPassed.value ? 'change' : 'update:modelValue', val?.value)
|
emit(valuePropPassed.value ? 'change' : 'update:modelValue', val?.value)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="text-lg font-semibold">
|
<div class="text-lg font-semibold">
|
||||||
{{ __('Components') }}
|
{{ __('Components') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="mt-5 space-y-4">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
:text="
|
:text="
|
||||||
__(
|
__(
|
||||||
@@ -18,20 +18,28 @@
|
|||||||
<Select v-model="currentEditor" :options="getEditorOptions()" />
|
<Select v-model="currentEditor" :options="getEditorOptions()" />
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div class="flex mt-4">
|
<div class="flex">
|
||||||
<Link
|
<Link
|
||||||
v-model="quiz"
|
:value="quiz"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
doctype="LMS Quiz"
|
doctype="LMS Quiz"
|
||||||
:label="__('Select a Quiz')"
|
:label="__('Add an existing quiz')"
|
||||||
|
@change="(option) => addQuiz(option)"
|
||||||
/>
|
/>
|
||||||
<Button @click="addQuiz()" class="self-end ml-2">
|
<router-link :to="{
|
||||||
|
name: 'QuizCreation',
|
||||||
|
params: {
|
||||||
|
quizID: 'new',
|
||||||
|
}
|
||||||
|
}" class="self-end ml-2">
|
||||||
|
<Button>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<Plus class="h-4 w-4 stroke-1.5" />
|
<Plus class="h-4 w-4 stroke-1.5" />
|
||||||
</template>
|
</template>
|
||||||
</Button>
|
</Button>
|
||||||
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4">
|
<div class="">
|
||||||
<div class="text-xs text-gray-600 mb-1">
|
<div class="text-xs text-gray-600 mb-1">
|
||||||
{{ __('Add an image, video, pdf or audio.') }}
|
{{ __('Add an image, video, pdf or audio.') }}
|
||||||
</div>
|
</div>
|
||||||
@@ -68,7 +76,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4">
|
<div class="">
|
||||||
<div class="text-xs text-gray-600 mb-1">
|
<div class="text-xs text-gray-600 mb-1">
|
||||||
{{
|
{{
|
||||||
__(
|
__(
|
||||||
@@ -112,11 +120,13 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const addQuiz = () => {
|
const addQuiz = (value) => {
|
||||||
|
console.log("here")
|
||||||
|
console.log(value)
|
||||||
getCurrentEditor().caret.setToLastBlock('end', 0)
|
getCurrentEditor().caret.setToLastBlock('end', 0)
|
||||||
if (quiz.value) {
|
if (value) {
|
||||||
getCurrentEditor().blocks.insert('quiz', {
|
getCurrentEditor().blocks.insert('quiz', {
|
||||||
quiz: quiz.value,
|
quiz: value,
|
||||||
})
|
})
|
||||||
quiz.value = null
|
quiz.value = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Breadcrumbs, FormControl, createResource, Button } from 'frappe-ui'
|
import { Breadcrumbs, FormControl, createResource, Button } from 'frappe-ui'
|
||||||
import { computed, reactive, onMounted, inject, ref, watch } from 'vue'
|
import { computed, reactive, onMounted, inject, ref, onBeforeUnmount } from 'vue'
|
||||||
import EditorJS from '@editorjs/editorjs'
|
import EditorJS from '@editorjs/editorjs'
|
||||||
import LessonPlugins from '@/components/LessonPlugins.vue'
|
import LessonPlugins from '@/components/LessonPlugins.vue'
|
||||||
import { ChevronRight } from 'lucide-vue-next'
|
import { ChevronRight } from 'lucide-vue-next'
|
||||||
@@ -171,9 +171,13 @@ const addInstructorNotes = (data) => {
|
|||||||
const enableAutoSave = () => {
|
const enableAutoSave = () => {
|
||||||
autoSaveInterval = setInterval(() => {
|
autoSaveInterval = setInterval(() => {
|
||||||
saveLesson()
|
saveLesson()
|
||||||
}, 10000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clearInterval(autoSaveInterval)
|
||||||
|
})
|
||||||
|
|
||||||
const newLessonResource = createResource({
|
const newLessonResource = createResource({
|
||||||
url: 'frappe.client.insert',
|
url: 'frappe.client.insert',
|
||||||
makeParams(values) {
|
makeParams(values) {
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ export function getEditorTools() {
|
|||||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
||||||
embedUrl:
|
embedUrl:
|
||||||
'https://docs.google.com/presentation/d/e/<%= remote_id %>/embed',
|
'https://docs.google.com/presentation/d/e/<%= remote_id %>/embed',
|
||||||
html: "<iframe style='width: 100%; height: 30rem; border: 1px solid #D3D3D3; border-radius: 12px;' frameborder='0' allowfullscreen='true'></iframe>",
|
html: "<iframe style='width: 100%; height: 30rem; border: 1px solid #D3D3D3; border-radius: 12px; margin: 1rem 0' frameborder='0' allowfullscreen='true'></iframe>",
|
||||||
},
|
},
|
||||||
drive: {
|
drive: {
|
||||||
regex: /https:\/\/drive\.google\.com\/file\/d\/([A-Za-z0-9_-]+)\/view(\?.+)?/,
|
regex: /https:\/\/drive\.google\.com\/file\/d\/([A-Za-z0-9_-]+)\/view(\?.+)?/,
|
||||||
@@ -260,7 +260,7 @@ export function getEditorTools() {
|
|||||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/([A-Za-z0-9_-]+)\/edit(\?.+)?/,
|
regex: /https:\/\/docs\.google\.com\/presentation\/d\/([A-Za-z0-9_-]+)\/edit(\?.+)?/,
|
||||||
embedUrl:
|
embedUrl:
|
||||||
'https://docs.google.com/presentation/d/<%= remote_id %>/embed',
|
'https://docs.google.com/presentation/d/<%= remote_id %>/embed',
|
||||||
html: "<iframe style='width: 100%; height: 30rem; border: 1px solid #D3D3D3; border-radius: 12px;' frameborder='0' allowfullscreen='true'></iframe>",
|
html: "<iframe style='width: 100%; height: 30rem; border: 1px solid #D3D3D3; border-radius: 12px; margin: 1rem 0;' frameborder='0' allowfullscreen='true'></iframe>",
|
||||||
},
|
},
|
||||||
codesandbox: {
|
codesandbox: {
|
||||||
regex: /^https:\/\/codesandbox\.io\/(?:embed\/)?([A-Za-z0-9_-]+)(?:\?[^\/]*)?$/,
|
regex: /^https:\/\/codesandbox\.io\/(?:embed\/)?([A-Za-z0-9_-]+)(?:\?[^\/]*)?$/,
|
||||||
|
|||||||
Reference in New Issue
Block a user