Compare commits

..

43 Commits

Author SHA1 Message Date
Frappe PR Bot
a744a43d14 chore(release): Bumped to Version 2.1.0 2024-08-12 12:32:42 +00:00
Jannat Patel
5abdbfec1f Merge pull request #962 from pateljannat/posthog
chore: product analytics
2024-08-12 18:01:45 +05:30
Jannat Patel
0335b3b4d0 chore: fixed linters 2024-08-12 17:38:59 +05:30
Jannat Patel
703fafd6c3 chore: analytics 2024-08-12 17:13:31 +05:30
Jannat Patel
b956c4e383 Merge branch 'develop' of https://github.com/frappe/lms into posthog 2024-08-12 14:17:04 +05:30
Jannat Patel
d0d1fb2c8c Merge pull request #944 from pateljannat/quiz-creation
Quiz creation
2024-08-12 14:13:23 +05:30
Jannat Patel
d18a6f6e73 chore: removed workspaces from package.json 2024-08-12 13:13:21 +05:30
Jannat Patel
2994144718 feat: quiz creation from lesson form 2024-08-12 12:47:17 +05:30
Jannat Patel
62ab853605 feat: quiz creation from lesson form 2024-08-12 12:46:38 +05:30
Jannat Patel
7f7986d77a chore: fixed linters 2024-08-12 10:04:42 +05:30
Jannat Patel
61f01cc51b chore: resolved conflicts 2024-08-12 10:02:22 +05:30
Jannat Patel
86af8c6301 Merge pull request #960 from mohsinalimat/patch-1
fix: lms setting to lms settings
2024-08-09 22:21:35 +05:30
Jannat Patel
f1b0fcfbfc Merge pull request #961 from frappe/pot_develop_2024-08-09
chore: update POT file
2024-08-09 21:50:21 +05:30
frappe-pr-bot
ab5ce39645 chore: update POT file 2024-08-09 16:04:06 +00:00
Jannat Patel
685e09ce4b feat: question update 2024-08-09 20:38:14 +05:30
MohsinAli
8ed4f775e5 fix: lms setting to lms settings 2024-08-09 13:58:50 +05:30
Jannat Patel
a3a3085b1f fix: update question title in quiz 2024-08-08 22:16:21 +05:30
Jannat Patel
ed97640107 feat: allow updating questions 2024-08-07 18:15:50 +05:30
Jannat Patel
a9e93a679b feat: posthog initialization 2024-08-07 11:31:58 +05:30
Jannat Patel
418c36c09f Merge pull request #957 from frappe/pot_develop_2024-08-06
chore: update POT file
2024-08-06 12:17:49 +05:30
frappe-pr-bot
935f7f1f7b chore: update POT file 2024-08-06 06:32:08 +00:00
Jannat Patel
9a0056b6ca Merge branch 'develop' of https://github.com/frappe/lms into develop 2024-08-06 11:50:23 +05:30
Jannat Patel
cd56da5d85 fix: changed upstream command for pot file generation 2024-08-06 11:47:37 +05:30
Jannat Patel
97d5d853fc Merge pull request #955 from pateljannat/issues-30
fix: lesson auto save
2024-08-06 11:11:50 +05:30
Jannat Patel
8adfe247b2 fix: lesson auto save 2024-08-05 18:14:35 +05:30
Jannat Patel
afe7df2989 fix: fetch question 2024-08-05 16:29:43 +05:30
Jannat Patel
eed330662b Merge pull request #953 from pateljannat/issues-29
fix: course cards home page rendering
2024-08-05 14:20:36 +05:30
Jannat Patel
26db10bbe0 fix: course cards home page rendering 2024-08-05 14:04:08 +05:30
Jannat Patel
14230bd588 Merge pull request #951 from pateljannat/issues-28
fix: spacing and widths
2024-08-05 11:32:12 +05:30
Jannat Patel
699c821edd fix: spacing and widths 2024-08-05 11:12:34 +05:30
Jannat Patel
27ca13ece6 feat: add questions to quiz 2024-08-02 20:20:43 +05:30
Jannat Patel
6820dfc820 fix: make question attachments public 2024-08-01 13:02:20 +05:30
Jannat Patel
e0855a2c1b fix: quiz question population issue 2024-07-31 22:30:29 +05:30
Jannat Patel
6a0b37a4d4 chore: changed release branch to develop 2024-07-31 12:43:04 +05:30
Jannat Patel
f7fd6916e2 chore: release notes action 2024-07-31 12:15:24 +05:30
Jannat Patel
30e61f4b7c Merge pull request #947 from pateljannat/semantic-release
chore: semantic release action
2024-07-31 11:45:42 +05:30
Jannat Patel
48b37d58d8 chore: semantic release action 2024-07-31 11:10:47 +05:30
Jannat Patel
e96f18df7c Merge pull request #946 from pateljannat/issues-27
fix: quiz shuffle issue
2024-07-30 18:04:26 +05:30
Jannat Patel
7d15527831 fix: quiz shuffle issue 2024-07-30 16:58:09 +05:30
Jannat Patel
794c0e760b Merge pull request #945 from pateljannat/issues-26
fix: eval request issues
2024-07-30 15:26:46 +05:30
Jannat Patel
e46a60d00a chore: linters 2024-07-30 15:05:24 +05:30
Jannat Patel
819aac70fd fix: linters 2024-07-30 14:54:21 +05:30
Jannat Patel
ed7db2d7c5 fix: eval request issues 2024-07-30 14:17:17 +05:30
48 changed files with 2527 additions and 3603 deletions

View File

@@ -22,7 +22,7 @@ git config user.name "frappe-pr-bot"
echo "Setting the correct git remote..." echo "Setting the correct git remote..."
# Here, the git remote is a local file path by default. Let's change it to the upstream repo. # Here, the git remote is a local file path by default. Let's change it to the upstream repo.
git remote add upstream https://github.com/frappe/lms.git git remote set-url upstream https://github.com/frappe/lms.git
echo "Creating a new branch..." echo "Creating a new branch..."
isodate=$(date -u +"%Y-%m-%d") isodate=$(date -u +"%Y-%m-%d")

View File

@@ -5,7 +5,7 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
regeneratee-pot-file: regenerate-pot-file:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:

32
.github/workflows/on_release.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Generate Semantic Release
on:
workflow_dispatch:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Entire Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup dependencies
run: |
npm install @semantic-release/git @semantic-release/exec --no-save
- name: Create Release
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GIT_AUTHOR_NAME: "Frappe PR Bot"
GIT_AUTHOR_EMAIL: "developers@frappe.io"
GIT_COMMITTER_NAME: "Frappe PR Bot"
GIT_COMMITTER_EMAIL: "developers@frappe.io"
run: npx semantic-release

39
.github/workflows/release_notes.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
# This action:
#
# 1. Generates release notes using github API.
# 2. Strips unnecessary info like chore/style etc from notes.
# 3. Updates release info.
name: 'Release Notes'
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag of release like v2.0.0'
required: true
type: string
release:
types: [released]
permissions:
contents: read
jobs:
regen-notes:
name: 'Regenerate release notes'
runs-on: ubuntu-latest
steps:
- name: Update notes
run: |
NEW_NOTES=$(gh api --method POST -H "Accept: application/vnd.github+json" /repos/frappe/lms/releases/generate-notes -f tag_name=$RELEASE_TAG \
| jq -r '.body' \
| sed -E '/^\* (chore|ci|test|docs|style)/d' \
| sed -E 's/by @mergify //'
)
RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/frappe/lms/releases/tags/$RELEASE_TAG | jq -r '.id')
gh api --method PATCH -H "Accept: application/vnd.github+json" /repos/frappe/lms/releases/$RELEASE_ID -f body="$NEW_NOTES"
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.event.release.tag_name }}

3
.gitignore vendored
View File

@@ -11,5 +11,4 @@ __pycache__/
node_modules node_modules
package-lock.json package-lock.json
lms/public/frontend lms/public/frontend
lms/www/lms.html lms/www/lms.html
frappe-ui

21
.releaserc Normal file
View File

@@ -0,0 +1,21 @@
{
"branches": ["develop"],
"plugins": [
"@semantic-release/commit-analyzer", {
"preset": "angular"
},
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec", {
"prepareCmd": 'sed -ir "s/[0-9]*\.[0-9]*\.[0-9]*/${nextRelease.version}/" lms/__init__.py'
}
],
[
"@semantic-release/git", {
"assets": ["lms/__init__.py"],
"message": "chore(release): Bumped to Version ${nextRelease.version}"
}
],
"@semantic-release/github"
]
}

Submodule frappe-ui deleted from a349ab070a

View File

@@ -8,10 +8,12 @@
<script setup> <script setup>
import { Toasts } from 'frappe-ui' import { Toasts } from 'frappe-ui'
import { Dialogs } from '@/utils/dialogs' import { Dialogs } from '@/utils/dialogs'
import { computed, defineAsyncComponent } from 'vue' import { computed, onMounted, onUnmounted } from 'vue'
import { useScreenSize } from './utils/composables' import { useScreenSize } from './utils/composables'
import DesktopLayout from './components/DesktopLayout.vue' import DesktopLayout from './components/DesktopLayout.vue'
import MobileLayout from './components/MobileLayout.vue' import MobileLayout from './components/MobileLayout.vue'
import { stopSession } from '@/telemetry'
import { init as initTelemetry } from '@/telemetry'
const screenSize = useScreenSize() const screenSize = useScreenSize()
@@ -22,4 +24,12 @@ const Layout = computed(() => {
return DesktopLayout return DesktopLayout
} }
}) })
onMounted(async () => {
await initTelemetry()
})
onUnmounted(() => {
stopSession()
})
</script> </script>

View File

@@ -100,7 +100,7 @@ import { ChevronRight, Plus } from 'lucide-vue-next'
import { createResource, Button } from 'frappe-ui' import { createResource, Button } from 'frappe-ui'
import PageModal from '@/components/Modals/PageModal.vue' import PageModal from '@/components/Modals/PageModal.vue'
const { user } = sessionStore() const { user, sidebarSettings } = sessionStore()
const { userResource } = usersStore() const { userResource } = usersStore()
const socket = inject('$socket') const socket = inject('$socket')
const unreadCount = ref(0) const unreadCount = ref(0)
@@ -115,6 +115,20 @@ onMounted(() => {
unreadNotifications.reload() unreadNotifications.reload()
}) })
addNotifications() addNotifications()
sidebarSettings.reload(
{},
{
onSuccess(data) {
Object.keys(data).forEach((key) => {
if (!parseInt(data[key])) {
sidebarLinks.value = sidebarLinks.value.filter(
(link) => link.label.toLowerCase().split(' ').join('_') !== key
)
}
})
},
}
)
}) })
const unreadNotifications = createResource({ const unreadNotifications = createResource({
@@ -153,21 +167,6 @@ const addNotifications = () => {
} }
} }
const sidebarSettings = createResource({
url: 'lms.lms.api.get_sidebar_settings',
cache: 'Sidebar Settings',
auto: true,
onSuccess(data) {
Object.keys(data).forEach((key) => {
if (!parseInt(data[key])) {
sidebarLinks.value = sidebarLinks.value.filter(
(link) => link.label.toLowerCase().split(' ').join('_') !== key
)
}
})
},
})
const openPageModal = (link) => { const openPageModal = (link) => {
showPageModal.value = true showPageModal.value = true
pageToEdit.value = link pageToEdit.value = link

View File

@@ -3,7 +3,7 @@
class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full" class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full"
style="min-height: 150px" style="min-height: 150px"
> >
<div class="text-xl font-semibold mb-2"> <div class="text-lg leading-5 font-semibold mb-2">
{{ batch.title }} {{ batch.title }}
</div> </div>
<Badge <Badge
@@ -22,18 +22,17 @@
> >
{{ __('Sold Out') }} {{ __('Sold Out') }}
</Badge> </Badge>
<div class="short-introduction"> <div class="short-introduction text-sm text-gray-700">
{{ batch.description }} {{ batch.description }}
</div> </div>
<div v-if="batch.amount" class="font-semibold mb-4">
{{ batch.price }}
</div>
<div class="flex flex-col space-y-2 mt-auto"> <div class="flex flex-col space-y-2 mt-auto">
<div v-if="batch.amount" class="font-semibold text-lg">
{{ batch.price }}
</div>
<DateRange <DateRange
:startDate="batch.start_date" :startDate="batch.start_date"
:endDate="batch.end_date" :endDate="batch.end_date"
class="text-sm text-gray-700 mb-3" class="text-sm text-gray-700"
/> />
<div class="flex items-center text-sm text-gray-700"> <div class="flex items-center text-sm text-gray-700">
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" /> <Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
@@ -50,18 +49,21 @@
{{ batch.timezone }} {{ batch.timezone }}
</span> </span>
</div> </div>
<div v-if="batch.instructors?.length" class="flex avatar-group overlap"> </div>
<div <div
class="h-6 mr-1" v-if="batch.instructors?.length"
:class="{ 'avatar-group overlap': batch.instructors.length > 1 }" class="flex avatar-group overlap mt-4"
> >
<UserAvatar <div
v-for="instructor in batch.instructors" class="h-6 mr-1"
:user="instructor" :class="{ 'avatar-group overlap': batch.instructors.length > 1 }"
/> >
</div> <UserAvatar
<CourseInstructors :instructors="batch.instructors" /> v-for="instructor in batch.instructors"
:user="instructor"
/>
</div> </div>
<CourseInstructors :instructors="batch.instructors" />
</div> </div>
</div> </div>
</template> </template>
@@ -88,7 +90,7 @@ const props = defineProps({
text-overflow: ellipsis; text-overflow: ellipsis;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
margin: 0.25rem 0 1.25rem; margin: 0.25rem 0 1rem;
line-height: 1.5; line-height: 1.5;
} }

View File

@@ -81,7 +81,7 @@
<router-link <router-link
v-if="isModerator" v-if="isModerator"
:to="{ :to="{
name: 'BatchCreation', name: 'BatchForm',
params: { params: {
batchName: batch.data.name, batchName: batch.data.name,
}, },

View File

@@ -75,7 +75,7 @@
> >
<li <li
:class="[ :class="[
'flex items-center rounded px-2.5 py-1.5 text-base', 'flex items-center rounded px-2.5 py-2 text-base',
{ 'bg-gray-100': active }, { 'bg-gray-100': active },
]" ]"
> >
@@ -87,7 +87,16 @@
name="item-label" name="item-label"
v-bind="{ active, selected, option }" v-bind="{ active, selected, option }"
> >
{{ option.label }} <div class="flex flex-col space-y-1">
<div>
{{ option.label }}
</div>
<div
v-if="option.label != option.description"
class="text-xs text-gray-700"
v-html="option.description"
></div>
</div>
</slot> </slot>
</li> </li>
</ComboboxOption> </ComboboxOption>

View File

@@ -118,6 +118,7 @@ const options = createResource({
return { return {
label: option.value, label: option.value,
value: option.value, value: option.value,
description: option.description,
} }
}) })
}, },

View File

@@ -72,7 +72,7 @@
{{ course.title }} {{ course.title }}
</div> </div>
<div class="short-introduction"> <div class="short-introduction text-gray-700 text-sm">
{{ course.short_introduction }} {{ course.short_introduction }}
</div> </div>

View File

@@ -75,7 +75,7 @@
<router-link <router-link
v-if="user?.data?.is_moderator || is_instructor()" v-if="user?.data?.is_moderator || is_instructor()"
:to="{ :to="{
name: 'CreateCourse', name: 'CourseForm',
params: { params: {
courseName: course.data.name, courseName: course.data.name,
}, },

View File

@@ -50,7 +50,7 @@
<div class="outline-lesson pl-8 py-2 pr-4"> <div class="outline-lesson pl-8 py-2 pr-4">
<router-link <router-link
:to="{ :to="{
name: allowEdit ? 'CreateLesson' : 'Lesson', name: allowEdit ? 'LessonForm' : 'Lesson',
params: { params: {
courseName: courseName, courseName: courseName,
chapterNumber: lesson.number.split('.')[0], chapterNumber: lesson.number.split('.')[0],
@@ -89,7 +89,7 @@
<div v-if="allowEdit" class="flex mt-2 mb-4 pl-8"> <div v-if="allowEdit" class="flex mt-2 mb-4 pl-8">
<router-link <router-link
:to="{ :to="{
name: 'CreateLesson', name: 'LessonForm',
params: { params: {
courseName: courseName, courseName: courseName,
chapterNumber: chapter.idx, chapterNumber: chapter.idx,

View File

@@ -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,31 @@
<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
<template #icon> :to="{
<Plus class="h-4 w-4 stroke-1.5" /> name: 'QuizCreation',
</template> params: {
</Button> quizID: 'new',
},
}"
class="self-end ml-2"
>
<Button>
<template #icon>
<Plus class="h-4 w-4 stroke-1.5" />
</template>
</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 +79,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 +123,11 @@ const props = defineProps({
}, },
}) })
const addQuiz = () => { const addQuiz = (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
} }

View File

@@ -4,14 +4,14 @@
<slot /> <slot />
</div> </div>
<div <div
v-if="tabs" v-if="sidebarSettings.data"
class="fixed flex justify-around border-t border-gray-300 bottom-0 z-10 w-full bg-white standalone:pb-4" class="fixed flex justify-around border-t border-gray-300 bottom-0 z-10 w-full bg-white standalone:pb-4"
:style="{ :style="{
gridTemplateColumns: `repeat(${tabs.length}, minmax(0, 1fr))`, gridTemplateColumns: `repeat(${sidebarLinks.length}, minmax(0, 1fr))`,
}" }"
> >
<button <button
v-for="tab in tabs" v-for="tab in sidebarLinks"
:key="tab.label" :key="tab.label"
:class="isVisible(tab) ? 'block' : 'hidden'" :class="isVisible(tab) ? 'block' : 'hidden'"
class="flex flex-col items-center justify-center py-3 transition active:scale-95" class="flex flex-col items-center justify-center py-3 transition active:scale-95"
@@ -29,21 +29,38 @@
<script setup> <script setup>
import { getSidebarLinks } from '../utils' import { getSidebarLinks } from '../utils'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { computed } from 'vue' import { computed, ref, onMounted } from 'vue'
import { sessionStore } from '@/stores/session' import { sessionStore } from '@/stores/session'
import { usersStore } from '@/stores/user' import { usersStore } from '@/stores/user'
import * as icons from 'lucide-vue-next' import * as icons from 'lucide-vue-next'
const { logout, user } = sessionStore() const { logout, user, sidebarSettings } = sessionStore()
let { isLoggedIn } = sessionStore() let { isLoggedIn } = sessionStore()
const router = useRouter() const router = useRouter()
let { userResource } = usersStore() let { userResource } = usersStore()
const sidebarLinks = ref(getSidebarLinks())
const tabs = computed(() => { onMounted(() => {
let links = getSidebarLinks() sidebarSettings.reload(
{},
{
onSuccess(data) {
Object.keys(data).forEach((key) => {
if (!parseInt(data[key])) {
sidebarLinks.value = sidebarLinks.value.filter(
(link) => link.label.toLowerCase().split(' ').join('_') !== key
)
}
})
addAccessLinks()
},
}
)
})
const addAccessLinks = () => {
if (user) { if (user) {
links.push({ sidebarLinks.value.push({
label: 'Profile', label: 'Profile',
icon: 'UserRound', icon: 'UserRound',
activeFor: [ activeFor: [
@@ -54,18 +71,17 @@ const tabs = computed(() => {
'ProfileRoles', 'ProfileRoles',
], ],
}) })
links.push({ sidebarLinks.value.push({
label: 'Log out', label: 'Log out',
icon: 'LogOut', icon: 'LogOut',
}) })
} else { } else {
links.push({ sidebarLinks.value.push({
label: 'Log in', label: 'Log in',
icon: 'LogIn', icon: 'LogIn',
}) })
} }
return links }
})
let isActive = (tab) => { let isActive = (tab) => {
return tab.activeFor?.includes(router.currentRoute.value.name) return tab.activeFor?.includes(router.currentRoute.value.name)

View File

@@ -21,8 +21,9 @@
</template> </template>
<script setup> <script setup>
import { Dialog, FormControl, createResource } from 'frappe-ui' import { Dialog, FormControl, createResource } from 'frappe-ui'
import { defineModel, reactive, watch, inject } from 'vue' import { defineModel, reactive, watch } from 'vue'
import { createToast, formatTime } from '@/utils/' import { createToast } from '@/utils/'
import { capture } from '@/telemetry'
const show = defineModel() const show = defineModel()
const outline = defineModel('outline') const outline = defineModel('outline')
@@ -91,6 +92,7 @@ const addChapter = (close) => {
} }
}, },
onSuccess: (data) => { onSuccess: (data) => {
capture('chapter_created')
chapterReference.submit( chapterReference.submit(
{ name: data.name }, { name: data.name },
{ {

View File

@@ -2,46 +2,95 @@
<Dialog v-model="show" :options="dialogOptions"> <Dialog v-model="show" :options="dialogOptions">
<template #body-content> <template #body-content>
<div class="space-y-4"> <div class="space-y-4">
<div> <div
<label class="block text-xs text-gray-600 mb-1"> v-if="!editMode"
{{ __('Question') }} class="flex items-center text-xs text-gray-700 space-x-5"
</label> >
<TextEditor <div class="flex items-center space-x-2">
:content="question.question" <input
@change="(val) => (question.question = val)" type="radio"
:editable="true" id="existing"
:fixedMenu="true" value="existing"
editorClass="prose-sm max-w-none border-b border-x bg-gray-100 rounded-b-md py-1 px-2 min-h-[7rem]" v-model="questionType"
/> class="w-3 h-3 accent-gray-900"
/>
<label for="existing">
{{ __('Add an existing question') }}
</label>
</div>
<div class="flex items-center space-x-2">
<input
type="radio"
id="new"
value="new"
v-model="questionType"
class="w-3 h-3"
/>
<label for="new">
{{ __('Create a new question') }}
</label>
</div>
</div> </div>
<FormControl <div v-if="questionType == 'new' || editMode" class="space-y-2">
:label="__('Type')" <div>
v-model="question.type" <label class="block text-xs text-gray-600 mb-1">
type="select" {{ __('Question') }}
:options="['Choices', 'User Input']" </label>
class="pb-2" <TextEditor
/> :content="question.question"
<div v-if="question.type == 'Choices'" class="divide-y"> @change="(val) => (question.question = val)"
<div v-for="n in 4" class="space-y-4 py-2"> :editable="true"
<FormControl :fixedMenu="true"
:label="__('Option') + ' ' + n" editorClass="prose-sm max-w-none border-b border-x bg-gray-100 rounded-b-md py-1 px-2 min-h-[7rem]"
v-model="question[`option_${n}`]"
/> />
</div>
<FormControl
v-model="question.marks"
:label="__('Marks')"
type="number"
/>
<FormControl
:label="__('Type')"
v-model="question.type"
type="select"
:options="['Choices', 'User Input']"
class="pb-2"
/>
<div v-if="question.type == 'Choices'" class="divide-y border-t">
<div v-for="n in 4" class="space-y-4 py-2">
<FormControl
:label="__('Option') + ' ' + n"
v-model="question[`option_${n}`]"
/>
<FormControl
:label="__('Explanation')"
v-model="question[`explanation_${n}`]"
/>
<FormControl
:label="__('Correct Answer')"
v-model="question[`is_correct_${n}`]"
type="checkbox"
/>
</div>
</div>
<div v-else v-for="n in 4" class="space-y-2">
<FormControl <FormControl
:label="__('Explanation')" :label="__('Possibility') + ' ' + n"
v-model="question[`explanation_${n}`]" v-model="question[`possibility_${n}`]"
/>
<FormControl
:label="__('Correct Answer')"
v-model="question[`correct_answer_${n}`]"
type="checkbox"
/> />
</div> </div>
</div> </div>
<div v-else v-for="n in 4" class="space-y-2"> <div v-else-if="questionType == 'existing'" class="space-y-2">
<Link
v-model="existingQuestion.question"
:label="__('Select a question')"
doctype="LMS Question"
/>
<FormControl <FormControl
:label="__('Possibility') + ' ' + n" v-model="existingQuestion.marks"
v-model="question[`possibility_${n}`]" :label="__('Marks')"
type="number"
/> />
</div> </div>
</div> </div>
@@ -50,83 +99,228 @@
</template> </template>
<script setup> <script setup>
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui' import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
import { computed, onMounted, reactive, inject } from 'vue' import { computed, watch, reactive, ref } from 'vue'
import Link from '@/components/Controls/Link.vue'
import { showToast } from '@/utils'
const show = defineModel() const show = defineModel()
const user = inject('$user') const quiz = defineModel('quiz')
const questionType = ref(null)
const editMode = ref(false)
const existingQuestion = reactive({
question: '',
marks: 0,
})
const question = reactive({ const question = reactive({
question: '', question: '',
type: 'Choices', type: 'Choices',
}) marks: 0,
onMounted(() => {
populateFields()
console.log(props.questionName)
if (
props.questionName == 'new' &&
!user.data?.is_moderator &&
!user.data?.is_instructor
) {
router.push({ name: 'Courses' })
}
if (props.courseName !== 'new') {
questionDoc.reload()
}
window.addEventListener('keydown', keyboardShortcut)
})
const props = defineProps({
title: {
type: String,
default: __('Add a Question'),
},
questionName: {
type: String,
},
})
const questionDoc = createResource({
url: 'frappe.client.get',
makeParams: (values) => {
return {
doctype: 'LMS Question',
name: props.questionName,
}
},
onSuccess(data) {
let counter = 1
Object.keys(data).forEach((key) => {
if (Object.hasOwn(question, key)) question[key] = data[key]
})
while (counter <= 4) {
question[`is_correct_${counter}`] = question[`is_correct_${counter}`]
? true
: false
}
},
}) })
const populateFields = () => { const populateFields = () => {
let fields = ['option', 'correct_answer', 'explanation', 'possibility'] let fields = ['option', 'is_correct', 'explanation', 'possibility']
let counter = 1 let counter = 1
fields.forEach((field) => { fields.forEach((field) => {
while (counter <= 4) { while (counter <= 4) {
question[`${field}_${counter}`] = field === 'correct_answer' ? false : '' question[`${field}_${counter}`] = field === 'is_correct' ? false : ''
counter++ counter++
} }
}) })
} }
const keyboardShortcut = (e) => { populateFields()
if (
e.key === 's' && const props = defineProps({
(e.ctrlKey || e.metaKey) && title: {
!e.target.classList.contains('ProseMirror') type: String,
) { default: __('Add a new question'),
submitQuestion() },
e.preventDefault() questionDetail: {
type: [Object, null],
required: true,
},
})
const questionData = createResource({
url: 'frappe.client.get',
makeParams() {
return {
doctype: 'LMS Question',
name: props.questionDetail.question,
}
},
auto: false,
onSuccess(data) {
let counter = 1
editMode.value = true
Object.keys(data).forEach((key) => {
if (Object.hasOwn(question, key)) question[key] = data[key]
})
while (counter <= 4) {
question[`is_correct_${counter}`] = data[`is_correct_${counter}`]
? true
: false
counter++
}
question.marks = props.questionDetail.marks
},
})
watch(show, () => {
if (show.value) {
editMode.value = false
if (props.questionDetail.question) questionData.fetch()
else {
;(question.question = ''), (question.marks = 0)
question.type = 'Choices'
existingQuestion.question = ''
existingQuestion.marks = 0
questionType.value = null
populateFields()
}
if (props.questionDetail.marks) question.marks = props.questionDetail.marks
} }
})
const questionRow = createResource({
url: 'frappe.client.insert',
makeParams(values) {
return {
doc: {
doctype: 'LMS Quiz Question',
parent: quiz.value.data.name,
parentfield: 'questions',
parenttype: 'LMS Quiz',
...values,
},
}
},
})
const questionCreation = createResource({
url: 'frappe.client.insert',
makeParams(values) {
return {
doc: {
doctype: 'LMS Question',
...question,
},
}
},
})
const submitQuestion = (close) => {
if (questionData.data?.name) updateQuestion(close)
else addQuestion(close)
}
const addQuestion = (close) => {
if (questionType.value == 'existing') {
addQuestionRow(
{
question: existingQuestion.question,
marks: existingQuestion.marks,
},
close
)
} else {
questionCreation.submit(
{},
{
onSuccess(data) {
addQuestionRow(
{
question: data.name,
marks: question.marks,
},
close
)
},
onError(err) {
showToast(__('Error'), __(err.message?.[0] || err), 'x')
},
}
)
}
}
const addQuestionRow = (question, close) => {
questionRow.submit(
{
...question,
},
{
onSuccess() {
show.value = false
showToast(__('Success'), __('Question added successfully'), 'check')
quiz.value.reload()
close()
},
onError(err) {
showToast(__('Error'), __(err.message?.[0] || err), 'x')
close()
},
}
)
}
const questionUpdate = createResource({
url: 'frappe.client.set_value',
auto: false,
makeParams(values) {
return {
doctype: 'LMS Question',
name: questionData.data?.name,
fieldname: {
...question,
},
}
},
})
const marksUpdate = createResource({
url: 'frappe.client.set_value',
auto: false,
makeParams(values) {
return {
doctype: 'LMS Quiz Question',
name: props.questionDetail.name,
fieldname: {
marks: question.marks,
},
}
},
})
const updateQuestion = (close) => {
questionUpdate.submit(
{},
{
onSuccess() {
marksUpdate.submit(
{},
{
onSuccess() {
show.value = false
showToast(
__('Success'),
__('Question updated successfully'),
'check'
)
quiz.value.reload()
close()
},
onError(err) {
showToast(__('Error'), __(err.message?.[0] || err), 'x')
close()
},
}
)
},
}
)
} }
const dialogOptions = computed(() => { const dialogOptions = computed(() => {
@@ -145,3 +339,10 @@ const dialogOptions = computed(() => {
} }
}) })
</script> </script>
<style>
input[type='radio']:checked {
background-color: theme('colors.gray.900') !important;
border-color: theme('colors.gray.900') !important;
--tw-ring-color: theme('colors.gray.900') !important;
}
</style>

View File

@@ -3,9 +3,7 @@
<div class="bg-blue-100 py-2 px-2 mb-4 rounded-md text-sm text-blue-800"> <div class="bg-blue-100 py-2 px-2 mb-4 rounded-md text-sm text-blue-800">
<div class="leading-relaxed"> <div class="leading-relaxed">
{{ {{
__('This quiz consists of {0} questions.').format( __('This quiz consists of {0} questions.').format(questions.length)
quiz.data.questions.length
)
}} }}
</div> </div>
<div v-if="quiz.data.passing_percentage" class="leading-relaxed"> <div v-if="quiz.data.passing_percentage" class="leading-relaxed">
@@ -59,7 +57,7 @@
</div> </div>
</div> </div>
<div v-else-if="!quizSubmission.data"> <div v-else-if="!quizSubmission.data">
<div v-for="(question, qtidx) in quiz.data.questions"> <div v-for="(question, qtidx) in questions">
<div <div
v-if="qtidx == activeQuestion - 1 && questionDetails.data" v-if="qtidx == activeQuestion - 1 && questionDetails.data"
class="border rounded-md p-5" class="border rounded-md p-5"
@@ -166,7 +164,7 @@
{{ {{
__('Question {0} of {1}').format( __('Question {0} of {1}').format(
activeQuestion, activeQuestion,
quiz.data.questions.length questions.length
) )
}} }}
</div> </div>
@@ -179,7 +177,7 @@
</span> </span>
</Button> </Button>
<Button <Button
v-else-if="activeQuestion != quiz.data.questions.length" v-else-if="activeQuestion != questions.length"
@click="nextQuetion()" @click="nextQuetion()"
> >
<span> <span>
@@ -250,6 +248,7 @@ const activeQuestion = ref(0)
const currentQuestion = ref('') const currentQuestion = ref('')
const selectedOptions = reactive([0, 0, 0, 0]) const selectedOptions = reactive([0, 0, 0, 0])
const showAnswers = reactive([]) const showAnswers = reactive([])
let questions = reactive([])
const possibleAnswer = ref(null) const possibleAnswer = ref(null)
const props = defineProps({ const props = defineProps({
@@ -270,15 +269,30 @@ const quiz = createResource({
cache: ['quiz', props.quizName], cache: ['quiz', props.quizName],
auto: true, auto: true,
onSuccess(data) { onSuccess(data) {
if (data.shuffle_questions) { populateQuestions()
data.questions = data.questions.sort(() => Math.random() - 0.5)
}
if (data.limit_questions_to) {
data.questions = data.questions.slice(0, data.limit_questions_to)
}
}, },
}) })
const populateQuestions = () => {
let data = quiz.data
if (data.shuffle_questions) {
questions = shuffleArray(data.questions)
if (data.limit_questions_to) {
questions = questions.slice(0, data.limit_questions_to)
}
} else {
questions = data.questions
}
}
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
;[array[i], array[j]] = [array[j], array[i]]
}
return array
}
const attempts = createResource({ const attempts = createResource({
url: 'frappe.client.get_list', url: 'frappe.client.get_list',
makeParams(values) { makeParams(values) {
@@ -310,7 +324,7 @@ const attempts = createResource({
watch( watch(
() => quiz.data, () => quiz.data,
() => { () => {
if (quiz.data) { if (quiz.data && quiz.data.max_attempts) {
attempts.reload() attempts.reload()
resetQuiz() resetQuiz()
} }
@@ -464,7 +478,7 @@ const submitQuiz = () => {
const createSubmission = () => { const createSubmission = () => {
quizSubmission.reload().then(() => { quizSubmission.reload().then(() => {
attempts.reload() if (quiz.data && quiz.data.max_attempts) attempts.reload()
}) })
} }
@@ -473,6 +487,7 @@ const resetQuiz = () => {
selectedOptions.splice(0, selectedOptions.length, ...[0, 0, 0, 0]) selectedOptions.splice(0, selectedOptions.length, ...[0, 0, 0, 0])
showAnswers.length = 0 showAnswers.length = 0
quizSubmission.reset() quizSubmission.reset()
populateQuestions()
} }
const getSubmissionColumns = () => { const getSubmissionColumns = () => {

View File

@@ -236,6 +236,7 @@ import MultiSelect from '@/components/Controls/MultiSelect.vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { getFileSize, showToast } from '../utils' import { getFileSize, showToast } from '../utils'
import { X, FileText } from 'lucide-vue-next' import { X, FileText } from 'lucide-vue-next'
import { capture } from '@/telemetry'
const router = useRouter() const router = useRouter()
const user = inject('$user') const user = inject('$user')
@@ -274,6 +275,8 @@ onMounted(() => {
if (!user.data) window.location.href = '/login' if (!user.data) window.location.href = '/login'
if (props.batchName != 'new') { if (props.batchName != 'new') {
batchDetail.reload() batchDetail.reload()
} else {
capture('batch_form_opened')
} }
window.addEventListener('keydown', keyboardShortcut) window.addEventListener('keydown', keyboardShortcut)
}) })
@@ -377,6 +380,7 @@ const createNewBatch = () => {
{}, {},
{ {
onSuccess(data) { onSuccess(data) {
capture('batch_created')
router.push({ router.push({
name: 'BatchDetail', name: 'BatchDetail',
params: { params: {
@@ -447,7 +451,7 @@ const breadcrumbs = computed(() => {
} }
crumbs.push({ crumbs.push({
label: props.batchName == 'new' ? 'New Batch' : 'Edit Batch', label: props.batchName == 'new' ? 'New Batch' : 'Edit Batch',
route: { name: 'BatchCreation', params: { batchName: props.batchName } }, route: { name: 'BatchForm', params: { batchName: props.batchName } },
}) })
return crumbs return crumbs
}) })

View File

@@ -5,7 +5,7 @@
> >
<Breadcrumbs <Breadcrumbs
class="h-7" class="h-7"
:items="[{ label: __('All Batches'), route: { name: 'Batches' } }]" :items="[{ label: __('Batches'), route: { name: 'Batches' } }]"
/> />
<div class="flex space-x-2"> <div class="flex space-x-2">
<div class="w-40"> <div class="w-40">
@@ -19,13 +19,13 @@
<router-link <router-link
v-if="user.data?.is_moderator" v-if="user.data?.is_moderator"
:to="{ :to="{
name: 'BatchCreation', name: 'BatchForm',
params: { batchName: 'new' }, params: { batchName: 'new' },
}" }"
> >
<Button variant="solid"> <Button variant="solid">
<template #prefix> <template #prefix>
<Plus class="h-4 w-4" /> <Plus class="h-4 w-4 stroke-1.5" />
</template> </template>
{{ __('New Batch') }} {{ __('New Batch') }}
</Button> </Button>

View File

@@ -6,9 +6,10 @@
<div> <div>
<FormControl <FormControl
type="text" type="text"
placeholder="Search Participants" placeholder="Search"
v-model="searchQuery" v-model="searchQuery"
@input="participants.reload()" @input="participants.reload()"
class="w-40"
> >
<template #prefix> <template #prefix>
<Search class="w-4 stroke-1.5 text-gray-600" name="search" /> <Search class="w-4 stroke-1.5 text-gray-600" name="search" />

View File

@@ -227,6 +227,7 @@ import { FileText, X } from 'lucide-vue-next'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import CourseOutline from '@/components/CourseOutline.vue' import CourseOutline from '@/components/CourseOutline.vue'
import MultiSelect from '@/components/Controls/MultiSelect.vue' import MultiSelect from '@/components/Controls/MultiSelect.vue'
import { capture } from '@/telemetry'
const user = inject('$user') const user = inject('$user')
const newTag = ref('') const newTag = ref('')
@@ -268,6 +269,8 @@ onMounted(() => {
if (props.courseName !== 'new') { if (props.courseName !== 'new') {
courseResource.reload() courseResource.reload()
} else {
capture('course_form_opened')
} }
window.addEventListener('keydown', keyboardShortcut) window.addEventListener('keydown', keyboardShortcut)
}) })
@@ -388,9 +391,10 @@ const submitCourse = () => {
} else { } else {
courseCreationResource.submit(course, { courseCreationResource.submit(course, {
onSuccess(data) { onSuccess(data) {
capture('course_created')
showToast('Success', 'Course created successfully', 'check') showToast('Success', 'Course created successfully', 'check')
router.push({ router.push({
name: 'CreateCourse', name: 'CourseForm',
params: { courseName: data.name }, params: { courseName: data.name },
}) })
}, },
@@ -489,7 +493,7 @@ const breadcrumbs = computed(() => {
} }
crumbs.push({ crumbs.push({
label: props.courseName == 'new' ? 'New Course' : 'Edit Course', label: props.courseName == 'new' ? 'New Course' : 'Edit Course',
route: { name: 'CreateCourse', params: { courseName: props.courseName } }, route: { name: 'CourseForm', params: { courseName: props.courseName } },
}) })
return crumbs return crumbs
}) })

View File

@@ -5,22 +5,24 @@
> >
<Breadcrumbs <Breadcrumbs
class="h-7" class="h-7"
:items="[{ label: __('All Courses'), route: { name: 'Courses' } }]" :items="[{ label: __('Courses'), route: { name: 'Courses' } }]"
/> />
<div class="flex space-x-2"> <div class="flex space-x-2 justify-end">
<FormControl <div class="w-36">
type="text" <FormControl
placeholder="Search Course" type="text"
v-model="searchQuery" placeholder="Search"
@input="courses.reload()" v-model="searchQuery"
> @input="courses.reload()"
<template #prefix> >
<Search class="w-4 stroke-1.5 text-gray-600" name="search" /> <template #prefix>
</template> <Search class="w-4 h-4 stroke-1.5" name="search" />
</FormControl> </template>
</FormControl>
</div>
<router-link <router-link
:to="{ :to="{
name: 'CreateCourse', name: 'CourseForm',
params: { params: {
courseName: 'new', courseName: 'new',
}, },

View File

@@ -50,9 +50,9 @@
</Button> </Button>
</div> </div>
</header> </header>
<div v-if="job.data" class="w-3/4 mx-auto"> <div v-if="job.data" class="max-w-3xl mx-auto">
<div class="p-4"> <div class="p-4">
<div class="flex mb-4"> <div class="flex mb-10">
<img <img
:src="job.data.company_logo" :src="job.data.company_logo"
class="w-16 h-16 rounded-lg object-contain mr-4" class="w-16 h-16 rounded-lg object-contain mr-4"
@@ -62,40 +62,36 @@
<div class="text-2xl font-semibold mb-4"> <div class="text-2xl font-semibold mb-4">
{{ job.data.job_title }} {{ job.data.job_title }}
</div> </div>
<div class="grid grid-cols-3 gap-8"> <div
<div class="grid grid-cols-1 gap-2"> class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-x-10 gap-y-2 md:gap-y-4"
<div class="flex items-center space-x-2"> >
<Building2 class="h-4 w-4 stroke-1.5" /> <div class="flex items-center space-x-2">
<span>{{ job.data.company_name }}</span> <Building2 class="h-4 w-4 stroke-1.5" />
</div> <span>{{ job.data.company_name }}</span>
<div class="flex items-center space-x-2">
<MapPin class="h-4 w-4 stroke-1.5" />
<span>{{ job.data.location }}</span>
</div>
</div> </div>
<div class="grid grid-cols-1 gap-2"> <div class="flex items-center space-x-2">
<div class="flex items-center space-x-2"> <MapPin class="h-4 w-4 stroke-1.5" />
<ClipboardType class="h-4 w-4 stroke-1.5" /> <span>{{ job.data.location }}</span>
<span>{{ job.data.type }}</span>
</div>
<div class="flex items-center space-x-2">
<CalendarDays class="h-4 w-4 stroke-1.5" />
<span>{{
dayjs(job.data.creation).format('DD MMM YYYY')
}}</span>
</div>
</div> </div>
<div class="grid grid-cols-1 h-fit"> <div class="flex items-center space-x-2">
<div <ClipboardType class="h-4 w-4 stroke-1.5" />
v-if="applicationCount.data" <span>{{ job.data.type }}</span>
class="flex items-center space-x-2" </div>
<div class="flex items-center space-x-2">
<CalendarDays class="h-4 w-4 stroke-1.5" />
<span>
{{ dayjs(job.data.creation).format('DD MMM YYYY') }}
</span>
</div>
<div
v-if="applicationCount.data"
class="flex items-center space-x-2"
>
<SquareUserRound class="h-4 w-4 stroke-1.5" />
<span
>{{ applicationCount.data }}
{{ __('applications received') }}</span
> >
<SquareUserRound class="h-4 w-4 stroke-1.5" />
<span
>{{ applicationCount.data }}
{{ __('applications received') }}</span
>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -58,7 +58,7 @@
<router-link <router-link
v-if="allowEdit()" v-if="allowEdit()"
:to="{ :to="{
name: 'CreateLesson', name: 'LessonForm',
params: { params: {
courseName: courseName, courseName: courseName,
chapterNumber: props.chapterNumber, chapterNumber: props.chapterNumber,

View File

@@ -70,16 +70,25 @@
</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'
import { updateDocumentTitle, createToast, getEditorTools } from '@/utils' import { updateDocumentTitle, createToast, getEditorTools } from '@/utils'
import { capture } from '@/telemetry'
const editor = ref(null) const editor = ref(null)
const instructorEditor = ref(null) const instructorEditor = ref(null)
const user = inject('$user') const user = inject('$user')
const openInstructorEditor = ref(false) const openInstructorEditor = ref(false)
let autoSaveInterval
const props = defineProps({ const props = defineProps({
courseName: { courseName: {
@@ -100,6 +109,7 @@ onMounted(() => {
if (!user.data?.is_moderator && !user.data?.is_instructor) { if (!user.data?.is_moderator && !user.data?.is_instructor) {
window.location.href = '/login' window.location.href = '/login'
} }
capture('lesson_form_opened')
editor.value = renderEditor('content') editor.value = renderEditor('content')
instructorEditor.value = renderEditor('instructor-notes') instructorEditor.value = renderEditor('instructor-notes')
}) })
@@ -134,32 +144,49 @@ const lessonDetails = createResource({
lesson[key] = data.lesson[key] lesson[key] = data.lesson[key]
}) })
lesson.include_in_preview = data.include_in_preview ? true : false lesson.include_in_preview = data.include_in_preview ? true : false
editor.value.isReady.then(() => { addLessonContent(data)
if (data.lesson.content) { addInstructorNotes(data)
editor.value.render(JSON.parse(data.lesson.content)) enableAutoSave()
} else if (data.lesson.body) {
let blocks = convertToJSON(data.lesson)
editor.value.render({
blocks: blocks,
})
}
})
instructorEditor.value.isReady.then(() => {
if (data.lesson.instructor_content) {
instructorEditor.value.render(
JSON.parse(data.lesson.instructor_content)
)
} else if (data.lesson.instructor_notes) {
let blocks = convertToJSON(data.lesson)
instructorEditor.value.render({
blocks: blocks,
})
}
})
} }
}, },
}) })
const addLessonContent = (data) => {
editor.value.isReady.then(() => {
if (data.lesson.content) {
editor.value.render(JSON.parse(data.lesson.content))
} else if (data.lesson.body) {
let blocks = convertToJSON(data.lesson)
editor.value.render({
blocks: blocks,
})
}
})
}
const addInstructorNotes = (data) => {
instructorEditor.value.isReady.then(() => {
if (data.lesson.instructor_content) {
instructorEditor.value.render(JSON.parse(data.lesson.instructor_content))
} else if (data.lesson.instructor_notes) {
let blocks = convertToJSON(data.lesson)
instructorEditor.value.render({
blocks: blocks,
})
}
})
}
const enableAutoSave = () => {
autoSaveInterval = setInterval(() => {
saveLesson()
}, 5000)
}
onBeforeUnmount(() => {
clearInterval(autoSaveInterval)
})
const newLessonResource = createResource({ const newLessonResource = createResource({
url: 'frappe.client.insert', url: 'frappe.client.insert',
makeParams(values) { makeParams(values) {
@@ -335,6 +362,7 @@ const createNewLesson = () => {
{ lesson: data.name }, { lesson: data.name },
{ {
onSuccess() { onSuccess() {
capture('lesson_created')
showToast('Success', 'Lesson created successfully', 'check') showToast('Success', 'Lesson created successfully', 'check')
lessonDetails.reload() lessonDetails.reload()
}, },
@@ -357,9 +385,6 @@ const editCurrentLesson = () => {
validate() { validate() {
return validateLesson() return validateLesson()
}, },
onSuccess() {
showToast('Success', 'Lesson updated successfully', 'check')
},
onError(err) { onError(err) {
showToast('Error', err.message, 'x') showToast('Error', err.message, 'x')
}, },
@@ -418,7 +443,7 @@ const breadcrumbs = computed(() => {
crumbs.push({ crumbs.push({
label: lessonDetails?.data?.lesson ? 'Edit Lesson' : 'Create Lesson', label: lessonDetails?.data?.lesson ? 'Edit Lesson' : 'Create Lesson',
route: { route: {
name: 'CreateLesson', name: 'LessonForm',
params: { params: {
courseName: props.courseName, courseName: props.courseName,
chapterNumber: props.chapterNumber, chapterNumber: props.chapterNumber,

View File

@@ -16,7 +16,7 @@
<h2 class="mb-3 text-lg font-semibold text-gray-900"> <h2 class="mb-3 text-lg font-semibold text-gray-900">
{{ __('Achievements') }} {{ __('Achievements') }}
</h2> </h2>
<div class="grid grid-cols-5 gap-4"> <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4">
<div v-for="badge in badges.data"> <div v-for="badge in badges.data">
<Popover trigger="hover" :leaveDelay="Number(0.01)"> <Popover trigger="hover" :leaveDelay="Number(0.01)">
<template #target> <template #target>

View File

@@ -3,6 +3,9 @@
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="submitQuiz()">
{{ __('Save') }}
</Button>
</header> </header>
<div class="w-3/4 mx-auto py-5"> <div class="w-3/4 mx-auto py-5">
<!-- Details --> <!-- Details -->
@@ -10,107 +13,145 @@
<div class="text-sm font-semibold mb-4"> <div class="text-sm font-semibold mb-4">
{{ __('Details') }} {{ __('Details') }}
</div> </div>
<div class="grid grid-cols-2 gap-5"> <FormControl
<div class="space-y-2"> v-model="quiz.title"
<FormControl v-model="quiz.title" :label="__('Title')" /> :label="
quizDetails.data?.name
? __('Title')
: __('Enter a title and save the quiz to proceed')
"
/>
<div v-if="quizDetails.data?.name">
<div class="grid grid-cols-3 gap-5 mt-2 mb-8">
<FormControl <FormControl
v-model="quiz.max_attempts" v-model="quiz.max_attempts"
:label="__('Maximun Attempts')" :label="__('Maximun Attempts')"
/> />
<FormControl <FormControl
v-model="quiz.limit_questions_to" v-model="quiz.total_marks"
:label="__('Limit Questions To')" :label="__('Total Marks')"
disabled
/> />
</div>
<div class="space-y-2">
<FormControl v-model="quiz.total_marks" :label="__('Total Marks')" />
<FormControl <FormControl
v-model="quiz.passing_percentage" v-model="quiz.passing_percentage"
:label="__('Passing Percentage')" :label="__('Passing Percentage')"
/> />
</div> </div>
</div>
</div>
<!-- Settings --> <!-- Settings -->
<div class="mb-8"> <div class="mb-8">
<div class="text-sm font-semibold mb-4"> <div class="text-sm font-semibold mb-4">
{{ __('Settings') }} {{ __('Settings') }}
</div> </div>
<div class="grid grid-cols-3 gap-5 my-4"> <div class="grid grid-cols-3 gap-5 my-4">
<FormControl <FormControl
v-model="quiz.show_answers" v-model="quiz.show_answers"
type="checkbox" type="checkbox"
:label="__('Show Answers')" :label="__('Show Answers')"
/> />
<FormControl <FormControl
v-model="quiz.show_submission_history" v-model="quiz.show_submission_history"
type="checkbox" type="checkbox"
:label="__('Show Submission History')" :label="__('Show Submission History')"
/> />
<FormControl </div>
v-model="quiz.shuffle_questions"
type="checkbox"
:label="__('Shuffle Questions')"
/>
</div>
</div>
<!-- Questions -->
<div>
<div class="flex items-center justify-between mb-4">
<div class="text-sm font-semibold">
{{ __('Questions') }}
</div> </div>
<Button @click="openQuestionModal()">
<template #prefix> <div class="mb-8">
<Plus class="w-4 h-4" /> <div class="text-sm font-semibold mb-4">
</template> {{ __('Shuffle Settings') }}
{{ __('New Question') }} </div>
</Button> <div class="grid grid-cols-3">
</div> <FormControl
<ListView v-model="quiz.shuffle_questions"
:columns="questionColumns" type="checkbox"
:rows="quiz.questions" :label="__('Shuffle Questions')"
row-key="name" />
:options="{ <FormControl
showTooltip: false, v-if="quiz.shuffle_questions"
}" v-model="quiz.limit_questions_to"
> :label="__('Limit Questions To')"
<ListHeader />
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2" </div>
> </div>
<ListHeaderItem :item="item" v-for="item in questionColumns" />
</ListHeader> <!-- Questions -->
<ListRows> <div>
<ListRow <div class="flex items-center justify-between mb-4">
:row="row" <div class="text-sm font-semibold">
v-slot="{ idx, column, item }" {{ __('Questions') }}
v-for="row in quiz.questions" </div>
@click="openQuestionModal(row.question)" <Button @click="openQuestionModal()">
<template #prefix>
<Plus class="w-4 h-4" />
</template>
{{ __('New Question') }}
</Button>
</div>
<ListView
:columns="questionColumns"
:rows="quiz.questions"
row-key="name"
:options="{
showTooltip: false,
}"
> >
<ListRowItem :item="item"> <ListHeader
<div class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
v-if="column.key == 'question_detail'" >
class="text-xs truncate" <ListHeaderItem :item="item" v-for="item in questionColumns" />
</ListHeader>
<ListRows>
<ListRow
:row="row"
v-slot="{ idx, column, item }"
v-for="row in quiz.questions"
@click="openQuestionModal(row)"
> >
{{ item }} <ListRowItem :item="item">
</div> <div
<div v-else class="text-xs"> v-if="column.key == 'question_detail'"
{{ item }} class="text-xs truncate h-4"
</div> v-html="item"
</ListRowItem> ></div>
</ListRow> <div v-else class="text-xs">
</ListRows> {{ item }}
</ListView> </div>
</ListRowItem>
</ListRow>
</ListRows>
<ListSelectBanner>
<template #actions="{ unselectAll, selections }">
<div class="flex gap-2">
<Button
variant="ghost"
@click="deleteQuizzes(selections, unselectAll)"
>
<Trash2 class="h-4 w-4 stroke-1.5" />
</Button>
</div>
</template>
</ListSelectBanner>
</ListView>
</div>
</div>
</div> </div>
</div> </div>
<Question v-model="showQuestionModal" :questionName="currentQuestion" /> <Question
v-model="showQuestionModal"
:questionDetail="currentQuestion"
v-model:quiz="quizDetails"
:title="
currentQuestion.question
? __('Edit the question')
: __('Add a new question')
"
/>
</template> </template>
<script setup> <script setup>
import { import {
Breadcrumbs, Breadcrumbs,
createDocumentResource, createResource,
FormControl, FormControl,
ListView, ListView,
ListHeader, ListHeader,
@@ -118,14 +159,32 @@ import {
ListRows, ListRows,
ListRow, ListRow,
ListRowItem, ListRowItem,
ListSelectBanner,
Button, Button,
} from 'frappe-ui' } from 'frappe-ui'
import { computed, reactive, ref } from 'vue' import {
import { Plus } from 'lucide-vue-next' computed,
reactive,
ref,
onMounted,
inject,
onBeforeUnmount,
watch,
isReactive,
} from 'vue'
import { Plus, Trash2 } from 'lucide-vue-next'
import Question from '@/components/Modals/Question.vue' import Question from '@/components/Modals/Question.vue'
import { showToast } from '../utils'
import { useRouter } from 'vue-router'
const showQuestionModal = ref(false) const showQuestionModal = ref(false)
const currentQuestion = ref(null) const currentQuestion = reactive({
question: '',
marks: 0,
name: '',
})
const user = inject('$user')
const router = useRouter()
const props = defineProps({ const props = defineProps({
quizID: { quizID: {
@@ -136,8 +195,8 @@ const props = defineProps({
const quiz = reactive({ const quiz = reactive({
title: '', title: '',
total_marks: '', total_marks: 0,
passing_percentage: '', passing_percentage: 0,
max_attempts: 0, max_attempts: 0,
limit_questions_to: 0, limit_questions_to: 0,
show_answers: true, show_answers: true,
@@ -146,11 +205,50 @@ const quiz = reactive({
questions: [], questions: [],
}) })
const quizDetails = createDocumentResource({ onMounted(() => {
doctype: 'LMS Quiz', if (
name: props.quizID, props.quizID == 'new' &&
auto: true, !user.data?.is_moderator &&
cache: ['quiz', props.quizID], !user.data?.is_instructor
) {
router.push({ name: 'Courses' })
}
if (props.quizID !== 'new') {
quizDetails.reload()
}
window.addEventListener('keydown', keyboardShortcut)
})
const keyboardShortcut = (e) => {
if (
e.key === 's' &&
(e.ctrlKey || e.metaKey) &&
!e.target.classList.contains('ProseMirror')
) {
submitQuiz()
e.preventDefault()
}
}
onBeforeUnmount(() => {
window.removeEventListener('keydown', keyboardShortcut)
})
watch(
() => props.quizID !== 'new',
(newVal) => {
if (newVal) {
quizDetails.reload()
}
}
)
const quizDetails = createResource({
url: 'frappe.client.get',
makeParams(values) {
return { doctype: 'LMS Quiz', name: props.quizID }
},
auto: false,
onSuccess(data) { onSuccess(data) {
Object.keys(data).forEach((key) => { Object.keys(data).forEach((key) => {
if (Object.hasOwn(quiz, key)) quiz[key] = data[key] if (Object.hasOwn(quiz, key)) quiz[key] = data[key]
@@ -168,6 +266,82 @@ const quizDetails = createDocumentResource({
}, },
}) })
const quizCreate = createResource({
url: 'frappe.client.insert',
auto: false,
makeParams(values) {
return {
doc: {
doctype: 'LMS Quiz',
...quiz,
},
}
},
})
const quizUpdate = createResource({
url: 'frappe.client.set_value',
auto: false,
makeParams(values) {
return {
doctype: 'LMS Quiz',
name: values.quizID,
fieldname: {
total_marks: calculateTotalMarks(),
...quiz,
},
}
},
})
const submitQuiz = () => {
if (quizDetails.data?.name) updateQuiz()
else createQuiz()
}
const createQuiz = () => {
quizCreate.submit(
{},
{
onSuccess(data) {
showToast(__('Success'), __('Quiz created successfully'), 'check')
router.push({
name: 'QuizCreation',
params: { quizID: data.name },
})
},
onError(err) {
showToast(__('Error'), __(err.messages?.[0] || err), 'x')
},
}
)
}
const updateQuiz = () => {
quizUpdate.submit(
{ quizID: quizDetails.data?.name },
{
onSuccess(data) {
quiz.total_marks = data.total_marks
showToast(__('Success'), __('Quiz updated successfully'), 'check')
},
onError(err) {
showToast(__('Error'), __(err.messages?.[0] || err), 'x')
},
}
)
}
const calculateTotalMarks = () => {
let totalMarks = 0
if (quiz.limit_questions_to && quiz.questions.length > 0)
return quiz.questions[0].marks * quiz.limit_questions_to
quiz.questions.forEach((question) => {
totalMarks += question.marks
})
return totalMarks
}
const questionColumns = computed(() => { const questionColumns = computed(() => {
return [ return [
{ {
@@ -189,12 +363,38 @@ const questionColumns = computed(() => {
}) })
const openQuestionModal = (question = null) => { const openQuestionModal = (question = null) => {
console.log('called') if (question) {
console.log(question) currentQuestion.question = question.question
currentQuestion.value = question currentQuestion.marks = question.marks
currentQuestion.name = question.name
} else {
currentQuestion.question = ''
currentQuestion.marks = 0
currentQuestion.name = ''
}
showQuestionModal.value = true showQuestionModal.value = true
} }
const deleteQuiz = createResource({
url: 'frappe.client.delete',
makeParams(values) {
return {
doctype: 'LMS Quiz Question',
name: values.quiz,
}
},
})
const deleteQuizzes = (selections, unselectAll) => {
selections.forEach(async (quiz) => {
deleteQuiz.submit({ quiz })
})
setTimeout(() => {
quizDetails.reload()
unselectAll()
}, 500)
}
const breadcrumbs = computed(() => { const breadcrumbs = computed(() => {
let crumbs = [ let crumbs = [
{ {
@@ -204,6 +404,15 @@ const breadcrumbs = computed(() => {
}, },
}, },
] ]
/* if (quizDetails.data) {
crumbs.push({
label: quiz.title,
})
} */
crumbs.push({
label: props.quizID == 'new' ? 'New Quiz' : quizDetails.data?.title,
route: { name: 'QuizCreation', params: { quizID: props.quizID } },
})
return crumbs return crumbs
}) })
</script> </script>

View File

@@ -3,12 +3,21 @@
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"> <router-link
<template #prefix> :to="{
<Plus class="w-4 h-4"/> name: 'QuizCreation',
</template> params: {
{{ __('New Quiz') }} quizID: 'new',
</Button> },
}"
>
<Button variant="solid">
<template #prefix>
<Plus class="w-4 h-4" />
</template>
{{ __('New Quiz') }}
</Button>
</router-link>
</header> </header>
<div v-if="quizzes.data?.length" class="w-3/4 mx-auto py-5"> <div v-if="quizzes.data?.length" class="w-3/4 mx-auto py-5">
<ListView <ListView
@@ -50,10 +59,18 @@ import {
ListHeaderItem, ListHeaderItem,
Button, Button,
} from 'frappe-ui' } from 'frappe-ui'
import { computed, inject } from 'vue' import { useRouter } from 'vue-router'
import { computed, inject, onMounted } from 'vue'
import { Plus } from 'lucide-vue-next' import { Plus } from 'lucide-vue-next'
const user = inject('$user') const user = inject('$user')
const router = useRouter()
onMounted(() => {
if (!user.data?.is_moderator && !user.data?.is_instructor) {
router.push({ name: 'Courses' })
}
})
const quizFilter = computed(() => { const quizFilter = computed(() => {
if (user.data?.is_moderator) return {} if (user.data?.is_moderator) return {}
@@ -68,6 +85,7 @@ const quizzes = createListResource({
fields: ['name', 'title', 'passing_percentage', 'total_marks'], fields: ['name', 'title', 'passing_percentage', 'total_marks'],
auto: true, auto: true,
cache: ['quizzes', user.data?.name], cache: ['quizzes', user.data?.name],
orderBy: 'modified desc',
onSuccess(data) { onSuccess(data) {
data.forEach((row) => {}) data.forEach((row) => {})
}, },

View File

@@ -97,20 +97,20 @@ const routes = [
}, },
{ {
path: '/courses/:courseName/edit', path: '/courses/:courseName/edit',
name: 'CreateCourse', name: 'CourseForm',
component: () => import('@/pages/CreateCourse.vue'), component: () => import('@/pages/CourseForm.vue'),
props: true, props: true,
}, },
{ {
path: '/courses/:courseName/learn/:chapterNumber-:lessonNumber/edit', path: '/courses/:courseName/learn/:chapterNumber-:lessonNumber/edit',
name: 'CreateLesson', name: 'LessonForm',
component: () => import('@/pages/CreateLesson.vue'), component: () => import('@/pages/LessonForm.vue'),
props: true, props: true,
}, },
{ {
path: '/batches/:batchName/edit', path: '/batches/:batchName/edit',
name: 'BatchCreation', name: 'BatchForm',
component: () => import('@/pages/BatchCreation.vue'), component: () => import('@/pages/BatchForm.vue'),
props: true, props: true,
}, },
{ {

View File

@@ -53,11 +53,18 @@ export const sessionStore = defineStore('lms-session', () => {
}, },
}) })
const sidebarSettings = createResource({
url: 'lms.lms.api.get_sidebar_settings',
cache: 'Sidebar Settings',
auto: false,
})
return { return {
user, user,
isLoggedIn, isLoggedIn,
login, login,
logout, logout,
branding, branding,
sidebarSettings,
} }
}) })

98
frontend/src/telemetry.ts Normal file
View File

@@ -0,0 +1,98 @@
import { useStorage } from "@vueuse/core";
import { call } from "frappe-ui";
import "../../../frappe/frappe/public/js/lib/posthog.js";
const APP = "lms";
const SITENAME = window.location.hostname;
declare global {
interface Window {
posthog: any;
}
}
const telemetry = useStorage("telemetry", {
enabled: false,
project_id: "",
host: "",
});
export async function init() {
await set_enabled();
if (!telemetry.value.enabled) return;
try {
await set_credentials();
window.posthog.init(telemetry.value.project_id, {
api_host: telemetry.value.host,
autocapture: false,
person_profiles: "always",
capture_pageview: true,
capture_pageleave: true,
disable_session_recording: false,
session_recording: {
maskAllInputs: false,
maskInputOptions: {
password: true,
},
},
loaded: (posthog) => {
window.posthog = posthog;
window.posthog.identify(SITENAME);
},
});
} catch (e) {
console.trace("Failed to initialize telemetry", e);
telemetry.value.enabled = false;
}
}
async function set_enabled() {
if (telemetry.value.enabled) return;
await call("lms.lms.telemetry.is_enabled").then((res) => {
telemetry.value.enabled = res;
});
}
async function set_credentials() {
if (!telemetry.value.enabled) return;
if (telemetry.value.project_id && telemetry.value.host) return;
await call("lms.lms.telemetry.get_credentials").then((res) => {
telemetry.value.project_id = res.project_id;
telemetry.value.host = res.telemetry_host;
});
}
interface CaptureOptions {
data: {
user: string;
[key: string]: string | number | boolean | object;
};
}
export function capture(
event: string,
options: CaptureOptions = { data: { user: "" } }
) {
if (!telemetry.value.enabled) return;
window.posthog.capture(`${APP}_${event}`, options);
}
export function recordSession() {
if (!telemetry.value.enabled) return;
if (window.posthog && window.posthog.__loaded) {
window.posthog.startSessionRecording();
}
}
export function stopSession() {
if (!telemetry.value.enabled) return;
if (
window.posthog &&
window.posthog.__loaded &&
window.posthog.sessionRecordingStarted()
) {
window.posthog.stopSessionRecording();
}
}

View File

@@ -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_-]+)(?:\?[^\/]*)?$/,
@@ -424,15 +424,15 @@ export function getSidebarLinks() {
'Courses', 'Courses',
'CourseDetail', 'CourseDetail',
'Lesson', 'Lesson',
'CreateCourse', 'CourseForm',
'CreateLesson', 'LessonForm',
], ],
}, },
{ {
label: 'Batches', label: 'Batches',
icon: 'Users', icon: 'Users',
to: 'Batches', to: 'Batches',
activeFor: ['Batches', 'BatchDetail', 'Batch', 'BatchCreation'], activeFor: ['Batches', 'BatchDetail', 'Batch', 'BatchForm'],
}, },
{ {
label: 'Certified Participants', label: 'Certified Participants',

View File

@@ -1 +1 @@
__version__ = "2.0.0" __version__ = "2.1.0"

View File

@@ -176,7 +176,16 @@ update_website_context = [
] ]
jinja = { jinja = {
"methods": ["lms.lms.utils.get_signup_optin_checks"], "methods": [
"lms.lms.utils.get_signup_optin_checks",
"lms.lms.utils.get_tags",
"lms.lms.utils.get_lesson_count",
"lms.lms.utils.get_instructors",
"lms.lms.utils.get_lesson_index",
"lms.lms.utils.get_lesson_url",
"lms.page_renderers.get_profile_url",
"lms.overrides.user.get_palette",
],
"filters": [], "filters": [],
} }
## Specify the additional tabs to be included in the user profile page. ## Specify the additional tabs to be included in the user profile page.

View File

@@ -6,6 +6,7 @@ from frappe.translate import get_all_translations
from frappe import _ from frappe import _
from frappe.query_builder import DocType from frappe.query_builder import DocType
from frappe.query_builder.functions import Count from frappe.query_builder.functions import Count
from frappe.utils import time_diff, now_datetime, get_datetime
@frappe.whitelist() @frappe.whitelist()

View File

@@ -59,6 +59,7 @@ class LMSCertificateRequest(Document):
"evaluator": self.evaluator, "evaluator": self.evaluator,
"date": self.date, "date": self.date,
"start_time": self.start_time, "start_time": self.start_time,
"member": ["!=", self.member],
}, },
): ):
frappe.throw(_("The slot is already booked by another participant.")) frappe.throw(_("The slot is already booked by another participant."))

View File

@@ -10,6 +10,7 @@ from lms.lms.utils import has_course_instructor_role, has_course_moderator_role
class LMSQuestion(Document): class LMSQuestion(Document):
def validate(self): def validate(self):
validate_correct_answers(self) validate_correct_answers(self)
update_question_title(self)
def validate_correct_answers(question): def validate_correct_answers(question):
@@ -62,6 +63,16 @@ def validate_possible_answer(question):
) )
def update_question_title(question):
if not question.is_new():
question_rows = frappe.get_all(
"LMS Quiz Question", {"question": question.name}, pluck="name"
)
for row in question_rows:
frappe.db.set_value("LMS Quiz Question", row, "question_detail", question.question)
def get_correct_options(question): def get_correct_options(question):
correct_options = [] correct_options = []
correct_option_fields = [ correct_option_fields = [

View File

@@ -9,16 +9,15 @@
"field_order": [ "field_order": [
"title", "title",
"max_attempts", "max_attempts",
"limit_questions_to", "show_answers",
"column_break_gaac", "column_break_gaac",
"total_marks", "total_marks",
"passing_percentage", "passing_percentage",
"section_break_hsiv",
"show_answers",
"column_break_rocd",
"show_submission_history", "show_submission_history",
"column_break_dsup", "section_break_tzbu",
"shuffle_questions", "shuffle_questions",
"column_break_clsh",
"limit_questions_to",
"section_break_sbjx", "section_break_sbjx",
"questions", "questions",
"section_break_3", "section_break_3",
@@ -91,11 +90,6 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Show Submission History" "label": "Show Submission History"
}, },
{
"fieldname": "section_break_hsiv",
"fieldtype": "Section Break",
"label": "Settings"
},
{ {
"fieldname": "passing_percentage", "fieldname": "passing_percentage",
"fieldtype": "Int", "fieldtype": "Int",
@@ -105,10 +99,6 @@
"non_negative": 1, "non_negative": 1,
"reqd": 1 "reqd": 1
}, },
{
"fieldname": "column_break_rocd",
"fieldtype": "Column Break"
},
{ {
"default": "0", "default": "0",
"fieldname": "total_marks", "fieldname": "total_marks",
@@ -119,10 +109,6 @@
"read_only": 1, "read_only": 1,
"reqd": 1 "reqd": 1
}, },
{
"fieldname": "column_break_dsup",
"fieldtype": "Column Break"
},
{ {
"default": "0", "default": "0",
"fieldname": "shuffle_questions", "fieldname": "shuffle_questions",
@@ -130,14 +116,23 @@
"label": "Shuffle Questions" "label": "Shuffle Questions"
}, },
{ {
"depends_on": "shuffle_questions",
"fieldname": "limit_questions_to", "fieldname": "limit_questions_to",
"fieldtype": "Int", "fieldtype": "Int",
"label": "Limit Questions To" "label": "Limit Questions To"
},
{
"fieldname": "section_break_tzbu",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_clsh",
"fieldtype": "Column Break"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2024-07-19 18:21:26.681501", "modified": "2024-08-09 12:21:36.256522",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Quiz", "name": "LMS Quiz",

View File

@@ -5,7 +5,7 @@ import json
import frappe import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import cstr, comma_and from frappe.utils import cstr, comma_and, cint
from fuzzywuzzy import fuzz from fuzzywuzzy import fuzz
from lms.lms.doctype.course_lesson.course_lesson import save_progress from lms.lms.doctype.course_lesson.course_lesson import save_progress
from lms.lms.utils import ( from lms.lms.utils import (
@@ -30,12 +30,12 @@ class LMSQuiz(Document):
) )
def validate_limit(self): def validate_limit(self):
if self.limit_questions_to and self.limit_questions_to >= len(self.questions): if self.limit_questions_to and cint(self.limit_questions_to) >= len(self.questions):
frappe.throw( frappe.throw(
_("Limit cannot be greater than or equal to the number of questions in the quiz.") _("Limit cannot be greater than or equal to the number of questions in the quiz.")
) )
if self.limit_questions_to and self.limit_questions_to < len(self.questions): if self.limit_questions_to and cint(self.limit_questions_to) < len(self.questions):
marks = [question.marks for question in self.questions] marks = [question.marks for question in self.questions]
if len(set(marks)) > 1: if len(set(marks)) > 1:
frappe.throw(_("All questions should have the same marks if the limit is set.")) frappe.throw(_("All questions should have the same marks if the limit is set."))
@@ -43,10 +43,10 @@ class LMSQuiz(Document):
def calculate_total_marks(self): def calculate_total_marks(self):
if self.limit_questions_to: if self.limit_questions_to:
self.total_marks = sum( self.total_marks = sum(
question.marks for question in self.questions[: self.limit_questions_to] question.marks for question in self.questions[: cint(self.limit_questions_to)]
) )
else: else:
self.total_marks = sum(question.marks for question in self.questions) self.total_marks = sum(cint(question.marks) for question in self.questions)
def autoname(self): def autoname(self):
if not self.name: if not self.name:

18
lms/lms/telemetry.py Normal file
View File

@@ -0,0 +1,18 @@
import frappe
@frappe.whitelist()
def is_enabled():
return bool(
frappe.get_system_settings("enable_telemetry")
and frappe.conf.get("posthog_host")
and frappe.conf.get("posthog_project_id")
)
@frappe.whitelist()
def get_credentials():
return {
"project_id": frappe.conf.get("posthog_project_id"),
"telemetry_host": frappe.conf.get("posthog_host"),
}

View File

@@ -9,7 +9,7 @@
"label": "Enrollments" "label": "Enrollments"
} }
], ],
"content": "[{\"id\":\"jNO4sdKxHu\",\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\"><b>Get Started</b></span>\",\"col\":12}},{\"id\":\"5s0qRBc4rY\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/lms/courses\\\">Visit LMS Portal</a>\",\"col\":4}},{\"id\":\"lGMuNLpmv-\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/lms/courses/new/edit\\\">Create a Course</a>\",\"col\":4}},{\"id\":\"3TVyc9AkPy\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/app/web-page/new-web-page-1\\\">Setup a Home Page</a>\",\"col\":4}},{\"id\":\"9zcbqpu2gm\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/app/lms-settings/LMS%20Settings\\\">LMS Setting</a>\",\"col\":4}},{\"id\":\"0ATmnKmXjc\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"https://docs.frappe.io/learning\\\">Documentation</a>\",\"col\":4}},{\"id\":\"C128a4abjX\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"5q4sPiv2ci\",\"type\":\"chart\",\"data\":{\"chart_name\":\"Signups\",\"col\":6}},{\"id\":\"8NSaRaEV5u\",\"type\":\"chart\",\"data\":{\"chart_name\":\"Enrollments\",\"col\":6}},{\"id\":\"kMuzko0uAU\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"iuvIOHmztI\",\"type\":\"header\",\"data\":{\"text\":\"<span style=\\\"font-size: 18px;\\\"><b>Statistics</b></span>\",\"col\":12}},{\"id\":\"l0VTd66Uy2\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Users\",\"col\":4}},{\"id\":\"wAWZin1KKk\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Course\",\"col\":4}},{\"id\":\"RLrIlFx0Hd\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Enrollments\",\"col\":4}},{\"id\":\"OuhWkhCQmq\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Course Completed\",\"col\":4}},{\"id\":\"3g8QmNqUXG\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Certificate\",\"col\":4}},{\"id\":\"EZsdsujs8N\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Evaluation\",\"col\":4}},{\"id\":\"s-nfsFQbGV\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"jeOBWBzHEa\",\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\"><b>Master</b></span>\",\"col\":12}},{\"id\":\"sVhgfS5GIh\",\"type\":\"card\",\"data\":{\"card_name\":\"Course Data\",\"col\":4}},{\"id\":\"Iea0snm4Fg\",\"type\":\"card\",\"data\":{\"card_name\":\"Course Stats\",\"col\":4}},{\"id\":\"bZB7RqOl6a\",\"type\":\"card\",\"data\":{\"card_name\":\"Certification\",\"col\":4}}]", "content": "[{\"id\":\"jNO4sdKxHu\",\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\"><b>Get Started</b></span>\",\"col\":12}},{\"id\":\"5s0qRBc4rY\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/lms/courses\\\">Visit LMS Portal</a>\",\"col\":4}},{\"id\":\"lGMuNLpmv-\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/lms/courses/new/edit\\\">Create a Course</a>\",\"col\":4}},{\"id\":\"3TVyc9AkPy\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/app/web-page/new-web-page-1\\\">Setup a Home Page</a>\",\"col\":4}},{\"id\":\"9zcbqpu2gm\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"/app/lms-settings/LMS%20Settings\\\">LMS Settings</a>\",\"col\":4}},{\"id\":\"0ATmnKmXjc\",\"type\":\"paragraph\",\"data\":{\"text\":\"<a href=\\\"https://docs.frappe.io/learning\\\">Documentation</a>\",\"col\":4}},{\"id\":\"C128a4abjX\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"5q4sPiv2ci\",\"type\":\"chart\",\"data\":{\"chart_name\":\"Signups\",\"col\":6}},{\"id\":\"8NSaRaEV5u\",\"type\":\"chart\",\"data\":{\"chart_name\":\"Enrollments\",\"col\":6}},{\"id\":\"kMuzko0uAU\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"iuvIOHmztI\",\"type\":\"header\",\"data\":{\"text\":\"<span style=\\\"font-size: 18px;\\\"><b>Statistics</b></span>\",\"col\":12}},{\"id\":\"l0VTd66Uy2\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Users\",\"col\":4}},{\"id\":\"wAWZin1KKk\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Course\",\"col\":4}},{\"id\":\"RLrIlFx0Hd\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Enrollments\",\"col\":4}},{\"id\":\"OuhWkhCQmq\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Course Completed\",\"col\":4}},{\"id\":\"3g8QmNqUXG\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Certificate\",\"col\":4}},{\"id\":\"EZsdsujs8N\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Evaluation\",\"col\":4}},{\"id\":\"s-nfsFQbGV\",\"type\":\"spacer\",\"data\":{\"col\":12}},{\"id\":\"jeOBWBzHEa\",\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\"><b>Master</b></span>\",\"col\":12}},{\"id\":\"sVhgfS5GIh\",\"type\":\"card\",\"data\":{\"card_name\":\"Course Data\",\"col\":4}},{\"id\":\"Iea0snm4Fg\",\"type\":\"card\",\"data\":{\"card_name\":\"Course Stats\",\"col\":4}},{\"id\":\"bZB7RqOl6a\",\"type\":\"card\",\"data\":{\"card_name\":\"Certification\",\"col\":4}}]",
"creation": "2021-10-21 17:20:01.358903", "creation": "2021-10-21 17:20:01.358903",
"custom_blocks": [], "custom_blocks": [],
"docstatus": 0, "docstatus": 0,
@@ -145,7 +145,7 @@
"type": "Link" "type": "Link"
} }
], ],
"modified": "2024-06-27 21:19:06.273056", "modified": "2024-08-09 13:19:06.273056",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS", "name": "LMS",
@@ -213,4 +213,4 @@
} }
], ],
"title": "LMS" "title": "LMS"
} }

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
"name": "frappe_lms", "name": "frappe_lms",
"version": "1.0.0", "version": "1.0.0",
"description": "Easy to use, open-source, Learning Management System", "description": "Easy to use, open-source, Learning Management System",
"workspaces": [ "workspaces1": [
"frappe-ui", "frappe-ui",
"frontend" "frontend"
], ],
@@ -26,5 +26,8 @@
"devDependencies": { "devDependencies": {
"cypress": "^13.9.0", "cypress": "^13.9.0",
"cypress-file-upload": "^5.0.8" "cypress-file-upload": "^5.0.8"
},
"dependencies": {
"pre-commit": "^1.2.2"
} }
} }

511
yarn.lock

File diff suppressed because it is too large Load Diff