Compare commits
122 Commits
v2.0.0
...
revert-101
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cdd155f75 | ||
|
|
de8c907c51 | ||
|
|
237ff8db07 | ||
|
|
b5e67a25d2 | ||
|
|
9d2ef4929c | ||
|
|
050084e552 | ||
|
|
86e9739218 | ||
|
|
bd94890da7 | ||
|
|
965f6adb90 | ||
|
|
4979569cf3 | ||
|
|
0fd1cabd60 | ||
|
|
5c21a0532a | ||
|
|
e07aae3fb0 | ||
|
|
65d628ffc0 | ||
|
|
8dd480735c | ||
|
|
bf290bbf0a | ||
|
|
3c9059025b | ||
|
|
4b0413720b | ||
|
|
f8b4ff4bd3 | ||
|
|
3b8ff171f4 | ||
|
|
dec270a10b | ||
|
|
152a339c4e | ||
|
|
395fe700e0 | ||
|
|
ec25e895dc | ||
|
|
e02e4c7ab4 | ||
|
|
676f1a1f0e | ||
|
|
e69cc9af1a | ||
|
|
98b8464e1a | ||
|
|
0170fcc111 | ||
|
|
0be5439e81 | ||
|
|
63f857b8fc | ||
|
|
a3b8ed8f91 | ||
|
|
cdd46667f3 | ||
|
|
2f8acea988 | ||
|
|
75f0e5b9f1 | ||
|
|
ce51129e84 | ||
|
|
86aa8b0a2a | ||
|
|
aeae62a45c | ||
|
|
6b12df44a0 | ||
|
|
a710183bc7 | ||
|
|
ce75422126 | ||
|
|
669316ba14 | ||
|
|
6c18f9a02f | ||
|
|
363edb9a50 | ||
|
|
afbf64170a | ||
|
|
14f36d0c64 | ||
|
|
ceecab395b | ||
|
|
b8eb9fd717 | ||
|
|
230a52f06b | ||
|
|
3e82608d5f | ||
|
|
cf2c2345c3 | ||
|
|
05ebe4b787 | ||
|
|
a744a43d14 | ||
|
|
5abdbfec1f | ||
|
|
0335b3b4d0 | ||
|
|
703fafd6c3 | ||
|
|
b956c4e383 | ||
|
|
d0d1fb2c8c | ||
|
|
d18a6f6e73 | ||
|
|
2994144718 | ||
|
|
62ab853605 | ||
|
|
7f7986d77a | ||
|
|
61f01cc51b | ||
|
|
86af8c6301 | ||
|
|
f1b0fcfbfc | ||
|
|
ab5ce39645 | ||
|
|
685e09ce4b | ||
|
|
8ed4f775e5 | ||
|
|
a3a3085b1f | ||
|
|
ed97640107 | ||
|
|
a9e93a679b | ||
|
|
418c36c09f | ||
|
|
935f7f1f7b | ||
|
|
9a0056b6ca | ||
|
|
cd56da5d85 | ||
|
|
3a097d6b15 | ||
|
|
97d5d853fc | ||
|
|
8adfe247b2 | ||
|
|
afe7df2989 | ||
|
|
cdb028c69c | ||
|
|
9de1bf1020 | ||
|
|
eed330662b | ||
|
|
26db10bbe0 | ||
|
|
93e5cf1c25 | ||
|
|
14230bd588 | ||
|
|
699c821edd | ||
|
|
27ca13ece6 | ||
|
|
6e2376570b | ||
|
|
6820dfc820 | ||
|
|
471e7d9229 | ||
|
|
e0855a2c1b | ||
|
|
b20c4bf197 | ||
|
|
6a0b37a4d4 | ||
|
|
f7fd6916e2 | ||
|
|
30e61f4b7c | ||
|
|
48b37d58d8 | ||
|
|
b8c3bdc0b4 | ||
|
|
e96f18df7c | ||
|
|
7d15527831 | ||
|
|
794c0e760b | ||
|
|
e46a60d00a | ||
|
|
819aac70fd | ||
|
|
ed7db2d7c5 | ||
|
|
a450c846a6 | ||
|
|
fa774b0db2 | ||
|
|
98a56f9117 | ||
|
|
cbc4b8c59d | ||
|
|
69d266e018 | ||
|
|
4bc3ac1665 | ||
|
|
e0de9d70de | ||
|
|
493bab8163 | ||
|
|
25a2d82e82 | ||
|
|
0183677494 | ||
|
|
7ae9244896 | ||
|
|
15330cb41d | ||
|
|
166996d77a | ||
|
|
4943e0e902 | ||
|
|
1db6a8bfda | ||
|
|
57f43b256a | ||
|
|
23b2e8d682 | ||
|
|
6e1d62340f | ||
|
|
6ae1d92033 |
2
.github/helper/update_pot_file.sh
vendored
2
.github/helper/update_pot_file.sh
vendored
@@ -22,7 +22,7 @@ git config user.name "frappe-pr-bot"
|
||||
|
||||
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.
|
||||
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..."
|
||||
isodate=$(date -u +"%Y-%m-%d")
|
||||
|
||||
2
.github/workflows/generate-pot-file.yml
vendored
2
.github/workflows/generate-pot-file.yml
vendored
@@ -5,7 +5,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
regeneratee-pot-file:
|
||||
regenerate-pot-file:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
||||
27
.github/workflows/make_release_pr.yml
vendored
Normal file
27
.github/workflows/make_release_pr.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Create weekly release
|
||||
on:
|
||||
schedule:
|
||||
# 13:00 UTC -> 7pm IST on every Wednesday
|
||||
- cron: '30 4 * * 3'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: octokit/request-action@v2.x
|
||||
with:
|
||||
route: POST /repos/{owner}/{repo}/pulls
|
||||
owner: frappe
|
||||
repo: lms
|
||||
title: |-
|
||||
"chore: merge 'develop' into 'main'"
|
||||
body: "Automated weekly release"
|
||||
base: main
|
||||
head: develop
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
32
.github/workflows/on_release.yml
vendored
Normal file
32
.github/workflows/on_release.yml
vendored
Normal 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
39
.github/workflows/release_notes.yml
vendored
Normal 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 }}
|
||||
1
.github/workflows/ui-tests.yml
vendored
1
.github/workflows/ui-tests.yml
vendored
@@ -99,6 +99,7 @@ jobs:
|
||||
cd ~/frappe-bench/
|
||||
bench --site lms.test execute frappe.utils.install.complete_setup_wizard
|
||||
bench --site lms.test execute frappe.tests.ui_test_helpers.create_test_user
|
||||
bench --site lms.test set-password frappe@example.com admin
|
||||
|
||||
- name: cypress pre-requisites
|
||||
run: |
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ node_modules
|
||||
package-lock.json
|
||||
lms/public/frontend
|
||||
lms/www/lms.html
|
||||
frappe-ui
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "frappe-ui"]
|
||||
path = frappe-ui
|
||||
url = https://github.com/pateljannat/frappe-ui
|
||||
21
.releaserc
Normal file
21
.releaserc
Normal 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"
|
||||
]
|
||||
}
|
||||
@@ -35,7 +35,6 @@ bench new-site lms.localhost \
|
||||
bench --site lms.localhost install-app lms
|
||||
bench --site lms.localhost set-config developer_mode 1
|
||||
bench --site lms.localhost clear-cache
|
||||
bench --site lms.localhost set-config mute_emails 1
|
||||
bench use lms.localhost
|
||||
|
||||
bench start
|
||||
|
||||
Submodule frappe-ui deleted from aa44431c18
@@ -14,10 +14,10 @@
|
||||
"@editorjs/editorjs": "^2.29.0",
|
||||
"@editorjs/embed": "^2.7.0",
|
||||
"@editorjs/header": "^2.8.1",
|
||||
"@editorjs/image": "^2.9.0",
|
||||
"@editorjs/inline-code": "^1.5.0",
|
||||
"@editorjs/nested-list": "^1.4.2",
|
||||
"@editorjs/paragraph": "^2.11.3",
|
||||
"@editorjs/simple-image": "^1.6.0",
|
||||
"chart.js": "^4.4.1",
|
||||
"dayjs": "^1.11.6",
|
||||
"feather-icons": "^4.28.0",
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
<script setup>
|
||||
import { Toasts } from 'frappe-ui'
|
||||
import { Dialogs } from '@/utils/dialogs'
|
||||
import { computed, defineAsyncComponent } from 'vue'
|
||||
import { computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useScreenSize } from './utils/composables'
|
||||
import DesktopLayout from './components/DesktopLayout.vue'
|
||||
import MobileLayout from './components/MobileLayout.vue'
|
||||
import { stopSession } from '@/telemetry'
|
||||
import { init as initTelemetry } from '@/telemetry'
|
||||
|
||||
const screenSize = useScreenSize()
|
||||
|
||||
@@ -22,4 +24,12 @@ const Layout = computed(() => {
|
||||
return DesktopLayout
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await initTelemetry()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopSession()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
class="flex flex-col overflow-hidden"
|
||||
:class="isSidebarCollapsed ? 'items-center' : ''"
|
||||
>
|
||||
<UserDropdown class="p-2" :isCollapsed="isSidebarCollapsed" />
|
||||
<UserDropdown :isCollapsed="isSidebarCollapsed" />
|
||||
<div class="flex flex-col" v-if="sidebarSettings.data">
|
||||
<SidebarLink
|
||||
v-for="link in sidebarLinks"
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div
|
||||
v-if="sidebarSettings.data?.web_pages?.length || isModerator"
|
||||
class="pt-1"
|
||||
class="mt-4"
|
||||
>
|
||||
<div
|
||||
class="flex items-center justify-between pr-2 cursor-pointer"
|
||||
@@ -27,7 +27,7 @@
|
||||
>
|
||||
<div
|
||||
v-if="!isSidebarCollapsed"
|
||||
class="flex items-center text-sm font-medium text-gray-600"
|
||||
class="flex items-center text-sm text-gray-600 my-1"
|
||||
>
|
||||
<span class="grid h-5 w-6 flex-shrink-0 place-items-center">
|
||||
<ChevronRight
|
||||
@@ -36,7 +36,7 @@
|
||||
/>
|
||||
</span>
|
||||
<span class="ml-2">
|
||||
{{ __('Web Pages') }}
|
||||
{{ __('More') }}
|
||||
</span>
|
||||
</div>
|
||||
<Button v-if="isModerator" variant="ghost" @click="openPageModal()">
|
||||
@@ -100,7 +100,7 @@ import { ChevronRight, Plus } from 'lucide-vue-next'
|
||||
import { createResource, Button } from 'frappe-ui'
|
||||
import PageModal from '@/components/Modals/PageModal.vue'
|
||||
|
||||
const { user } = sessionStore()
|
||||
const { user, sidebarSettings } = sessionStore()
|
||||
const { userResource } = usersStore()
|
||||
const socket = inject('$socket')
|
||||
const unreadCount = ref(0)
|
||||
@@ -115,6 +115,20 @@ onMounted(() => {
|
||||
unreadNotifications.reload()
|
||||
})
|
||||
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({
|
||||
@@ -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) => {
|
||||
showPageModal.value = true
|
||||
pageToEdit.value = link
|
||||
|
||||
67
frontend/src/components/Apps.vue
Normal file
67
frontend/src/components/Apps.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<Popover placement="right-start" class="flex w-full">
|
||||
<template #target="{ togglePopover }">
|
||||
<button
|
||||
:class="[
|
||||
'group w-full flex h-7 items-center justify-between rounded px-2 text-base text-gray-800 hover:bg-gray-100',
|
||||
]"
|
||||
@click.prevent="togglePopover()"
|
||||
>
|
||||
<div class="flex gap-2">
|
||||
<LayoutGrid class="size-4 stroke-1.5" />
|
||||
<span class="whitespace-nowrap">
|
||||
{{ __('Apps') }}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronRight class="h-4 w-4 stroke-1.5" />
|
||||
</button>
|
||||
</template>
|
||||
<template #body>
|
||||
<div
|
||||
class="grid grid-cols-3 justify-between mx-3 p-2 rounded-lg border border-gray-100 bg-white shadow-xl"
|
||||
>
|
||||
<div v-for="app in apps.data" key="name">
|
||||
<a
|
||||
:href="app.route"
|
||||
class="flex flex-col gap-1.5 rounded justify-center items-center py-2 px-3 hover:bg-gray-100"
|
||||
>
|
||||
<img class="size-8" :src="app.logo" />
|
||||
<div class="text-sm" @click="app.onClick">
|
||||
{{ app.title }}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Popover>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Popover, createResource } from 'frappe-ui'
|
||||
import { LayoutGrid, ChevronRight } from 'lucide-vue-next'
|
||||
|
||||
const apps = createResource({
|
||||
url: 'frappe.apps.get_apps',
|
||||
cache: 'apps',
|
||||
auto: true,
|
||||
transform: (data) => {
|
||||
let _apps = [
|
||||
{
|
||||
name: 'frappe',
|
||||
logo: '/assets/lms/images/desk.png',
|
||||
title: __('Desk'),
|
||||
route: '/app',
|
||||
},
|
||||
]
|
||||
data.map((app) => {
|
||||
if (app.name === 'lms') return
|
||||
_apps.push({
|
||||
name: app.name,
|
||||
logo: app.logo,
|
||||
title: __(app.title),
|
||||
route: app.route,
|
||||
})
|
||||
})
|
||||
return _apps
|
||||
},
|
||||
})
|
||||
</script>
|
||||
@@ -3,6 +3,9 @@
|
||||
class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full"
|
||||
style="min-height: 150px"
|
||||
>
|
||||
<div class="text-lg leading-5 font-semibold mb-2">
|
||||
{{ batch.title }}
|
||||
</div>
|
||||
<Badge
|
||||
v-if="batch.seat_count && batch.seats_left > 0"
|
||||
theme="green"
|
||||
@@ -19,49 +22,48 @@
|
||||
>
|
||||
{{ __('Sold Out') }}
|
||||
</Badge>
|
||||
<div class="text-xl font-semibold mb-1">
|
||||
{{ batch.title }}
|
||||
</div>
|
||||
<div class="short-introduction">
|
||||
<div class="short-introduction text-sm text-gray-700">
|
||||
{{ batch.description }}
|
||||
</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 v-if="batch.amount" class="font-semibold text-lg">
|
||||
{{ batch.price }}
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<BookOpen class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||
<span> {{ batch.courses.length }} {{ __('Courses') }} </span>
|
||||
</div>
|
||||
<DateRange
|
||||
:startDate="batch.start_date"
|
||||
:endDate="batch.end_date"
|
||||
class="mb-3"
|
||||
class="text-sm text-gray-700"
|
||||
/>
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center text-sm text-gray-700">
|
||||
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||
<span>
|
||||
{{ formatTime(batch.start_time) }} - {{ formatTime(batch.end_time) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="batch.timezone" class="flex items-center">
|
||||
<Globe class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||
<div
|
||||
v-if="batch.timezone"
|
||||
class="flex items-center text-sm text-gray-700"
|
||||
>
|
||||
<Globe class="h-4 w-4 stroke-1.5 mr-2 text-gray-600" />
|
||||
<span>
|
||||
{{ batch.timezone }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="batch.instructors?.length" class="flex avatar-group overlap">
|
||||
<div
|
||||
class="h-6 mr-1"
|
||||
:class="{ 'avatar-group overlap': batch.instructors.length > 1 }"
|
||||
>
|
||||
<UserAvatar
|
||||
v-for="instructor in batch.instructors"
|
||||
:user="instructor"
|
||||
/>
|
||||
</div>
|
||||
<CourseInstructors :instructors="batch.instructors" />
|
||||
</div>
|
||||
<div
|
||||
v-if="batch.instructors?.length"
|
||||
class="flex avatar-group overlap mt-4"
|
||||
>
|
||||
<div
|
||||
class="h-6 mr-1"
|
||||
:class="{ 'avatar-group overlap': batch.instructors.length > 1 }"
|
||||
>
|
||||
<UserAvatar
|
||||
v-for="instructor in batch.instructors"
|
||||
:user="instructor"
|
||||
/>
|
||||
</div>
|
||||
<CourseInstructors :instructors="batch.instructors" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -88,7 +90,7 @@ const props = defineProps({
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
margin: 0.25rem 0 1.25rem;
|
||||
margin: 0.25rem 0 1rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<router-link
|
||||
v-if="isModerator"
|
||||
:to="{
|
||||
name: 'BatchCreation',
|
||||
name: 'BatchForm',
|
||||
params: {
|
||||
batchName: batch.data.name,
|
||||
},
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
>
|
||||
<li
|
||||
: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 },
|
||||
]"
|
||||
>
|
||||
@@ -87,7 +87,16 @@
|
||||
name="item-label"
|
||||
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>
|
||||
</li>
|
||||
</ComboboxOption>
|
||||
|
||||
@@ -118,6 +118,7 @@ const options = createResource({
|
||||
return {
|
||||
label: option.value,
|
||||
value: option.value,
|
||||
description: option.description,
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<script setup>
|
||||
import { Star } from 'lucide-vue-next'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
|
||||
@@ -2,28 +2,23 @@
|
||||
<div
|
||||
v-if="course.title"
|
||||
class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto"
|
||||
style="min-height: 320px"
|
||||
style="min-height: 350px"
|
||||
>
|
||||
<div
|
||||
class="course-image"
|
||||
:class="{ 'default-image': !course.image }"
|
||||
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
|
||||
>
|
||||
<div class="flex relative top-4 left-4 w-fit flex-wrap">
|
||||
<Badge
|
||||
v-if="course.featured"
|
||||
variant="subtle"
|
||||
theme="green"
|
||||
size="md"
|
||||
class="mr-2"
|
||||
>
|
||||
<div
|
||||
class="flex items-center flex-wrap space-y-1 space-x-1 relative top-4 px-2 w-fit"
|
||||
>
|
||||
<Badge v-if="course.featured" variant="subtle" theme="green" size="md">
|
||||
{{ __('Featured') }}
|
||||
</Badge>
|
||||
<Badge
|
||||
variant="outline"
|
||||
theme="gray"
|
||||
size="md"
|
||||
class="mr-2"
|
||||
v-for="tag in course.tags"
|
||||
>
|
||||
{{ tag }}
|
||||
@@ -77,7 +72,7 @@
|
||||
{{ course.title }}
|
||||
</div>
|
||||
|
||||
<div class="short-introduction">
|
||||
<div class="short-introduction text-gray-700 text-sm">
|
||||
{{ course.short_introduction }}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -63,10 +63,19 @@
|
||||
{{ __('Start Learning') }}
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
v-if="canGetCertificate"
|
||||
@click="fetchCertificate()"
|
||||
variant="subtle"
|
||||
class="w-full mt-2"
|
||||
size="md"
|
||||
>
|
||||
{{ __('Get Certificate') }}
|
||||
</Button>
|
||||
<router-link
|
||||
v-if="user?.data?.is_moderator || is_instructor()"
|
||||
:to="{
|
||||
name: 'CreateCourse',
|
||||
name: 'CourseForm',
|
||||
params: {
|
||||
courseName: course.data.name,
|
||||
},
|
||||
@@ -136,7 +145,7 @@ function enrollStudent() {
|
||||
})
|
||||
setTimeout(() => {
|
||||
window.location.href = `/login?redirect-to=${window.location.pathname}`
|
||||
}, 3000)
|
||||
}, 2000)
|
||||
} else {
|
||||
const enrollStudentResource = createResource({
|
||||
url: 'lms.lms.doctype.lms_enrollment.lms_enrollment.create_membership',
|
||||
@@ -174,4 +183,39 @@ const is_instructor = () => {
|
||||
})
|
||||
return user_is_instructor
|
||||
}
|
||||
|
||||
const canGetCertificate = computed(() => {
|
||||
if (
|
||||
props.course.data?.enable_certification &&
|
||||
props.course.data?.membership?.progress == 100
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
const certificate = createResource({
|
||||
url: 'lms.lms.doctype.lms_certificate.lms_certificate.create_certificate',
|
||||
makeParams(values) {
|
||||
return {
|
||||
course: values.course,
|
||||
}
|
||||
},
|
||||
onSuccess(data) {
|
||||
console.log(data)
|
||||
window.open(
|
||||
`/api/method/frappe.utils.print_format.download_pdf?doctype=LMS+Certificate&name=${
|
||||
data.name
|
||||
}&format=${encodeURIComponent(data.template)}`,
|
||||
'_blank'
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
const fetchCertificate = () => {
|
||||
certificate.submit({
|
||||
course: props.course.data?.name,
|
||||
member: user.data?.name,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<DisclosurePanel>
|
||||
<Draggable
|
||||
:list="chapter.lessons"
|
||||
:disabled="!allowEdit"
|
||||
item-key="name"
|
||||
group="items"
|
||||
@end="updateOutline"
|
||||
@@ -50,7 +51,7 @@
|
||||
<div class="outline-lesson pl-8 py-2 pr-4">
|
||||
<router-link
|
||||
:to="{
|
||||
name: allowEdit ? 'CreateLesson' : 'Lesson',
|
||||
name: allowEdit ? 'LessonForm' : 'Lesson',
|
||||
params: {
|
||||
courseName: courseName,
|
||||
chapterNumber: lesson.number.split('.')[0],
|
||||
@@ -89,7 +90,7 @@
|
||||
<div v-if="allowEdit" class="flex mt-2 mb-4 pl-8">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'CreateLesson',
|
||||
name: 'LessonForm',
|
||||
params: {
|
||||
courseName: courseName,
|
||||
chapterNumber: chapter.idx,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<Button v-if="!singleThread" class="float-right" @click="openTopicModal()">
|
||||
{{ __('New {0}').format(title) }}
|
||||
{{ __('New {0}').format(singularize(title)) }}
|
||||
</Button>
|
||||
<div class="text-xl font-semibold">
|
||||
{{ __(title) }}
|
||||
@@ -65,7 +65,7 @@
|
||||
<script setup>
|
||||
import { createResource, Button } from 'frappe-ui'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { timeAgo } from '../utils'
|
||||
import { singularize, timeAgo } from '../utils'
|
||||
import { ref, onMounted, inject } from 'vue'
|
||||
import DiscussionReplies from '@/components/DiscussionReplies.vue'
|
||||
import DiscussionModal from '@/components/Modals/DiscussionModal.vue'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="text-lg font-semibold">
|
||||
{{ __('Components') }}
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<div class="mt-5 space-y-4">
|
||||
<Tooltip
|
||||
:text="
|
||||
__(
|
||||
@@ -18,20 +18,31 @@
|
||||
<Select v-model="currentEditor" :options="getEditorOptions()" />
|
||||
</div>
|
||||
</Tooltip>
|
||||
<div class="flex mt-4">
|
||||
<div class="flex">
|
||||
<Link
|
||||
v-model="quiz"
|
||||
:value="quiz"
|
||||
class="flex-1"
|
||||
doctype="LMS Quiz"
|
||||
:label="__('Select a Quiz')"
|
||||
:label="__('Add an existing quiz')"
|
||||
@change="(option) => addQuiz(option)"
|
||||
/>
|
||||
<Button @click="addQuiz()" class="self-end ml-2">
|
||||
<template #icon>
|
||||
<Plus class="h-4 w-4 stroke-1.5" />
|
||||
</template>
|
||||
</Button>
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'QuizCreation',
|
||||
params: {
|
||||
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 class="mt-4">
|
||||
<div class="">
|
||||
<div class="text-xs text-gray-600 mb-1">
|
||||
{{ __('Add an image, video, pdf or audio.') }}
|
||||
</div>
|
||||
@@ -68,7 +79,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<div class="">
|
||||
<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)
|
||||
if (quiz.value) {
|
||||
if (value) {
|
||||
getCurrentEditor().blocks.insert('quiz', {
|
||||
quiz: quiz.value,
|
||||
quiz: value,
|
||||
})
|
||||
quiz.value = null
|
||||
}
|
||||
|
||||
183
frontend/src/components/Members.vue
Normal file
183
frontend/src/components/Members.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<div class="text-base p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<div class="font-semibold mb-1">
|
||||
{{ __(label) }}
|
||||
</div>
|
||||
<div class="text-xs text-gray-600">
|
||||
{{ __(description) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex item-center space-x-2">
|
||||
<FormControl
|
||||
v-model="search"
|
||||
:placeholder="__('Search')"
|
||||
type="text"
|
||||
:debounce="300"
|
||||
/>
|
||||
<Button @click="() => (showForm = true)">
|
||||
<template #icon>
|
||||
<Plus class="h-3 w-3 stroke-1.5" />
|
||||
</template>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="my-4">
|
||||
<!-- Form to add new member -->
|
||||
<div v-if="showForm" class="flex items-center space-x-2 mb-4">
|
||||
<FormControl
|
||||
v-model="member.email"
|
||||
:placeholder="__('Email')"
|
||||
type="email"
|
||||
class="w-full"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="member.first_name"
|
||||
:placeholder="__('First Name')"
|
||||
type="test"
|
||||
class="w-full"
|
||||
/>
|
||||
<Button @click="addMember()" variant="subtle">
|
||||
{{ __('Add') }}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!-- Member list -->
|
||||
<div
|
||||
v-for="member in memberList"
|
||||
class="grid grid-cols-5 grid-flow-row py-2 cursor-pointer"
|
||||
>
|
||||
<div
|
||||
@click="openProfile(member.username)"
|
||||
class="flex items-center space-x-2 col-span-2"
|
||||
>
|
||||
<Avatar
|
||||
:image="member.user_image"
|
||||
:label="member.full_name"
|
||||
size="sm"
|
||||
/>
|
||||
<div>
|
||||
{{ member.full_name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-gray-700 col-span-2">
|
||||
{{ member.name }}
|
||||
</div>
|
||||
<div class="text-sm text-gray-700 justify-self-end">
|
||||
{{ getRole(member.role) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="hasNextPage" class="flex justify-center">
|
||||
<Button variant="solid" @click="members.reload()">
|
||||
<template #prefix>
|
||||
<RefreshCw class="h-3 w-3 stroke-1.5" />
|
||||
</template>
|
||||
{{ __('Load More') }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { createResource, Avatar, Button, FormControl } from 'frappe-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ref, watch, reactive } from 'vue'
|
||||
import { RefreshCw, Plus } from 'lucide-vue-next'
|
||||
|
||||
const router = useRouter()
|
||||
const show = defineModel('show')
|
||||
const search = ref('')
|
||||
const start = ref(0)
|
||||
const memberList = ref([])
|
||||
const hasNextPage = ref(false)
|
||||
const showForm = ref(false)
|
||||
|
||||
const member = reactive({
|
||||
email: '',
|
||||
first_name: '',
|
||||
})
|
||||
|
||||
const props = defineProps({
|
||||
label: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
},
|
||||
})
|
||||
|
||||
const members = createResource({
|
||||
url: 'lms.lms.api.get_members',
|
||||
makeParams: () => {
|
||||
return {
|
||||
search: search.value,
|
||||
start: start.value,
|
||||
}
|
||||
},
|
||||
onSuccess(data) {
|
||||
memberList.value = memberList.value.concat(data)
|
||||
start.value = start.value + 20
|
||||
hasNextPage.value = data.length === 20
|
||||
},
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const openProfile = (username) => {
|
||||
show.value = false
|
||||
router.push({
|
||||
name: 'Profile',
|
||||
params: {
|
||||
username: username,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const newMember = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
makeParams(values) {
|
||||
return {
|
||||
doc: {
|
||||
doctype: 'User',
|
||||
first_name: member.first_name,
|
||||
email: member.email,
|
||||
},
|
||||
}
|
||||
},
|
||||
auto: false,
|
||||
onSuccess(data) {
|
||||
show.value = false
|
||||
router.push({
|
||||
name: 'Profile',
|
||||
params: {
|
||||
username: data.username,
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const addMember = () => {
|
||||
newMember.reload()
|
||||
}
|
||||
|
||||
watch(search, () => {
|
||||
memberList.value = []
|
||||
start.value = 0
|
||||
members.reload()
|
||||
})
|
||||
|
||||
const getRole = (role) => {
|
||||
const map = {
|
||||
'LMS Student': 'Student',
|
||||
'Course Creator': 'Instructor',
|
||||
Moderator: 'Moderator',
|
||||
'Batch Evaluator': 'Evaluator',
|
||||
}
|
||||
return map[role]
|
||||
}
|
||||
</script>
|
||||
@@ -4,14 +4,14 @@
|
||||
<slot />
|
||||
</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"
|
||||
:style="{
|
||||
gridTemplateColumns: `repeat(${tabs.length}, minmax(0, 1fr))`,
|
||||
gridTemplateColumns: `repeat(${sidebarLinks.length}, minmax(0, 1fr))`,
|
||||
}"
|
||||
>
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
v-for="tab in sidebarLinks"
|
||||
:key="tab.label"
|
||||
:class="isVisible(tab) ? 'block' : 'hidden'"
|
||||
class="flex flex-col items-center justify-center py-3 transition active:scale-95"
|
||||
@@ -29,21 +29,38 @@
|
||||
<script setup>
|
||||
import { getSidebarLinks } from '../utils'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, onMounted } from 'vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { usersStore } from '@/stores/user'
|
||||
import * as icons from 'lucide-vue-next'
|
||||
|
||||
const { logout, user } = sessionStore()
|
||||
const { logout, user, sidebarSettings } = sessionStore()
|
||||
let { isLoggedIn } = sessionStore()
|
||||
const router = useRouter()
|
||||
let { userResource } = usersStore()
|
||||
const sidebarLinks = ref(getSidebarLinks())
|
||||
|
||||
const tabs = computed(() => {
|
||||
let links = getSidebarLinks()
|
||||
onMounted(() => {
|
||||
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) {
|
||||
links.push({
|
||||
sidebarLinks.value.push({
|
||||
label: 'Profile',
|
||||
icon: 'UserRound',
|
||||
activeFor: [
|
||||
@@ -54,18 +71,17 @@ const tabs = computed(() => {
|
||||
'ProfileRoles',
|
||||
],
|
||||
})
|
||||
links.push({
|
||||
sidebarLinks.value.push({
|
||||
label: 'Log out',
|
||||
icon: 'LogOut',
|
||||
})
|
||||
} else {
|
||||
links.push({
|
||||
sidebarLinks.value.push({
|
||||
label: 'Log in',
|
||||
icon: 'LogIn',
|
||||
})
|
||||
}
|
||||
return links
|
||||
})
|
||||
}
|
||||
|
||||
let isActive = (tab) => {
|
||||
return tab.activeFor?.includes(router.currentRoute.value.name)
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import { Dialog, FormControl, createResource } from 'frappe-ui'
|
||||
import { defineModel, reactive, watch, inject } from 'vue'
|
||||
import { createToast, formatTime } from '@/utils/'
|
||||
import { defineModel, reactive, watch } from 'vue'
|
||||
import { createToast } from '@/utils/'
|
||||
import { capture } from '@/telemetry'
|
||||
|
||||
const show = defineModel()
|
||||
const outline = defineModel('outline')
|
||||
@@ -91,6 +92,7 @@ const addChapter = (close) => {
|
||||
}
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
capture('chapter_created')
|
||||
chapterReference.submit(
|
||||
{ name: data.name },
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:options="{
|
||||
title: props.title,
|
||||
title: singularize(props.title),
|
||||
size: '2xl',
|
||||
actions: [
|
||||
{
|
||||
@@ -35,8 +35,8 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
|
||||
import { reactive, defineModel, computed } from 'vue'
|
||||
import { showToast } from '@/utils'
|
||||
import { reactive, defineModel } from 'vue'
|
||||
import { showToast, singularize } from '@/utils'
|
||||
|
||||
const topics = defineModel('reloadTopics')
|
||||
|
||||
|
||||
@@ -130,11 +130,14 @@ function submitEvaluation(close) {
|
||||
close()
|
||||
},
|
||||
onError(err) {
|
||||
let message = err.messages?.[0] || err
|
||||
let unavailabilityMessage = message.includes('unavailable')
|
||||
|
||||
createToast({
|
||||
title: 'Error',
|
||||
text: err.messages?.[0] || err,
|
||||
icon: 'x',
|
||||
iconClasses: 'bg-red-600 text-white rounded-md p-px',
|
||||
title: unavailabilityMessage ? 'Evaluator is Unavailable' : 'Error',
|
||||
text: message,
|
||||
icon: unavailabilityMessage ? 'alert-circle' : 'x',
|
||||
iconClasses: 'bg-yellow-600 text-white rounded-md p-px',
|
||||
position: 'top-center',
|
||||
timeout: 10,
|
||||
})
|
||||
|
||||
348
frontend/src/components/Modals/Question.vue
Normal file
348
frontend/src/components/Modals/Question.vue
Normal file
@@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<Dialog v-model="show" :options="dialogOptions">
|
||||
<template #body-content>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-if="!editMode"
|
||||
class="flex items-center text-xs text-gray-700 space-x-5"
|
||||
>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input
|
||||
type="radio"
|
||||
id="existing"
|
||||
value="existing"
|
||||
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 v-if="questionType == 'new' || editMode" class="space-y-2">
|
||||
<div>
|
||||
<label class="block text-xs text-gray-600 mb-1">
|
||||
{{ __('Question') }}
|
||||
</label>
|
||||
<TextEditor
|
||||
:content="question.question"
|
||||
@change="(val) => (question.question = val)"
|
||||
:editable="true"
|
||||
:fixedMenu="true"
|
||||
editorClass="prose-sm max-w-none border-b border-x bg-gray-100 rounded-b-md py-1 px-2 min-h-[7rem]"
|
||||
/>
|
||||
</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
|
||||
:label="__('Possibility') + ' ' + n"
|
||||
v-model="question[`possibility_${n}`]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="questionType == 'existing'" class="space-y-2">
|
||||
<Link
|
||||
v-model="existingQuestion.question"
|
||||
:label="__('Select a question')"
|
||||
doctype="LMS Question"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="existingQuestion.marks"
|
||||
:label="__('Marks')"
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
|
||||
import { computed, watch, reactive, ref } from 'vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import { showToast } from '@/utils'
|
||||
|
||||
const show = defineModel()
|
||||
const quiz = defineModel('quiz')
|
||||
const questionType = ref(null)
|
||||
const editMode = ref(false)
|
||||
|
||||
const existingQuestion = reactive({
|
||||
question: '',
|
||||
marks: 0,
|
||||
})
|
||||
const question = reactive({
|
||||
question: '',
|
||||
type: 'Choices',
|
||||
marks: 0,
|
||||
})
|
||||
|
||||
const populateFields = () => {
|
||||
let fields = ['option', 'is_correct', 'explanation', 'possibility']
|
||||
let counter = 1
|
||||
fields.forEach((field) => {
|
||||
while (counter <= 4) {
|
||||
question[`${field}_${counter}`] = field === 'is_correct' ? false : ''
|
||||
counter++
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
populateFields()
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: __('Add a new question'),
|
||||
},
|
||||
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(() => {
|
||||
return {
|
||||
title: __(props.title),
|
||||
size: 'xl',
|
||||
actions: [
|
||||
{
|
||||
label: __('Submit'),
|
||||
variant: 'solid',
|
||||
onClick: (close) => {
|
||||
submitQuestion(close)
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
})
|
||||
</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>
|
||||
279
frontend/src/components/Modals/Settings.vue
Normal file
279
frontend/src/components/Modals/Settings.vue
Normal file
@@ -0,0 +1,279 @@
|
||||
<template>
|
||||
<Dialog v-model="show" :options="{ size: '3xl' }">
|
||||
<template #body>
|
||||
<div class="flex h-[calc(100vh_-_8rem)]">
|
||||
<div class="flex w-52 shrink-0 flex-col bg-gray-50 p-2">
|
||||
<h1 class="mb-3 px-2 pt-2 text-lg font-semibold">
|
||||
{{ __('Settings') }}
|
||||
</h1>
|
||||
<div v-for="tab in tabs">
|
||||
<div
|
||||
v-if="!tab.hideLabel"
|
||||
class="mb-2 mt-3 flex cursor-pointer gap-1.5 px-1 text-base font-medium text-gray-600 transition-all duration-300 ease-in-out"
|
||||
>
|
||||
<span>{{ __(tab.label) }}</span>
|
||||
</div>
|
||||
<nav class="space-y-1">
|
||||
<SidebarLink
|
||||
v-for="item in tab.items"
|
||||
:link="item"
|
||||
class="w-full"
|
||||
:class="
|
||||
activeTab?.label == item.label
|
||||
? 'bg-white shadow-sm'
|
||||
: 'hover:bg-gray-100'
|
||||
"
|
||||
@click="activeTab = item"
|
||||
/>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="activeTab && data.doc"
|
||||
class="flex flex-1 flex-col overflow-y-auto"
|
||||
>
|
||||
<Members
|
||||
v-if="activeTab.label === 'Members'"
|
||||
:label="activeTab.label"
|
||||
:description="activeTab.description"
|
||||
v-model:show="show"
|
||||
/>
|
||||
<SettingDetails
|
||||
v-else
|
||||
:fields="activeTab.fields"
|
||||
:label="activeTab.label"
|
||||
:description="activeTab.description"
|
||||
:data="data"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Dialog, createDocumentResource } from 'frappe-ui'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import SettingDetails from '../SettingDetails.vue'
|
||||
import SidebarLink from '@/components/SidebarLink.vue'
|
||||
import Members from '@/components/Members.vue'
|
||||
|
||||
const show = defineModel()
|
||||
const doctype = ref('LMS Settings')
|
||||
const activeTab = ref(null)
|
||||
|
||||
const data = createDocumentResource({
|
||||
doctype: doctype.value,
|
||||
name: doctype.value,
|
||||
fields: ['*'],
|
||||
cache: doctype.value,
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const tabs = computed(() => {
|
||||
let _tabs = [
|
||||
{
|
||||
label: 'Settings',
|
||||
hideLabel: true,
|
||||
items: [
|
||||
{
|
||||
label: 'Members',
|
||||
description: 'Manage the members of your learning system',
|
||||
icon: 'UserRoundPlus',
|
||||
},
|
||||
{
|
||||
label: 'Payment Gateway',
|
||||
icon: 'DollarSign',
|
||||
description:
|
||||
'Configure the payment gateway and other payment related settings',
|
||||
fields: [
|
||||
{
|
||||
label: 'Razorpay Key',
|
||||
name: 'razorpay_key',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
label: 'Razorpay Secret',
|
||||
name: 'razorpay_secret',
|
||||
type: 'password',
|
||||
},
|
||||
{
|
||||
label: 'Default Currency',
|
||||
name: 'default_currency',
|
||||
type: 'Link',
|
||||
doctype: 'Currency',
|
||||
},
|
||||
{
|
||||
type: 'Column Break',
|
||||
},
|
||||
{
|
||||
label: 'Apply GST for India',
|
||||
name: 'apply_gst',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Show USD equivalent amount',
|
||||
name: 'show_usd_equivalent',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Apply rounding on equivalent',
|
||||
name: 'apply_rounding',
|
||||
type: 'checkbox',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Settings',
|
||||
hideLabel: true,
|
||||
items: [
|
||||
{
|
||||
label: 'Sidebar',
|
||||
icon: 'PanelLeftIcon',
|
||||
description: 'Customize the sidebar as per your needs',
|
||||
fields: [
|
||||
{
|
||||
label: 'Courses',
|
||||
name: 'courses',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Batches',
|
||||
name: 'batches',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Certified Participants',
|
||||
name: 'certified_participants',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
type: 'Column Break',
|
||||
},
|
||||
{
|
||||
label: 'Jobs',
|
||||
name: 'jobs',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Statistics',
|
||||
name: 'statistics',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Notifications',
|
||||
name: 'notifications',
|
||||
type: 'checkbox',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Settings',
|
||||
hideLabel: true,
|
||||
items: [
|
||||
{
|
||||
label: 'Email Templates',
|
||||
icon: 'MailPlus',
|
||||
description: 'Create email templates with the content you want',
|
||||
fields: [
|
||||
{
|
||||
label: 'Batch Confirmation Template',
|
||||
name: 'batch_confirmation_template',
|
||||
doctype: 'Email Template',
|
||||
type: 'Link',
|
||||
},
|
||||
{
|
||||
label: 'Certification Template',
|
||||
name: 'certification_template',
|
||||
doctype: 'Email Template',
|
||||
type: 'Link',
|
||||
},
|
||||
{
|
||||
label: 'Assignment Submission Template',
|
||||
name: 'assignment_submission_template',
|
||||
doctype: 'Email Template',
|
||||
type: 'Link',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Settings',
|
||||
hideLabel: true,
|
||||
items: [
|
||||
{
|
||||
label: 'Signup',
|
||||
icon: 'LogIn',
|
||||
description:
|
||||
'Customize the signup page to inform users about your terms and policies',
|
||||
fields: [
|
||||
{
|
||||
label: 'Show terms of use on signup',
|
||||
name: 'terms_of_use',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Terms of Use Page',
|
||||
name: 'terms_page',
|
||||
type: 'Link',
|
||||
doctype: 'Web Page',
|
||||
},
|
||||
{
|
||||
label: 'Show privacy policy on signup',
|
||||
name: 'privacy_policy',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Privacy Policy Page',
|
||||
name: 'privacy_policy_page',
|
||||
type: 'Link',
|
||||
doctype: 'Web Page',
|
||||
},
|
||||
{
|
||||
type: 'Column Break',
|
||||
},
|
||||
{
|
||||
label: 'Show cookie policy on signup',
|
||||
name: 'cookie_policy',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Cookie Policy Page',
|
||||
name: 'cookie_policy_page',
|
||||
type: 'Link',
|
||||
doctype: 'Web Page',
|
||||
},
|
||||
{
|
||||
label: 'Ask user category during signup',
|
||||
name: 'user_category',
|
||||
type: 'checkbox',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
return _tabs.map((tab) => {
|
||||
tab.items = tab.items.filter((item) => {
|
||||
if (item.condition) {
|
||||
return item.condition()
|
||||
}
|
||||
return true
|
||||
})
|
||||
return tab
|
||||
})
|
||||
})
|
||||
|
||||
watch(show, () => {
|
||||
if (show.value) {
|
||||
activeTab.value = tabs.value[0].items[0]
|
||||
} else {
|
||||
activeTab.value = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -3,9 +3,7 @@
|
||||
<div class="bg-blue-100 py-2 px-2 mb-4 rounded-md text-sm text-blue-800">
|
||||
<div class="leading-relaxed">
|
||||
{{
|
||||
__('This quiz consists of {0} questions.').format(
|
||||
quiz.data.questions.length
|
||||
)
|
||||
__('This quiz consists of {0} questions.').format(questions.length)
|
||||
}}
|
||||
</div>
|
||||
<div v-if="quiz.data.passing_percentage" class="leading-relaxed">
|
||||
@@ -59,7 +57,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!quizSubmission.data">
|
||||
<div v-for="(question, qtidx) in quiz.data.questions">
|
||||
<div v-for="(question, qtidx) in questions">
|
||||
<div
|
||||
v-if="qtidx == activeQuestion - 1 && questionDetails.data"
|
||||
class="border rounded-md p-5"
|
||||
@@ -166,7 +164,7 @@
|
||||
{{
|
||||
__('Question {0} of {1}').format(
|
||||
activeQuestion,
|
||||
quiz.data.questions.length
|
||||
questions.length
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
@@ -179,7 +177,7 @@
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
v-else-if="activeQuestion != quiz.data.questions.length"
|
||||
v-else-if="activeQuestion != questions.length"
|
||||
@click="nextQuetion()"
|
||||
>
|
||||
<span>
|
||||
@@ -250,6 +248,7 @@ const activeQuestion = ref(0)
|
||||
const currentQuestion = ref('')
|
||||
const selectedOptions = reactive([0, 0, 0, 0])
|
||||
const showAnswers = reactive([])
|
||||
let questions = reactive([])
|
||||
const possibleAnswer = ref(null)
|
||||
|
||||
const props = defineProps({
|
||||
@@ -270,15 +269,30 @@ const quiz = createResource({
|
||||
cache: ['quiz', props.quizName],
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
if (data.shuffle_questions) {
|
||||
data.questions = data.questions.sort(() => Math.random() - 0.5)
|
||||
}
|
||||
if (data.limit_questions_to) {
|
||||
data.questions = data.questions.slice(0, data.limit_questions_to)
|
||||
}
|
||||
populateQuestions()
|
||||
},
|
||||
})
|
||||
|
||||
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({
|
||||
url: 'frappe.client.get_list',
|
||||
makeParams(values) {
|
||||
@@ -310,7 +324,7 @@ const attempts = createResource({
|
||||
watch(
|
||||
() => quiz.data,
|
||||
() => {
|
||||
if (quiz.data) {
|
||||
if (quiz.data && quiz.data.max_attempts) {
|
||||
attempts.reload()
|
||||
resetQuiz()
|
||||
}
|
||||
@@ -425,7 +439,7 @@ const checkAnswer = () => {
|
||||
const addToLocalStorage = () => {
|
||||
let quizData = JSON.parse(localStorage.getItem(quiz.data.title))
|
||||
let questionData = {
|
||||
question_index: activeQuestion.value,
|
||||
question_name: currentQuestion.value,
|
||||
answer: getAnswers().join(),
|
||||
is_correct: showAnswers.filter((answer) => {
|
||||
return answer != undefined
|
||||
@@ -464,7 +478,7 @@ const submitQuiz = () => {
|
||||
|
||||
const createSubmission = () => {
|
||||
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])
|
||||
showAnswers.length = 0
|
||||
quizSubmission.reset()
|
||||
populateQuestions()
|
||||
}
|
||||
|
||||
const getSubmissionColumns = () => {
|
||||
|
||||
96
frontend/src/components/SettingDetails.vue
Normal file
96
frontend/src/components/SettingDetails.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div class="flex flex-col justify-between h-full p-4">
|
||||
<div>
|
||||
<div class="font-semibold mb-1">
|
||||
{{ __(label) }}
|
||||
</div>
|
||||
<div class="text-xs text-gray-600">
|
||||
{{ __(description) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex space-x-8 my-5">
|
||||
<div v-for="(column, index) in columns" :key="index">
|
||||
<div class="flex flex-col space-y-4 w-60">
|
||||
<div v-for="field in column">
|
||||
<Link
|
||||
v-if="field.type == 'Link'"
|
||||
v-model="field.value"
|
||||
:doctype="field.doctype"
|
||||
:label="field.label"
|
||||
/>
|
||||
<FormControl
|
||||
v-else
|
||||
:key="field.name"
|
||||
v-model="field.value"
|
||||
:label="field.label"
|
||||
:type="field.type"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row-reverse mt-auto">
|
||||
<Button variant="solid" :loading="data.save.loading" @click="update">
|
||||
{{ __('Update') }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { FormControl, Button } from 'frappe-ui'
|
||||
import { computed } from 'vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
|
||||
const props = defineProps({
|
||||
fields: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
})
|
||||
|
||||
const columns = computed(() => {
|
||||
const cols = []
|
||||
let currentColumn = []
|
||||
|
||||
props.fields.forEach((field) => {
|
||||
if (field.type === 'Column Break') {
|
||||
if (currentColumn.length > 0) {
|
||||
cols.push(currentColumn)
|
||||
currentColumn = []
|
||||
}
|
||||
} else {
|
||||
if (field.type == 'checkbox') {
|
||||
field.value = props.data.doc[field.name] ? true : false
|
||||
} else {
|
||||
field.value = props.data.doc[field.name]
|
||||
}
|
||||
currentColumn.push(field)
|
||||
}
|
||||
})
|
||||
|
||||
if (currentColumn.length > 0) {
|
||||
cols.push(currentColumn)
|
||||
}
|
||||
|
||||
return cols
|
||||
})
|
||||
|
||||
const update = () => {
|
||||
props.fields.forEach((f) => {
|
||||
props.data.doc[f.name] = f.value
|
||||
})
|
||||
props.data.save.submit()
|
||||
}
|
||||
</script>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Dropdown :options="userDropdownOptions">
|
||||
<Dropdown class="p-2" :options="userDropdownOptions">
|
||||
<template v-slot="{ open }">
|
||||
<button
|
||||
class="flex h-12 py-2 items-center rounded-md duration-300 ease-in-out"
|
||||
@@ -56,24 +56,33 @@
|
||||
</button>
|
||||
</template>
|
||||
</Dropdown>
|
||||
<SettingsModal
|
||||
v-if="userResource.data?.is_moderator"
|
||||
v-model="showSettingsModal"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import LMSLogo from '@/components/Icons/LMSLogo.vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { Dropdown } from 'frappe-ui'
|
||||
import Apps from '@/components/Apps.vue'
|
||||
import {
|
||||
ChevronDown,
|
||||
LogIn,
|
||||
LogOut,
|
||||
User,
|
||||
ArrowRightLeft,
|
||||
Settings,
|
||||
} from 'lucide-vue-next'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { convertToTitleCase } from '../utils'
|
||||
import { usersStore } from '@/stores/user'
|
||||
import { ref, markRaw } from 'vue'
|
||||
import SettingsModal from '@/components/Modals/Settings.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const showSettingsModal = ref(false)
|
||||
const { logout, branding } = sessionStore()
|
||||
let { userResource } = usersStore()
|
||||
let { isLoggedIn } = sessionStore()
|
||||
@@ -97,11 +106,7 @@ const userDropdownOptions = [
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: ArrowRightLeft,
|
||||
label: 'Switch to Desk',
|
||||
onClick: () => {
|
||||
window.location.href = '/app'
|
||||
},
|
||||
component: markRaw(Apps),
|
||||
condition: () => {
|
||||
let cookies = new URLSearchParams(document.cookie.split('; ').join('&'))
|
||||
let system_user = cookies.get('system_user')
|
||||
@@ -109,6 +114,16 @@ const userDropdownOptions = [
|
||||
else return false
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: Settings,
|
||||
label: 'Settings',
|
||||
onClick: () => {
|
||||
showSettingsModal.value = true
|
||||
},
|
||||
condition: () => {
|
||||
return userResource.data?.is_moderator
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: LogOut,
|
||||
label: 'Log out',
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<template>
|
||||
<div ref="videoContainer" class="video-block group relative">
|
||||
<video @timeupdate="updateTime" @ended="videoEnded" class="rounded-lg">
|
||||
<video
|
||||
@timeupdate="updateTime"
|
||||
@ended="videoEnded"
|
||||
class="rounded-lg border border-gray-100"
|
||||
>
|
||||
<source :src="fileURL" :type="type" />
|
||||
</video>
|
||||
<div
|
||||
class="flex items-center space-x-2 bg-gray-200 rounded-lg p-0.5 absolute bottom-3 w-[98%] left-0 right-0 mx-auto"
|
||||
class="flex items-center space-x-2 bg-gray-200 rounded-md p-0.5 absolute bottom-3 w-[98%] left-0 right-0 mx-auto"
|
||||
>
|
||||
<Button variant="ghost">
|
||||
<template #icon>
|
||||
|
||||
@@ -236,6 +236,7 @@ import MultiSelect from '@/components/Controls/MultiSelect.vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getFileSize, showToast } from '../utils'
|
||||
import { X, FileText } from 'lucide-vue-next'
|
||||
import { capture } from '@/telemetry'
|
||||
|
||||
const router = useRouter()
|
||||
const user = inject('$user')
|
||||
@@ -274,6 +275,8 @@ onMounted(() => {
|
||||
if (!user.data) window.location.href = '/login'
|
||||
if (props.batchName != 'new') {
|
||||
batchDetail.reload()
|
||||
} else {
|
||||
capture('batch_form_opened')
|
||||
}
|
||||
window.addEventListener('keydown', keyboardShortcut)
|
||||
})
|
||||
@@ -377,6 +380,7 @@ const createNewBatch = () => {
|
||||
{},
|
||||
{
|
||||
onSuccess(data) {
|
||||
capture('batch_created')
|
||||
router.push({
|
||||
name: 'BatchDetail',
|
||||
params: {
|
||||
@@ -447,7 +451,7 @@ const breadcrumbs = computed(() => {
|
||||
}
|
||||
crumbs.push({
|
||||
label: props.batchName == 'new' ? 'New Batch' : 'Edit Batch',
|
||||
route: { name: 'BatchCreation', params: { batchName: props.batchName } },
|
||||
route: { name: 'BatchForm', params: { batchName: props.batchName } },
|
||||
})
|
||||
return crumbs
|
||||
})
|
||||
@@ -5,19 +5,27 @@
|
||||
>
|
||||
<Breadcrumbs
|
||||
class="h-7"
|
||||
:items="[{ label: __('All Batches'), route: { name: 'Batches' } }]"
|
||||
:items="[{ label: __('Batches'), route: { name: 'Batches' } }]"
|
||||
/>
|
||||
<div class="flex">
|
||||
<div class="flex space-x-2">
|
||||
<div class="w-40">
|
||||
<Select
|
||||
v-if="categories.data?.length"
|
||||
v-model="currentCategory"
|
||||
:options="categories.data"
|
||||
:placeholder="__('Filter')"
|
||||
/>
|
||||
</div>
|
||||
<router-link
|
||||
v-if="user.data?.is_moderator"
|
||||
:to="{
|
||||
name: 'BatchCreation',
|
||||
name: 'BatchForm',
|
||||
params: { batchName: 'new' },
|
||||
}"
|
||||
>
|
||||
<Button variant="solid">
|
||||
<template #prefix>
|
||||
<Plus class="h-4 w-4" />
|
||||
<Plus class="h-4 w-4 stroke-1.5" />
|
||||
</template>
|
||||
{{ __('New Batch') }}
|
||||
</Button>
|
||||
@@ -33,7 +41,7 @@
|
||||
</div>
|
||||
<Tabs
|
||||
v-model="tabIndex"
|
||||
:tabs="tabs"
|
||||
:tabs="makeTabs"
|
||||
tablistClass="overflow-x-visible flex-wrap !gap-3 md:flex-nowrap"
|
||||
>
|
||||
<template #tab="{ tab, selected }">
|
||||
@@ -87,13 +95,29 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { createListResource, Breadcrumbs, Button, Tabs, Badge } from 'frappe-ui'
|
||||
import {
|
||||
createListResource,
|
||||
createResource,
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Tabs,
|
||||
Badge,
|
||||
Select,
|
||||
} from 'frappe-ui'
|
||||
import { Plus } from 'lucide-vue-next'
|
||||
import BatchCard from '@/components/BatchCard.vue'
|
||||
import { inject, ref, computed } from 'vue'
|
||||
import { inject, ref, computed, onMounted, watch } from 'vue'
|
||||
import { updateDocumentTitle } from '@/utils'
|
||||
|
||||
const user = inject('$user')
|
||||
const currentCategory = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
let queries = new URLSearchParams(location.search)
|
||||
if (queries.has('category')) {
|
||||
currentCategory.value = queries.get('category')
|
||||
}
|
||||
})
|
||||
|
||||
const batches = createListResource({
|
||||
doctype: 'LMS Batch',
|
||||
@@ -102,35 +126,76 @@ const batches = createListResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const tabIndex = ref(0)
|
||||
const tabs = [
|
||||
{
|
||||
label: 'Upcoming',
|
||||
batches: computed(() => batches.data?.upcoming || []),
|
||||
count: computed(() => batches.data?.upcoming?.length),
|
||||
const categories = createResource({
|
||||
url: 'lms.lms.api.get_categories',
|
||||
makeParams() {
|
||||
return {
|
||||
doctype: 'LMS Batch',
|
||||
filters: {
|
||||
published: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
]
|
||||
cache: ['batchCategories'],
|
||||
auto: true,
|
||||
transform(data) {
|
||||
data.unshift({
|
||||
label: '',
|
||||
value: null,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
if (user.data?.is_moderator) {
|
||||
const tabIndex = ref(0)
|
||||
let tabs
|
||||
|
||||
const makeTabs = computed(() => {
|
||||
tabs = []
|
||||
addToTabs('Upcoming')
|
||||
|
||||
if (user.data?.is_moderator) {
|
||||
addToTabs('Archived')
|
||||
addToTabs('Private')
|
||||
}
|
||||
|
||||
if (user.data) {
|
||||
addToTabs('Enrolled')
|
||||
}
|
||||
|
||||
return tabs
|
||||
})
|
||||
|
||||
const getBatches = (type) => {
|
||||
if (currentCategory.value && currentCategory.value != '') {
|
||||
return batches.data[type].filter(
|
||||
(batch) => batch.category == currentCategory.value
|
||||
)
|
||||
}
|
||||
return batches.data[type]
|
||||
}
|
||||
|
||||
const addToTabs = (label) => {
|
||||
let batches = getBatches(label.toLowerCase().split(' ').join('_'))
|
||||
tabs.push({
|
||||
label: 'Archived',
|
||||
batches: computed(() => batches.data?.archived),
|
||||
count: computed(() => batches.data?.archived?.length),
|
||||
})
|
||||
tabs.push({
|
||||
label: 'Private',
|
||||
batches: computed(() => batches.data?.private),
|
||||
count: computed(() => batches.data?.private?.length),
|
||||
})
|
||||
}
|
||||
if (user.data) {
|
||||
tabs.push({
|
||||
label: 'Enrolled',
|
||||
batches: computed(() => batches.data?.enrolled),
|
||||
count: computed(() => batches.data?.enrolled?.length),
|
||||
label,
|
||||
batches: computed(() => batches),
|
||||
count: computed(() => batches.length),
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => currentCategory.value,
|
||||
() => {
|
||||
let queries = new URLSearchParams(location.search)
|
||||
if (currentCategory.value) {
|
||||
queries.set('category', currentCategory.value)
|
||||
} else {
|
||||
queries.delete('category')
|
||||
}
|
||||
history.pushState(null, '', `${location.pathname}?${queries.toString()}`)
|
||||
}
|
||||
)
|
||||
|
||||
const pageMeta = computed(() => {
|
||||
return {
|
||||
title: 'Batches',
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
<div>
|
||||
<FormControl
|
||||
type="text"
|
||||
placeholder="Search Participants"
|
||||
placeholder="Search"
|
||||
v-model="searchQuery"
|
||||
@input="participants.reload()"
|
||||
class="w-40"
|
||||
>
|
||||
<template #prefix>
|
||||
<Search class="w-4 stroke-1.5 text-gray-600" name="search" />
|
||||
@@ -18,7 +19,10 @@
|
||||
</header>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 m-5">
|
||||
<div v-if="participants.data" v-for="participant in participants.data">
|
||||
<div
|
||||
v-if="participants.data?.length"
|
||||
v-for="participant in participantsList"
|
||||
>
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'Profile',
|
||||
@@ -59,12 +63,7 @@ const searchQuery = ref('')
|
||||
const participants = createResource({
|
||||
url: 'lms.lms.api.get_certified_participants',
|
||||
method: 'GET',
|
||||
debounce: 300,
|
||||
makeParams(values) {
|
||||
return {
|
||||
search_query: searchQuery.value,
|
||||
}
|
||||
},
|
||||
cache: 'certified-participants',
|
||||
auto: true,
|
||||
})
|
||||
|
||||
@@ -79,5 +78,16 @@ const pageMeta = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const participantsList = computed(() => {
|
||||
if (searchQuery.value) {
|
||||
return participants.data.filter((participant) => {
|
||||
return participant.full_name
|
||||
.toLowerCase()
|
||||
.includes(searchQuery.value.toLowerCase())
|
||||
})
|
||||
}
|
||||
return participants.data
|
||||
})
|
||||
|
||||
updateDocumentTitle(pageMeta)
|
||||
</script>
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<div class="text-lg font-semibold mt-5 mb-4">
|
||||
{{ __('Settings') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-10 mb-4">
|
||||
<div class="grid grid-cols-3 gap-10 mb-4">
|
||||
<div
|
||||
v-if="user.data?.is_moderator"
|
||||
class="flex flex-col space-y-3"
|
||||
@@ -147,11 +147,18 @@
|
||||
v-model="course.featured"
|
||||
:label="__('Featured')"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col space-y-3">
|
||||
<FormControl
|
||||
type="checkbox"
|
||||
v-model="course.disable_self_learning"
|
||||
:label="__('Disable Self Enrollment')"
|
||||
/>
|
||||
<FormControl
|
||||
type="checkbox"
|
||||
v-model="course.enable_certification"
|
||||
:label="__('Completion Certificate')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -220,6 +227,7 @@ import { FileText, X } from 'lucide-vue-next'
|
||||
import { useRouter } from 'vue-router'
|
||||
import CourseOutline from '@/components/CourseOutline.vue'
|
||||
import MultiSelect from '@/components/Controls/MultiSelect.vue'
|
||||
import { capture } from '@/telemetry'
|
||||
|
||||
const user = inject('$user')
|
||||
const newTag = ref('')
|
||||
@@ -244,6 +252,7 @@ const course = reactive({
|
||||
featured: false,
|
||||
upcoming: false,
|
||||
disable_self_learning: false,
|
||||
enable_certification: false,
|
||||
paid_course: false,
|
||||
course_price: '',
|
||||
currency: '',
|
||||
@@ -260,6 +269,8 @@ onMounted(() => {
|
||||
|
||||
if (props.courseName !== 'new') {
|
||||
courseResource.reload()
|
||||
} else {
|
||||
capture('course_form_opened')
|
||||
}
|
||||
window.addEventListener('keydown', keyboardShortcut)
|
||||
})
|
||||
@@ -337,6 +348,7 @@ const courseResource = createResource({
|
||||
'disable_self_learning',
|
||||
'paid_course',
|
||||
'featured',
|
||||
'enable_certification',
|
||||
]
|
||||
for (let idx in checkboxes) {
|
||||
let key = checkboxes[idx]
|
||||
@@ -379,9 +391,10 @@ const submitCourse = () => {
|
||||
} else {
|
||||
courseCreationResource.submit(course, {
|
||||
onSuccess(data) {
|
||||
capture('course_created')
|
||||
showToast('Success', 'Course created successfully', 'check')
|
||||
router.push({
|
||||
name: 'CreateCourse',
|
||||
name: 'CourseForm',
|
||||
params: { courseName: data.name },
|
||||
})
|
||||
},
|
||||
@@ -480,7 +493,7 @@ const breadcrumbs = computed(() => {
|
||||
}
|
||||
crumbs.push({
|
||||
label: props.courseName == 'new' ? 'New Course' : 'Edit Course',
|
||||
route: { name: 'CreateCourse', params: { courseName: props.courseName } },
|
||||
route: { name: 'CourseForm', params: { courseName: props.courseName } },
|
||||
})
|
||||
return crumbs
|
||||
})
|
||||
@@ -5,22 +5,24 @@
|
||||
>
|
||||
<Breadcrumbs
|
||||
class="h-7"
|
||||
:items="[{ label: __('All Courses'), route: { name: 'Courses' } }]"
|
||||
:items="[{ label: __('Courses'), route: { name: 'Courses' } }]"
|
||||
/>
|
||||
<div class="flex space-x-2">
|
||||
<FormControl
|
||||
type="text"
|
||||
placeholder="Search Course"
|
||||
v-model="searchQuery"
|
||||
@input="courses.reload()"
|
||||
>
|
||||
<template #prefix>
|
||||
<Search class="w-4 stroke-1.5 text-gray-600" name="search" />
|
||||
</template>
|
||||
</FormControl>
|
||||
<div class="flex space-x-2 justify-end">
|
||||
<div class="w-36">
|
||||
<FormControl
|
||||
type="text"
|
||||
placeholder="Search"
|
||||
v-model="searchQuery"
|
||||
@input="courses.reload()"
|
||||
>
|
||||
<template #prefix>
|
||||
<Search class="w-4 h-4 stroke-1.5 text-gray-600" name="search" />
|
||||
</template>
|
||||
</FormControl>
|
||||
</div>
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'CreateCourse',
|
||||
name: 'CourseForm',
|
||||
params: {
|
||||
courseName: 'new',
|
||||
},
|
||||
@@ -134,29 +136,30 @@ let tabs
|
||||
|
||||
const makeTabs = computed(() => {
|
||||
tabs = []
|
||||
addToTabs('Live', getCourses('live'))
|
||||
addToTabs('New', getCourses('new'))
|
||||
addToTabs('Upcoming', getCourses('upcoming'))
|
||||
addToTabs('Live')
|
||||
addToTabs('New')
|
||||
addToTabs('Upcoming')
|
||||
|
||||
if (user.data) {
|
||||
addToTabs('Enrolled', getCourses('enrolled'))
|
||||
addToTabs('Enrolled')
|
||||
|
||||
if (
|
||||
user.data.is_moderator ||
|
||||
user.data.is_instructor ||
|
||||
courses.data?.created?.length
|
||||
) {
|
||||
addToTabs('Created', getCourses('created'))
|
||||
addToTabs('Created')
|
||||
}
|
||||
|
||||
if (user.data.is_moderator) {
|
||||
addToTabs('Under Review', getCourses('under_review'))
|
||||
addToTabs('Under Review')
|
||||
}
|
||||
}
|
||||
return tabs
|
||||
})
|
||||
|
||||
const addToTabs = (label, courses) => {
|
||||
const addToTabs = (label) => {
|
||||
let courses = getCourses(label.toLowerCase().split(' ').join('_'))
|
||||
tabs.push({
|
||||
label,
|
||||
courses: computed(() => courses),
|
||||
@@ -166,8 +169,12 @@ const addToTabs = (label, courses) => {
|
||||
|
||||
const getCourses = (type) => {
|
||||
if (searchQuery.value) {
|
||||
return courses.data[type].filter((course) =>
|
||||
course.title.toLowerCase().includes(searchQuery.value.toLowerCase())
|
||||
let query = searchQuery.value.toLowerCase()
|
||||
return courses.data[type].filter(
|
||||
(course) =>
|
||||
course.title.toLowerCase().includes(query) ||
|
||||
course.short_introduction.toLowerCase().includes(query) ||
|
||||
course.tags.filter((tag) => tag.toLowerCase().includes(query)).length
|
||||
)
|
||||
}
|
||||
return courses.data[type]
|
||||
|
||||
@@ -50,9 +50,9 @@
|
||||
</Button>
|
||||
</div>
|
||||
</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="flex mb-4">
|
||||
<div class="flex mb-10">
|
||||
<img
|
||||
:src="job.data.company_logo"
|
||||
class="w-16 h-16 rounded-lg object-contain mr-4"
|
||||
@@ -62,40 +62,36 @@
|
||||
<div class="text-2xl font-semibold mb-4">
|
||||
{{ job.data.job_title }}
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-8">
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<Building2 class="h-4 w-4 stroke-1.5" />
|
||||
<span>{{ job.data.company_name }}</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<MapPin class="h-4 w-4 stroke-1.5" />
|
||||
<span>{{ job.data.location }}</span>
|
||||
</div>
|
||||
<div
|
||||
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" />
|
||||
<span>{{ job.data.company_name }}</span>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<ClipboardType class="h-4 w-4 stroke-1.5" />
|
||||
<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 class="flex items-center space-x-2">
|
||||
<MapPin class="h-4 w-4 stroke-1.5" />
|
||||
<span>{{ job.data.location }}</span>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 h-fit">
|
||||
<div
|
||||
v-if="applicationCount.data"
|
||||
class="flex items-center space-x-2"
|
||||
<div class="flex items-center space-x-2">
|
||||
<ClipboardType class="h-4 w-4 stroke-1.5" />
|
||||
<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
|
||||
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>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<router-link
|
||||
v-if="allowEdit()"
|
||||
:to="{
|
||||
name: 'CreateLesson',
|
||||
name: 'LessonForm',
|
||||
params: {
|
||||
courseName: courseName,
|
||||
chapterNumber: props.chapterNumber,
|
||||
@@ -90,6 +90,17 @@
|
||||
</span>
|
||||
</Button>
|
||||
</router-link>
|
||||
<router-link
|
||||
v-else
|
||||
:to="{
|
||||
name: 'CourseDetail',
|
||||
params: { courseName: courseName },
|
||||
}"
|
||||
>
|
||||
<Button>
|
||||
{{ __('Back to Course') }}
|
||||
</Button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -160,12 +171,12 @@
|
||||
{{ lesson.data.course_title }}
|
||||
</div>
|
||||
<div v-if="user && lesson.data.membership" class="text-sm mt-3">
|
||||
{{ Math.ceil(lesson.data.membership.progress) }}% completed
|
||||
{{ Math.ceil(lessonProgress) }}% {{ __('completed') }}
|
||||
</div>
|
||||
|
||||
<ProgressBar
|
||||
v-if="user && lesson.data.membership"
|
||||
:progress="lesson.data.membership.progress"
|
||||
:progress="lessonProgress"
|
||||
/>
|
||||
</div>
|
||||
<CourseOutline
|
||||
@@ -179,7 +190,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import { createResource, Breadcrumbs, Button } from 'frappe-ui'
|
||||
import { computed, watch, inject, ref } from 'vue'
|
||||
import { computed, watch, inject, ref, onMounted, onBeforeUnmount } from 'vue'
|
||||
import CourseOutline from '@/components/CourseOutline.vue'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
@@ -196,6 +207,9 @@ const route = useRoute()
|
||||
const allowDiscussions = ref(false)
|
||||
const editor = ref(null)
|
||||
const instructorEditor = ref(null)
|
||||
const lessonProgress = ref(0)
|
||||
const timer = ref(0)
|
||||
let timerInterval
|
||||
|
||||
const props = defineProps({
|
||||
courseName: {
|
||||
@@ -212,6 +226,10 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
startTimer()
|
||||
})
|
||||
|
||||
const lesson = createResource({
|
||||
url: 'lms.lms.utils.get_lesson',
|
||||
cache: ['lesson', props.courseName, props.chapterNumber, props.lessonNumber],
|
||||
@@ -224,7 +242,7 @@ const lesson = createResource({
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
markProgress(data)
|
||||
lessonProgress.value = data.membership?.progress
|
||||
if (data.content) editor.value = renderEditor('editor', data.content)
|
||||
if (data.instructor_content?.blocks?.length)
|
||||
instructorEditor.value = renderEditor(
|
||||
@@ -256,8 +274,10 @@ const renderEditor = (holder, content) => {
|
||||
})
|
||||
}
|
||||
|
||||
const markProgress = (data) => {
|
||||
if (user.data && !data.progress) progress.submit()
|
||||
const markProgress = () => {
|
||||
if (user.data && !lesson.data?.progress) {
|
||||
progress.submit()
|
||||
}
|
||||
}
|
||||
|
||||
const progress = createResource({
|
||||
@@ -268,6 +288,9 @@ const progress = createResource({
|
||||
course: props.courseName,
|
||||
}
|
||||
},
|
||||
onSuccess(data) {
|
||||
lessonProgress.value = data
|
||||
},
|
||||
})
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
@@ -304,10 +327,27 @@ watch(
|
||||
chapter: newChapterNumber,
|
||||
lesson: newLessonNumber,
|
||||
})
|
||||
clearInterval(timerInterval)
|
||||
timer.value = 0
|
||||
startTimer()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const startTimer = () => {
|
||||
timerInterval = setInterval(() => {
|
||||
timer.value++
|
||||
if (timer.value == 30) {
|
||||
clearInterval(timerInterval)
|
||||
markProgress()
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
clearInterval(timerInterval)
|
||||
})
|
||||
|
||||
const checkIfDiscussionsAllowed = () => {
|
||||
let quizPresent = false
|
||||
JSON.parse(lesson.data?.content)?.blocks?.forEach((block) => {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div
|
||||
v-show="openInstructorEditor"
|
||||
id="instructor-notes"
|
||||
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 py-3"
|
||||
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 py-3"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -54,7 +54,7 @@
|
||||
</label>
|
||||
<div
|
||||
id="content"
|
||||
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 py-3"
|
||||
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 py-3"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,16 +70,25 @@
|
||||
</template>
|
||||
<script setup>
|
||||
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 LessonPlugins from '@/components/LessonPlugins.vue'
|
||||
import { ChevronRight } from 'lucide-vue-next'
|
||||
import { updateDocumentTitle, createToast, getEditorTools } from '@/utils'
|
||||
import { capture } from '@/telemetry'
|
||||
|
||||
const editor = ref(null)
|
||||
const instructorEditor = ref(null)
|
||||
const user = inject('$user')
|
||||
const openInstructorEditor = ref(false)
|
||||
let autoSaveInterval
|
||||
|
||||
const props = defineProps({
|
||||
courseName: {
|
||||
@@ -100,6 +109,7 @@ onMounted(() => {
|
||||
if (!user.data?.is_moderator && !user.data?.is_instructor) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
capture('lesson_form_opened')
|
||||
editor.value = renderEditor('content')
|
||||
instructorEditor.value = renderEditor('instructor-notes')
|
||||
})
|
||||
@@ -134,32 +144,49 @@ const lessonDetails = createResource({
|
||||
lesson[key] = data.lesson[key]
|
||||
})
|
||||
lesson.include_in_preview = data.include_in_preview ? true : false
|
||||
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,
|
||||
})
|
||||
}
|
||||
})
|
||||
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,
|
||||
})
|
||||
}
|
||||
})
|
||||
addLessonContent(data)
|
||||
addInstructorNotes(data)
|
||||
enableAutoSave()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
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({
|
||||
url: 'frappe.client.insert',
|
||||
makeParams(values) {
|
||||
@@ -335,6 +362,7 @@ const createNewLesson = () => {
|
||||
{ lesson: data.name },
|
||||
{
|
||||
onSuccess() {
|
||||
capture('lesson_created')
|
||||
showToast('Success', 'Lesson created successfully', 'check')
|
||||
lessonDetails.reload()
|
||||
},
|
||||
@@ -357,9 +385,6 @@ const editCurrentLesson = () => {
|
||||
validate() {
|
||||
return validateLesson()
|
||||
},
|
||||
onSuccess() {
|
||||
showToast('Success', 'Lesson updated successfully', 'check')
|
||||
},
|
||||
onError(err) {
|
||||
showToast('Error', err.message, 'x')
|
||||
},
|
||||
@@ -418,7 +443,7 @@ const breadcrumbs = computed(() => {
|
||||
crumbs.push({
|
||||
label: lessonDetails?.data?.lesson ? 'Edit Lesson' : 'Create Lesson',
|
||||
route: {
|
||||
name: 'CreateLesson',
|
||||
name: 'LessonForm',
|
||||
params: {
|
||||
courseName: props.courseName,
|
||||
chapterNumber: props.chapterNumber,
|
||||
@@ -439,7 +464,8 @@ const pageMeta = computed(() => {
|
||||
updateDocumentTitle(pageMeta)
|
||||
</script>
|
||||
<style>
|
||||
.embed-tool__caption {
|
||||
.embed-tool__caption,
|
||||
.cdx-simple-image__caption {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<h2 class="mb-3 text-lg font-semibold text-gray-900">
|
||||
{{ __('Achievements') }}
|
||||
</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">
|
||||
<Popover trigger="hover" :leaveDelay="Number(0.01)">
|
||||
<template #target>
|
||||
|
||||
418
frontend/src/pages/QuizCreation.vue
Normal file
418
frontend/src/pages/QuizCreation.vue
Normal file
@@ -0,0 +1,418 @@
|
||||
<template>
|
||||
<header
|
||||
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" />
|
||||
<Button variant="solid" @click="submitQuiz()">
|
||||
{{ __('Save') }}
|
||||
</Button>
|
||||
</header>
|
||||
<div class="w-3/4 mx-auto py-5">
|
||||
<!-- Details -->
|
||||
<div class="mb-8">
|
||||
<div class="text-sm font-semibold mb-4">
|
||||
{{ __('Details') }}
|
||||
</div>
|
||||
<FormControl
|
||||
v-model="quiz.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
|
||||
v-model="quiz.max_attempts"
|
||||
:label="__('Maximun Attempts')"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="quiz.total_marks"
|
||||
:label="__('Total Marks')"
|
||||
disabled
|
||||
/>
|
||||
<FormControl
|
||||
v-model="quiz.passing_percentage"
|
||||
:label="__('Passing Percentage')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Settings -->
|
||||
<div class="mb-8">
|
||||
<div class="text-sm font-semibold mb-4">
|
||||
{{ __('Settings') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-5 my-4">
|
||||
<FormControl
|
||||
v-model="quiz.show_answers"
|
||||
type="checkbox"
|
||||
:label="__('Show Answers')"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="quiz.show_submission_history"
|
||||
type="checkbox"
|
||||
:label="__('Show Submission History')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-8">
|
||||
<div class="text-sm font-semibold mb-4">
|
||||
{{ __('Shuffle Settings') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-3">
|
||||
<FormControl
|
||||
v-model="quiz.shuffle_questions"
|
||||
type="checkbox"
|
||||
:label="__('Shuffle Questions')"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="quiz.shuffle_questions"
|
||||
v-model="quiz.limit_questions_to"
|
||||
:label="__('Limit Questions To')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Questions -->
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="text-sm font-semibold">
|
||||
{{ __('Questions') }}
|
||||
</div>
|
||||
<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,
|
||||
}"
|
||||
>
|
||||
<ListHeader
|
||||
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
|
||||
>
|
||||
<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)"
|
||||
>
|
||||
<ListRowItem :item="item">
|
||||
<div
|
||||
v-if="column.key == 'question_detail'"
|
||||
class="text-xs truncate h-4"
|
||||
v-html="item"
|
||||
></div>
|
||||
<div v-else class="text-xs">
|
||||
{{ item }}
|
||||
</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>
|
||||
<Question
|
||||
v-model="showQuestionModal"
|
||||
:questionDetail="currentQuestion"
|
||||
v-model:quiz="quizDetails"
|
||||
:title="
|
||||
currentQuestion.question
|
||||
? __('Edit the question')
|
||||
: __('Add a new question')
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
Breadcrumbs,
|
||||
createResource,
|
||||
FormControl,
|
||||
ListView,
|
||||
ListHeader,
|
||||
ListHeaderItem,
|
||||
ListRows,
|
||||
ListRow,
|
||||
ListRowItem,
|
||||
ListSelectBanner,
|
||||
Button,
|
||||
} from 'frappe-ui'
|
||||
import {
|
||||
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 { showToast } from '../utils'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const showQuestionModal = ref(false)
|
||||
const currentQuestion = reactive({
|
||||
question: '',
|
||||
marks: 0,
|
||||
name: '',
|
||||
})
|
||||
const user = inject('$user')
|
||||
const router = useRouter()
|
||||
|
||||
const props = defineProps({
|
||||
quizID: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const quiz = reactive({
|
||||
title: '',
|
||||
total_marks: 0,
|
||||
passing_percentage: 0,
|
||||
max_attempts: 0,
|
||||
limit_questions_to: 0,
|
||||
show_answers: true,
|
||||
show_submission_history: false,
|
||||
shuffle_questions: false,
|
||||
questions: [],
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (
|
||||
props.quizID == 'new' &&
|
||||
!user.data?.is_moderator &&
|
||||
!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) {
|
||||
Object.keys(data).forEach((key) => {
|
||||
if (Object.hasOwn(quiz, key)) quiz[key] = data[key]
|
||||
})
|
||||
|
||||
let checkboxes = [
|
||||
'show_answers',
|
||||
'show_submission_history',
|
||||
'shuffle_questions',
|
||||
]
|
||||
for (let idx in checkboxes) {
|
||||
let key = checkboxes[idx]
|
||||
quiz[key] = quiz[key] ? true : false
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
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(() => {
|
||||
return [
|
||||
{
|
||||
label: __('ID'),
|
||||
key: 'question',
|
||||
width: '25%',
|
||||
},
|
||||
{
|
||||
label: __('Question'),
|
||||
key: __('question_detail'),
|
||||
width: '60%',
|
||||
},
|
||||
{
|
||||
label: __('Marks'),
|
||||
key: 'marks',
|
||||
width: '10%',
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const openQuestionModal = (question = null) => {
|
||||
if (question) {
|
||||
currentQuestion.question = question.question
|
||||
currentQuestion.marks = question.marks
|
||||
currentQuestion.name = question.name
|
||||
} else {
|
||||
currentQuestion.question = ''
|
||||
currentQuestion.marks = 0
|
||||
currentQuestion.name = ''
|
||||
}
|
||||
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(() => {
|
||||
let crumbs = [
|
||||
{
|
||||
label: __('Quizzes'),
|
||||
route: {
|
||||
name: 'Quizzes',
|
||||
},
|
||||
},
|
||||
]
|
||||
/* 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
|
||||
})
|
||||
</script>
|
||||
126
frontend/src/pages/Quizzes.vue
Normal file
126
frontend/src/pages/Quizzes.vue
Normal file
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<header
|
||||
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" />
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'QuizCreation',
|
||||
params: {
|
||||
quizID: 'new',
|
||||
},
|
||||
}"
|
||||
>
|
||||
<Button variant="solid">
|
||||
<template #prefix>
|
||||
<Plus class="w-4 h-4" />
|
||||
</template>
|
||||
{{ __('New Quiz') }}
|
||||
</Button>
|
||||
</router-link>
|
||||
</header>
|
||||
<div v-if="quizzes.data?.length" class="w-3/4 mx-auto py-5">
|
||||
<ListView
|
||||
:columns="quizColumns"
|
||||
:rows="quizzes.data"
|
||||
row-key="name"
|
||||
:options="{ showTooltip: false, selectable: false }"
|
||||
>
|
||||
<ListHeader
|
||||
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
|
||||
>
|
||||
<ListHeaderItem :item="item" v-for="item in quizColumns">
|
||||
</ListHeaderItem>
|
||||
</ListHeader>
|
||||
<ListRows>
|
||||
<router-link
|
||||
v-for="row in quizzes.data"
|
||||
:to="{
|
||||
name: 'QuizCreation',
|
||||
params: {
|
||||
quizID: row.name,
|
||||
},
|
||||
}"
|
||||
>
|
||||
<ListRow :row="row" />
|
||||
</router-link>
|
||||
</ListRows>
|
||||
</ListView>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
Breadcrumbs,
|
||||
createListResource,
|
||||
ListView,
|
||||
ListRows,
|
||||
ListRow,
|
||||
ListHeader,
|
||||
ListHeaderItem,
|
||||
Button,
|
||||
} from 'frappe-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { computed, inject, onMounted } from 'vue'
|
||||
import { Plus } from 'lucide-vue-next'
|
||||
|
||||
const user = inject('$user')
|
||||
const router = useRouter()
|
||||
|
||||
onMounted(() => {
|
||||
if (!user.data?.is_moderator && !user.data?.is_instructor) {
|
||||
router.push({ name: 'Courses' })
|
||||
}
|
||||
})
|
||||
|
||||
const quizFilter = computed(() => {
|
||||
if (user.data?.is_moderator) return {}
|
||||
return {
|
||||
owner: user.data?.name,
|
||||
}
|
||||
})
|
||||
|
||||
const quizzes = createListResource({
|
||||
doctype: 'LMS Quiz',
|
||||
filters: quizFilter,
|
||||
fields: ['name', 'title', 'passing_percentage', 'total_marks'],
|
||||
auto: true,
|
||||
cache: ['quizzes', user.data?.name],
|
||||
orderBy: 'modified desc',
|
||||
onSuccess(data) {
|
||||
data.forEach((row) => {})
|
||||
},
|
||||
})
|
||||
|
||||
const quizColumns = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: __('Title'),
|
||||
key: 'title',
|
||||
width: 2,
|
||||
},
|
||||
{
|
||||
label: __('Total Marks'),
|
||||
key: 'total_marks',
|
||||
width: 1,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
label: __('Passing Percentage'),
|
||||
key: 'passing_percentage',
|
||||
width: 1,
|
||||
align: 'center',
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: __('Quizzes'),
|
||||
route: {
|
||||
name: 'Quizzes',
|
||||
},
|
||||
},
|
||||
]
|
||||
})
|
||||
</script>
|
||||
@@ -97,20 +97,20 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: '/courses/:courseName/edit',
|
||||
name: 'CreateCourse',
|
||||
component: () => import('@/pages/CreateCourse.vue'),
|
||||
name: 'CourseForm',
|
||||
component: () => import('@/pages/CourseForm.vue'),
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: '/courses/:courseName/learn/:chapterNumber-:lessonNumber/edit',
|
||||
name: 'CreateLesson',
|
||||
component: () => import('@/pages/CreateLesson.vue'),
|
||||
name: 'LessonForm',
|
||||
component: () => import('@/pages/LessonForm.vue'),
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: '/batches/:batchName/edit',
|
||||
name: 'BatchCreation',
|
||||
component: () => import('@/pages/BatchCreation.vue'),
|
||||
name: 'BatchForm',
|
||||
component: () => import('@/pages/BatchForm.vue'),
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
@@ -141,6 +141,17 @@ const routes = [
|
||||
component: () => import('@/pages/Badge.vue'),
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: '/quizzes',
|
||||
name: 'Quizzes',
|
||||
component: () => import('@/pages/Quizzes.vue'),
|
||||
},
|
||||
{
|
||||
path: '/quizzes/:quizID',
|
||||
name: 'QuizCreation',
|
||||
component: () => import('@/pages/QuizCreation.vue'),
|
||||
props: true,
|
||||
},
|
||||
]
|
||||
|
||||
let router = createRouter({
|
||||
|
||||
@@ -5,7 +5,7 @@ import router from '@/router'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
export const sessionStore = defineStore('lms-session', () => {
|
||||
let { userResource } = usersStore()
|
||||
let { userResource, allUsers } = usersStore()
|
||||
|
||||
function sessionUser() {
|
||||
let cookies = new URLSearchParams(document.cookie.split('; ').join('&'))
|
||||
@@ -17,6 +17,9 @@ export const sessionStore = defineStore('lms-session', () => {
|
||||
}
|
||||
|
||||
let user = ref(sessionUser())
|
||||
if (user) {
|
||||
allUsers.reload()
|
||||
}
|
||||
const isLoggedIn = computed(() => !!user.value)
|
||||
|
||||
const login = createResource({
|
||||
@@ -50,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 {
|
||||
user,
|
||||
isLoggedIn,
|
||||
login,
|
||||
logout,
|
||||
branding,
|
||||
sidebarSettings,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -15,7 +15,6 @@ export const usersStore = defineStore('lms-users', () => {
|
||||
const allUsers = createResource({
|
||||
url: 'lms.lms.api.get_all_users',
|
||||
cache: ['allUsers'],
|
||||
auto: true,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
98
frontend/src/telemetry.ts
Normal file
98
frontend/src/telemetry.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui'
|
||||
|
||||
export default function translationPlugin(app) {
|
||||
app.config.globalProperties.__ = translate
|
||||
window.__ = translate
|
||||
if (!window.translatedMessages) fetchTranslations()
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import InlineCode from '@editorjs/inline-code'
|
||||
import { watch } from 'vue'
|
||||
import dayjs from '@/utils/dayjs'
|
||||
import Embed from '@editorjs/embed'
|
||||
import SimpleImage from '@editorjs/simple-image'
|
||||
|
||||
export function createToast(options) {
|
||||
toast({
|
||||
@@ -79,15 +80,18 @@ export function getFileSize(file_size) {
|
||||
return value
|
||||
}
|
||||
|
||||
export function showToast(title, text, icon) {
|
||||
export function showToast(title, text, icon, iconClasses = null) {
|
||||
if (!iconClasses) {
|
||||
iconClasses =
|
||||
icon == 'check'
|
||||
? 'bg-green-600 text-white rounded-md p-px'
|
||||
: 'bg-red-600 text-white rounded-md p-px'
|
||||
}
|
||||
createToast({
|
||||
title: title,
|
||||
text: htmlToText(text),
|
||||
icon: icon,
|
||||
iconClasses:
|
||||
icon == 'check'
|
||||
? 'bg-green-600 text-white rounded-md p-px'
|
||||
: 'bg-red-600 text-white rounded-md p-px',
|
||||
iconClasses: iconClasses,
|
||||
position: icon == 'check' ? 'bottom-right' : 'top-center',
|
||||
timeout: 5,
|
||||
})
|
||||
@@ -133,6 +137,7 @@ export function getEditorTools() {
|
||||
header: Header,
|
||||
quiz: Quiz,
|
||||
upload: Upload,
|
||||
image: SimpleImage,
|
||||
paragraph: {
|
||||
class: Paragraph,
|
||||
inlineToolbar: true,
|
||||
@@ -164,16 +169,74 @@ export function getEditorTools() {
|
||||
inlineToolbar: false,
|
||||
config: {
|
||||
services: {
|
||||
youtube: true,
|
||||
youtube: {
|
||||
regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/,
|
||||
embedUrl:
|
||||
'https://www.youtube.com/embed/<%= remote_id %>',
|
||||
html: '<iframe style="width:100%; height: 30rem;" frameborder="0" allowfullscreen></iframe>',
|
||||
height: 320,
|
||||
width: 580,
|
||||
id: ([id, params]) => {
|
||||
if (!params && id) {
|
||||
return id
|
||||
}
|
||||
|
||||
const paramsMap = {
|
||||
start: 'start',
|
||||
end: 'end',
|
||||
t: 'start',
|
||||
// eslint-disable-next-line camelcase
|
||||
time_continue: 'start',
|
||||
list: 'list',
|
||||
}
|
||||
|
||||
let newParams = params
|
||||
.slice(1)
|
||||
.split('&')
|
||||
.map((param) => {
|
||||
const [name, value] = param.split('=')
|
||||
|
||||
if (!id && name === 'v') {
|
||||
id = value
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
if (!paramsMap[name]) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (
|
||||
value === 'LL' ||
|
||||
value.startsWith('RDMM') ||
|
||||
value.startsWith('FL')
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
return `${paramsMap[name]}=${value}`
|
||||
})
|
||||
.filter((param) => !!param)
|
||||
|
||||
return id + '?' + newParams.join('&')
|
||||
},
|
||||
},
|
||||
vimeo: true,
|
||||
codepen: true,
|
||||
aparat: true,
|
||||
aparat: {
|
||||
regex: /(?:http[s]?:\/\/)?(?:www.)?aparat\.com\/v\/([^\/\?\&]+)\/?/,
|
||||
embedUrl:
|
||||
'https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame',
|
||||
html: '<iframe style="margin: 0 auto; width: 100%; height: 25rem;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
|
||||
height: 300,
|
||||
width: 600,
|
||||
},
|
||||
github: true,
|
||||
slides: {
|
||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/([A-Za-z0-9_-]+)\/pub/,
|
||||
embedUrl:
|
||||
'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>",
|
||||
'https://docs.google.com/presentation/d/<%= remote_id %>/embed',
|
||||
html: "<iframe style='width: 100%; height: 30rem; border: 1px solid #D3D3D3; border-radius: 12px; margin: 1rem 0' frameborder='0' allowfullscreen='true'></iframe>",
|
||||
},
|
||||
drive: {
|
||||
regex: /https:\/\/drive\.google\.com\/file\/d\/([A-Za-z0-9_-]+)\/view(\?.+)?/,
|
||||
@@ -197,7 +260,7 @@ export function getEditorTools() {
|
||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/([A-Za-z0-9_-]+)\/edit(\?.+)?/,
|
||||
embedUrl:
|
||||
'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: {
|
||||
regex: /^https:\/\/codesandbox\.io\/(?:embed\/)?([A-Za-z0-9_-]+)(?:\?[^\/]*)?$/,
|
||||
@@ -361,15 +424,15 @@ export function getSidebarLinks() {
|
||||
'Courses',
|
||||
'CourseDetail',
|
||||
'Lesson',
|
||||
'CreateCourse',
|
||||
'CreateLesson',
|
||||
'CourseForm',
|
||||
'LessonForm',
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Batches',
|
||||
icon: 'Users',
|
||||
to: 'Batches',
|
||||
activeFor: ['Batches', 'BatchDetail', 'Batch', 'BatchCreation'],
|
||||
activeFor: ['Batches', 'BatchDetail', 'Batch', 'BatchForm'],
|
||||
},
|
||||
{
|
||||
label: 'Certified Participants',
|
||||
@@ -420,3 +483,19 @@ export function getLineStartPosition(string, position) {
|
||||
|
||||
return position
|
||||
}
|
||||
|
||||
export function singularize(word) {
|
||||
const endings = {
|
||||
ves: 'fe',
|
||||
ies: 'y',
|
||||
i: 'us',
|
||||
zes: 'ze',
|
||||
ses: 's',
|
||||
es: 'e',
|
||||
s: '',
|
||||
}
|
||||
return word.replace(
|
||||
new RegExp(`(${Object.keys(endings).join('|')})$`),
|
||||
(r) => endings[r]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,13 +68,6 @@
|
||||
dependencies:
|
||||
"@codexteam/icons" "^0.0.5"
|
||||
|
||||
"@editorjs/image@^2.9.0":
|
||||
version "2.9.0"
|
||||
resolved "https://registry.yarnpkg.com/@editorjs/image/-/image-2.9.0.tgz#0c83252d569a0dc3af14c3f7d16b6df033b9c37b"
|
||||
integrity sha512-xItihKJFiWJ06SMtLWQZvzHv4LRPNAFZYaHAXesBFzXvWwUrtVaVMcNSf0eNnw3InrPO3Po1vZRRgpsT+Ya3Bg==
|
||||
dependencies:
|
||||
"@codexteam/icons" "^0.0.6"
|
||||
|
||||
"@editorjs/inline-code@^1.5.0":
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@editorjs/inline-code/-/inline-code-1.5.0.tgz#ad5849bac3396b9dad22dceeda76198dd991e426"
|
||||
@@ -96,6 +89,13 @@
|
||||
dependencies:
|
||||
"@codexteam/icons" "^0.0.4"
|
||||
|
||||
"@editorjs/simple-image@^1.6.0":
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@editorjs/simple-image/-/simple-image-1.6.0.tgz#711c3900e17845331d6667cf0fe91793a5557f84"
|
||||
integrity sha512-WvdGfQPlozwZd3PXQrJnRXk6gEYbv1U2vRupYJ6lTd3/UsLInXYUX5jSFcnGB5ZMH3bd0JDZfcb4d4Sv1/1big==
|
||||
dependencies:
|
||||
"@codexteam/icons" "^0.0.6"
|
||||
|
||||
"@esbuild/aix-ppc64@0.20.2":
|
||||
version "0.20.2"
|
||||
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz#a70f4ac11c6a1dfc18b8bbb13284155d933b9537"
|
||||
@@ -1875,8 +1875,16 @@ source-map-js@^1.2.0:
|
||||
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af"
|
||||
integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
|
||||
name string-width-cjs
|
||||
"string-width-cjs@npm:string-width@^4.2.0":
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^4.1.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
@@ -1894,8 +1902,14 @@ string-width@^5.0.1, string-width@^5.1.2:
|
||||
emoji-regex "^9.2.2"
|
||||
strip-ansi "^7.0.1"
|
||||
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
name strip-ansi-cjs
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "2.0.0"
|
||||
__version__ = "2.4.0"
|
||||
|
||||
62
lms/hooks.py
62
lms/hooks.py
@@ -4,9 +4,11 @@ app_name = "frappe_lms"
|
||||
app_title = "Frappe LMS"
|
||||
app_publisher = "Frappe"
|
||||
app_description = "Frappe LMS App"
|
||||
app_icon = "octicon octicon-file-directory"
|
||||
app_icon_url = "/assets/lms/images/lms-logo.png"
|
||||
app_icon_title = "Learning"
|
||||
app_icon_route = "/lms"
|
||||
app_color = "grey"
|
||||
app_email = "school@frappe.io"
|
||||
app_email = "jannat@frappe.io"
|
||||
app_license = "AGPL"
|
||||
|
||||
# Includes in <head>
|
||||
@@ -61,8 +63,6 @@ web_include_js = ["website.bundle.js"]
|
||||
after_install = "lms.install.after_install"
|
||||
after_sync = "lms.install.after_sync"
|
||||
before_uninstall = "lms.install.before_uninstall"
|
||||
|
||||
|
||||
setup_wizard_requires = "assets/lms/js/setup_wizard.js"
|
||||
|
||||
# Desk Notifications
|
||||
@@ -177,50 +177,14 @@ update_website_context = [
|
||||
|
||||
jinja = {
|
||||
"methods": [
|
||||
"lms.page_renderers.get_profile_url",
|
||||
"lms.overrides.user.get_enrolled_courses",
|
||||
"lms.overrides.user.get_course_membership",
|
||||
"lms.overrides.user.get_authored_courses",
|
||||
"lms.overrides.user.get_palette",
|
||||
"lms.lms.utils.get_membership",
|
||||
"lms.lms.utils.get_lessons",
|
||||
"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_students",
|
||||
"lms.lms.utils.get_average_rating",
|
||||
"lms.lms.utils.is_certified",
|
||||
"lms.lms.utils.get_lesson_index",
|
||||
"lms.lms.utils.get_lesson_url",
|
||||
"lms.lms.utils.get_chapters",
|
||||
"lms.lms.utils.get_slugified_chapter_title",
|
||||
"lms.lms.utils.get_progress",
|
||||
"lms.lms.utils.render_html",
|
||||
"lms.lms.utils.is_mentor",
|
||||
"lms.lms.utils.is_cohort_staff",
|
||||
"lms.lms.utils.get_mentors",
|
||||
"lms.lms.utils.get_reviews",
|
||||
"lms.lms.utils.is_eligible_to_review",
|
||||
"lms.lms.utils.get_initial_members",
|
||||
"lms.lms.utils.get_sorted_reviews",
|
||||
"lms.lms.utils.is_instructor",
|
||||
"lms.lms.utils.convert_number_to_character",
|
||||
"lms.lms.utils.get_signup_optin_checks",
|
||||
"lms.lms.utils.get_popular_courses",
|
||||
"lms.lms.utils.format_amount",
|
||||
"lms.lms.utils.first_lesson_exists",
|
||||
"lms.lms.utils.get_courses_under_review",
|
||||
"lms.lms.utils.has_course_instructor_role",
|
||||
"lms.lms.utils.has_course_moderator_role",
|
||||
"lms.lms.utils.get_certificates",
|
||||
"lms.lms.utils.format_number",
|
||||
"lms.lms.utils.get_lesson_count",
|
||||
"lms.lms.utils.get_all_memberships",
|
||||
"lms.lms.utils.get_filtered_membership",
|
||||
"lms.lms.utils.show_start_learing_cta",
|
||||
"lms.lms.utils.can_create_courses",
|
||||
"lms.lms.utils.get_telemetry_boot_info",
|
||||
"lms.lms.utils.is_onboarding_complete",
|
||||
"lms.www.utils.is_student",
|
||||
"lms.page_renderers.get_profile_url",
|
||||
"lms.overrides.user.get_palette",
|
||||
],
|
||||
"filters": [],
|
||||
}
|
||||
@@ -267,3 +231,13 @@ profile_url_prefix = "/users/"
|
||||
signup_form_template = "lms.plugins.show_custom_signup"
|
||||
|
||||
on_session_creation = "lms.overrides.user.on_session_creation"
|
||||
|
||||
add_to_apps_screen = [
|
||||
{
|
||||
"name": "lms",
|
||||
"logo": "/assets/lms/images/lms-logo.png",
|
||||
"title": "Learning",
|
||||
"route": "/lms",
|
||||
"has_permission": "lms.lms.api.check_app_permission",
|
||||
}
|
||||
]
|
||||
|
||||
@@ -6,6 +6,7 @@ from frappe.translate import get_all_translations
|
||||
from frappe import _
|
||||
from frappe.query_builder import DocType
|
||||
from frappe.query_builder.functions import Count
|
||||
from frappe.utils import time_diff, now_datetime, get_datetime
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
@@ -265,7 +266,9 @@ def get_chart_details():
|
||||
"upcoming": 0,
|
||||
},
|
||||
)
|
||||
details.users = frappe.db.count("User", {"enabled": 1})
|
||||
details.users = frappe.db.count(
|
||||
"User", {"enabled": 1, "name": ["not in", ("Administrator", "Guest")]}
|
||||
)
|
||||
details.completions = frappe.db.count(
|
||||
"LMS Enrollment", {"progress": ["like", "%100%"]}
|
||||
)
|
||||
@@ -330,13 +333,12 @@ def get_evaluator_details(evaluator):
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_certified_participants(search_query=""):
|
||||
def get_certified_participants():
|
||||
LMSCertificate = DocType("LMS Certificate")
|
||||
participants = (
|
||||
frappe.qb.from_(LMSCertificate)
|
||||
.select(LMSCertificate.member)
|
||||
.distinct()
|
||||
.where(LMSCertificate.member_name.like(f"%{search_query}%"))
|
||||
.where(LMSCertificate.published == 1)
|
||||
.orderby(LMSCertificate.creation, order=frappe.qb.desc)
|
||||
.run(as_dict=1)
|
||||
@@ -542,3 +544,69 @@ def update_index(lessons, chapter):
|
||||
frappe.db.set_value(
|
||||
"Lesson Reference", {"lesson": row, "parent": chapter}, "idx", lessons.index(row) + 1
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_categories(doctype, filters):
|
||||
categoryOptions = []
|
||||
|
||||
categories = frappe.get_all(
|
||||
doctype,
|
||||
filters,
|
||||
pluck="category",
|
||||
)
|
||||
categories = list(set(categories))
|
||||
|
||||
for category in categories:
|
||||
if category:
|
||||
categoryOptions.append({"label": category, "value": category})
|
||||
|
||||
return categoryOptions
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_members(start=0, search=""):
|
||||
"""Get members for the given search term and start index.
|
||||
Args: start (int): Start index for the query.
|
||||
search (str): Search term to filter the results.
|
||||
Returns: List of members.
|
||||
"""
|
||||
|
||||
filters = {"enabled": 1, "name": ["not in", ["Administrator", "Guest"]]}
|
||||
|
||||
if search:
|
||||
filters["full_name"] = ["like", f"%{search}%"]
|
||||
|
||||
members = frappe.get_all(
|
||||
"User",
|
||||
filters=filters,
|
||||
fields=["name", "full_name", "user_image", "username"],
|
||||
page_length=20,
|
||||
start=start,
|
||||
)
|
||||
|
||||
for member in members:
|
||||
roles = frappe.get_roles(member.name)
|
||||
if "Moderator" in roles:
|
||||
member.role = "Moderator"
|
||||
elif "Course Creator" in roles:
|
||||
member.role = "Course Creator"
|
||||
elif "Batch Evaluator" in roles:
|
||||
member.role = "Batch Evaluator"
|
||||
elif "LMS Student" in roles:
|
||||
member.role = "LMS Student"
|
||||
|
||||
return members
|
||||
|
||||
|
||||
def check_app_permission():
|
||||
"""Check if the user has permission to access the app."""
|
||||
if frappe.session.user == "Administrator":
|
||||
return True
|
||||
|
||||
roles = frappe.get_roles()
|
||||
lms_roles = ["Moderator", "Course Creator", "Batch Evaluator", "LMS Student"]
|
||||
if any(role in roles for role in lms_roles):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@@ -93,7 +93,7 @@ def save_progress(lesson, course):
|
||||
"LMS Enrollment", {"course": course, "member": frappe.session.user}
|
||||
)
|
||||
if not membership:
|
||||
return 0
|
||||
return
|
||||
|
||||
frappe.db.set_value("LMS Enrollment", membership, "current_lesson", lesson)
|
||||
|
||||
@@ -104,7 +104,7 @@ def save_progress(lesson, course):
|
||||
if frappe.db.exists(
|
||||
"LMS Course Progress", {"lesson": lesson, "member": frappe.session.user}
|
||||
):
|
||||
return 0
|
||||
return
|
||||
|
||||
frappe.get_doc(
|
||||
{
|
||||
@@ -116,9 +116,12 @@ def save_progress(lesson, course):
|
||||
).save(ignore_permissions=True)
|
||||
|
||||
progress = get_course_progress(course)
|
||||
frappe.db.set_value("LMS Enrollment", membership, "progress", progress)
|
||||
# Had to get doc, as on_change doesn't trigger when you use set_value. The trigger is necesary for badge to get assigned.
|
||||
enrollment = frappe.get_doc("LMS Enrollment", membership)
|
||||
enrollment.progress = progress
|
||||
enrollment.save()
|
||||
enrollment.run_method("on_change")
|
||||
|
||||
return progress
|
||||
|
||||
|
||||
|
||||
@@ -11,74 +11,4 @@ from lms.lms.doctype.invite_request.invite_request import (
|
||||
|
||||
|
||||
class TestInviteRequest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
create_invite_request("test_invite@example.com")
|
||||
|
||||
def test_create_invite_request(self):
|
||||
if frappe.db.exists("Invite Request", {"invite_email": "test_invite@example.com"}):
|
||||
invite = frappe.db.get_value(
|
||||
"Invite Request",
|
||||
filters={"invite_email": "test_invite@example.com"},
|
||||
fieldname=["invite_email", "status", "signup_email"],
|
||||
as_dict=True,
|
||||
)
|
||||
self.assertEqual(invite.status, "Approved")
|
||||
self.assertEqual(invite.signup_email, None)
|
||||
|
||||
def test_create_invite_request_update(self):
|
||||
if frappe.db.exists("Invite Request", {"invite_email": "test_invite@example.com"}):
|
||||
|
||||
data = {
|
||||
"signup_email": "test_invite@example.com",
|
||||
"username": "test_invite",
|
||||
"full_name": "Test Invite",
|
||||
"password": "Test@invite",
|
||||
"invite_code": frappe.db.get_value(
|
||||
"Invite Request", {"invite_email": "test_invite@example.com"}, "name"
|
||||
),
|
||||
}
|
||||
|
||||
update_invite(data)
|
||||
invite = frappe.db.get_value(
|
||||
"Invite Request",
|
||||
filters={"invite_email": "test_invite@example.com"},
|
||||
fieldname=[
|
||||
"invite_email",
|
||||
"status",
|
||||
"signup_email",
|
||||
"full_name",
|
||||
"username",
|
||||
"invite_code",
|
||||
"name",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
self.assertEqual(invite.signup_email, "test_invite@example.com")
|
||||
self.assertEqual(invite.full_name, "Test Invite")
|
||||
self.assertEqual(invite.username, "test_invite")
|
||||
self.assertEqual(invite.invite_code, invite.name)
|
||||
self.assertEqual(invite.status, "Registered")
|
||||
|
||||
user = frappe.db.get_value(
|
||||
"User",
|
||||
"test_invite@example.com",
|
||||
fieldname=["first_name", "username", "send_welcome_email", "user_type"],
|
||||
as_dict=True,
|
||||
)
|
||||
self.assertTrue(user)
|
||||
self.assertEqual(user.first_name, invite.full_name.split(" ")[0])
|
||||
self.assertEqual(user.username, invite.username)
|
||||
self.assertEqual(user.send_welcome_email, 0)
|
||||
self.assertEqual(user.user_type, "Website User")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
if frappe.db.exists("User", "test_invite@example.com"):
|
||||
frappe.delete_doc("User", "test_invite@example.com")
|
||||
|
||||
invite_request = frappe.db.exists(
|
||||
"Invite Request", {"invite_email": "test_invite@example.com"}
|
||||
)
|
||||
if invite_request:
|
||||
frappe.delete_doc("Invite Request", invite_request)
|
||||
pass
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
"label": "Comments"
|
||||
},
|
||||
{
|
||||
"fetch_from": "course.evaluator",
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Link",
|
||||
"label": "Evaluator",
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
"fieldname": "start_date",
|
||||
"fieldtype": "Date",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Start Date",
|
||||
"reqd": 1
|
||||
},
|
||||
@@ -127,6 +128,7 @@
|
||||
{
|
||||
"fieldname": "start_time",
|
||||
"fieldtype": "Time",
|
||||
"in_list_view": 1,
|
||||
"label": "Start Time",
|
||||
"reqd": 1
|
||||
},
|
||||
@@ -165,6 +167,7 @@
|
||||
{
|
||||
"fieldname": "category",
|
||||
"fieldtype": "Link",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Category",
|
||||
"options": "LMS Category"
|
||||
},
|
||||
@@ -325,7 +328,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-24 16:24:45.536453",
|
||||
"modified": "2024-07-18 18:06:37.229885",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch",
|
||||
|
||||
@@ -96,6 +96,7 @@ class LMSBatch(Document):
|
||||
)
|
||||
|
||||
args = {
|
||||
"title": self.title,
|
||||
"student_name": student.student_name,
|
||||
"start_time": self.start_time,
|
||||
"start_date": self.start_date,
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
"course_title",
|
||||
"member",
|
||||
"member_name",
|
||||
"column_break_3",
|
||||
"template",
|
||||
"column_break_vwbn",
|
||||
"issue_date",
|
||||
"template",
|
||||
"published",
|
||||
"section_break_scyf",
|
||||
"expiry_date",
|
||||
"batch_name",
|
||||
"published"
|
||||
"column_break_slaw",
|
||||
"batch_name"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -25,10 +27,6 @@
|
||||
"label": "Issue Date",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
@@ -85,11 +83,23 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "Course Title",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_vwbn",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_scyf",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_slaw",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-21 18:14:30.491841",
|
||||
"modified": "2024-07-16 15:29:19.708888",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate",
|
||||
@@ -120,13 +130,15 @@
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "LMS Student",
|
||||
"share": 1
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
|
||||
@@ -73,6 +73,8 @@ class LMSCertificate(Document):
|
||||
def has_website_permission(doc, ptype, user, verbose=False):
|
||||
if ptype in ["read", "print"]:
|
||||
return True
|
||||
if doc.member == user and ptype == "create":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -81,7 +83,9 @@ def create_certificate(course):
|
||||
certificate = is_certified(course)
|
||||
|
||||
if certificate:
|
||||
return certificate
|
||||
return frappe.db.get_value(
|
||||
"LMS Certificate", certificate, ["name", "course", "template"], as_dict=True
|
||||
)
|
||||
|
||||
else:
|
||||
expires_after_yrs = int(frappe.db.get_value("LMS Course", course, "expiry"))
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
"fieldtype": "Rating",
|
||||
"in_list_view": 1,
|
||||
"label": "Rating",
|
||||
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
|
||||
"mandatory_depends_on": "eval:doc.status == 'Pass'"
|
||||
},
|
||||
{
|
||||
"fieldname": "summary",
|
||||
@@ -107,7 +107,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-04-15 11:22:43.189908",
|
||||
"modified": "2024-07-16 14:06:11.977666",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate Evaluation",
|
||||
|
||||
@@ -26,6 +26,9 @@ class LMSCertificateRequest(Document):
|
||||
self.validate_if_existing_requests()
|
||||
self.validate_evaluation_end_date()
|
||||
|
||||
def after_insert(self):
|
||||
self.send_notification()
|
||||
|
||||
def set_evaluator(self):
|
||||
if not self.evaluator:
|
||||
self.evaluator = get_evaluator(self.course, self.batch_name)
|
||||
@@ -42,7 +45,7 @@ class LMSCertificateRequest(Document):
|
||||
):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Evaluator is unavailable from {0} to {1}. Please select a date after {1}"
|
||||
"The evaluator of this course is unavailable from {0} to {1}. Please select a date after {1}"
|
||||
).format(
|
||||
format_date(unavailable.unavailable_from, "medium"),
|
||||
format_date(unavailable.unavailable_to, "medium"),
|
||||
@@ -56,6 +59,7 @@ class LMSCertificateRequest(Document):
|
||||
"evaluator": self.evaluator,
|
||||
"date": self.date,
|
||||
"start_time": self.start_time,
|
||||
"member": ["!=", self.member],
|
||||
},
|
||||
):
|
||||
frappe.throw(_("The slot is already booked by another participant."))
|
||||
@@ -107,6 +111,35 @@ class LMSCertificateRequest(Document):
|
||||
)
|
||||
)
|
||||
|
||||
def send_notification(self):
|
||||
outgoing_email_account = frappe.get_cached_value(
|
||||
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
|
||||
)
|
||||
if outgoing_email_account or frappe.conf.get("mail_login"):
|
||||
subject = _("Your evaluation slot has been booked")
|
||||
template = "certificate_request_notification"
|
||||
|
||||
args = {
|
||||
"course": frappe.db.get_value("LMS Course", self.course, "title"),
|
||||
"timezone": frappe.db.get_value("LMS Batch", self.batch_name, "timezone")
|
||||
if self.batch_name
|
||||
else "",
|
||||
"date": format_date(self.date, "medium"),
|
||||
"member_name": self.member_name,
|
||||
"start_time": format_time(self.start_time, "short"),
|
||||
"evaluator": frappe.db.get_value("User", self.evaluator, "full_name"),
|
||||
}
|
||||
|
||||
frappe.sendmail(
|
||||
recipients=[self.member],
|
||||
cc=[self.evaluator],
|
||||
subject=subject,
|
||||
template=template,
|
||||
args=args,
|
||||
header=[subject, "green"],
|
||||
retry=3,
|
||||
)
|
||||
|
||||
|
||||
def schedule_evals():
|
||||
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
|
||||
|
||||
@@ -30,23 +30,23 @@
|
||||
"disable_self_learning",
|
||||
"section_break_18",
|
||||
"short_introduction",
|
||||
"column_break_viqw",
|
||||
"description",
|
||||
"section_break_gglp",
|
||||
"chapters",
|
||||
"related_courses",
|
||||
"pricing_tab",
|
||||
"pricing_section",
|
||||
"paid_course",
|
||||
"column_break_acoj",
|
||||
"course_price",
|
||||
"currency",
|
||||
"amount_usd",
|
||||
"certification_tab",
|
||||
"certification_section",
|
||||
"enable_certification",
|
||||
"expiry",
|
||||
"max_attempts",
|
||||
"column_break_rxww",
|
||||
"grant_certificate_after",
|
||||
"evaluator",
|
||||
"duration"
|
||||
"expiry"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -129,8 +129,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "certification_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Certification"
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@@ -170,25 +169,9 @@
|
||||
"fieldname": "column_break_10",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "enable_certification",
|
||||
"fieldname": "grant_certificate_after",
|
||||
"fieldtype": "Select",
|
||||
"label": "Grant Certificate After",
|
||||
"options": "Completion\nEvaluation"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Link",
|
||||
"label": "Evaluator",
|
||||
"mandatory_depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
||||
"options": "Course Evaluator"
|
||||
},
|
||||
{
|
||||
"fieldname": "pricing_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Pricing"
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "paid_course",
|
||||
@@ -198,20 +181,6 @@
|
||||
"mandatory_depends_on": "paid_course",
|
||||
"options": "Currency"
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
||||
"fieldname": "max_attempts",
|
||||
"fieldtype": "Int",
|
||||
"label": "Max Attempts for Evaluations"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
||||
"fieldname": "duration",
|
||||
"fieldtype": "Select",
|
||||
"label": "Duration for Attempts",
|
||||
"options": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "paid_course",
|
||||
@@ -250,6 +219,24 @@
|
||||
"fieldname": "featured",
|
||||
"fieldtype": "Check",
|
||||
"label": "Featured"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_viqw",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_gglp",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "pricing_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Pricing"
|
||||
},
|
||||
{
|
||||
"fieldname": "certification_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Certification"
|
||||
}
|
||||
],
|
||||
"is_published_field": "published",
|
||||
@@ -276,7 +263,7 @@
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2024-06-24 17:44:45.903164",
|
||||
"modified": "2024-07-12 13:54:40.474097",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
|
||||
@@ -195,7 +195,8 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-05-24 16:12:26.331351",
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2024-08-01 12:53:22.540990",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Question",
|
||||
|
||||
@@ -10,6 +10,7 @@ from lms.lms.utils import has_course_instructor_role, has_course_moderator_role
|
||||
class LMSQuestion(Document):
|
||||
def validate(self):
|
||||
validate_correct_answers(self)
|
||||
update_question_title(self)
|
||||
|
||||
|
||||
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):
|
||||
correct_options = []
|
||||
correct_option_fields = [
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
"field_order": [
|
||||
"title",
|
||||
"max_attempts",
|
||||
"limit_questions_to",
|
||||
"show_answers",
|
||||
"column_break_gaac",
|
||||
"total_marks",
|
||||
"passing_percentage",
|
||||
"section_break_hsiv",
|
||||
"show_answers",
|
||||
"column_break_rocd",
|
||||
"show_submission_history",
|
||||
"column_break_dsup",
|
||||
"section_break_tzbu",
|
||||
"shuffle_questions",
|
||||
"column_break_clsh",
|
||||
"limit_questions_to",
|
||||
"section_break_sbjx",
|
||||
"questions",
|
||||
"section_break_3",
|
||||
@@ -74,6 +73,7 @@
|
||||
"default": "1",
|
||||
"fieldname": "show_answers",
|
||||
"fieldtype": "Check",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Show Answers"
|
||||
},
|
||||
{
|
||||
@@ -90,35 +90,25 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "Show Submission History"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_hsiv",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "passing_percentage",
|
||||
"fieldtype": "Int",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Passing Percentage",
|
||||
"non_negative": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_rocd",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "total_marks",
|
||||
"fieldtype": "Int",
|
||||
"in_list_view": 1,
|
||||
"label": "Total Marks",
|
||||
"non_negative": 1,
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_dsup",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "shuffle_questions",
|
||||
@@ -126,14 +116,23 @@
|
||||
"label": "Shuffle Questions"
|
||||
},
|
||||
{
|
||||
"depends_on": "shuffle_questions",
|
||||
"fieldname": "limit_questions_to",
|
||||
"fieldtype": "Int",
|
||||
"label": "Limit Questions To"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_tzbu",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_clsh",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-27 22:03:48.576489",
|
||||
"modified": "2024-08-09 12:21:36.256522",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Quiz",
|
||||
|
||||
@@ -5,7 +5,7 @@ import json
|
||||
import frappe
|
||||
from frappe import _
|
||||
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 lms.lms.doctype.course_lesson.course_lesson import save_progress
|
||||
from lms.lms.utils import (
|
||||
@@ -30,12 +30,12 @@ class LMSQuiz(Document):
|
||||
)
|
||||
|
||||
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(
|
||||
_("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]
|
||||
if len(set(marks)) > 1:
|
||||
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):
|
||||
if self.limit_questions_to:
|
||||
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:
|
||||
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):
|
||||
if not self.name:
|
||||
@@ -90,21 +90,19 @@ def quiz_summary(quiz, results):
|
||||
|
||||
question_details = frappe.db.get_value(
|
||||
"LMS Quiz Question",
|
||||
{"parent": quiz, "idx": result["question_index"]},
|
||||
["question", "marks"],
|
||||
{"parent": quiz, "question": result["question_name"]},
|
||||
["question", "marks", "question_detail"],
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
result["question_name"] = question_details.question
|
||||
result["question"] = frappe.db.get_value(
|
||||
"LMS Question", question_details.question, "question"
|
||||
)
|
||||
result["question"] = question_details.question_detail
|
||||
marks = question_details.marks if correct else 0
|
||||
|
||||
result["marks"] = marks
|
||||
score += marks
|
||||
|
||||
del result["question_index"]
|
||||
del result["question_name"]
|
||||
|
||||
quiz_details = frappe.db.get_value(
|
||||
"LMS Quiz", quiz, ["total_marks", "passing_percentage", "lesson", "course"], as_dict=1
|
||||
@@ -297,15 +295,6 @@ def check_choice_answers(question, answers):
|
||||
|
||||
question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1)
|
||||
|
||||
""" if question_details.multiple:
|
||||
correct_answers = [ question_details[f"option_{num}"] for num in range(1,5) if question_details[f"is_correct_{num}"]]
|
||||
print(answers)
|
||||
for ans in correct_answers:
|
||||
if ans not in answers:
|
||||
is_correct.append(0)
|
||||
else:
|
||||
is_correct.append(1)
|
||||
else: """
|
||||
for num in range(1, 5):
|
||||
if question_details[f"option_{num}"] in answers:
|
||||
is_correct.append(question_details[f"is_correct_{num}"])
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"question",
|
||||
"marks"
|
||||
"column_break_qcpo",
|
||||
"marks",
|
||||
"section_break_huup",
|
||||
"question_detail"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -25,12 +28,28 @@
|
||||
"label": "Marks",
|
||||
"non_negative": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "question.question",
|
||||
"fieldname": "question_detail",
|
||||
"fieldtype": "Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Question Detail",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_qcpo",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_huup",
|
||||
"fieldtype": "Section Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-16 19:51:03.893144",
|
||||
"modified": "2024-07-29 15:10:09.662715",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Quiz Question",
|
||||
|
||||
@@ -10,14 +10,9 @@
|
||||
"column_break_zdel",
|
||||
"unsplash_access_key",
|
||||
"livecode_url",
|
||||
"course_settings_section",
|
||||
"search_placeholder",
|
||||
"column_break_iqxy",
|
||||
"portal_course_creation",
|
||||
"section_break_szgq",
|
||||
"send_calendar_invite_for_evaluations",
|
||||
"show_day_view",
|
||||
"allow_student_progress",
|
||||
"column_break_2",
|
||||
"show_dashboard",
|
||||
"show_courses",
|
||||
@@ -48,7 +43,6 @@
|
||||
"notifications",
|
||||
"section_break_qlss",
|
||||
"sidebar_items",
|
||||
"mentor_request_tab",
|
||||
"mentor_request_section",
|
||||
"mentor_request_creation",
|
||||
"mentor_request_status_update",
|
||||
@@ -98,11 +92,6 @@
|
||||
"fieldtype": "Column Break",
|
||||
"label": "Show Tab in Batch"
|
||||
},
|
||||
{
|
||||
"fieldname": "search_placeholder",
|
||||
"fieldtype": "Data",
|
||||
"label": "Course List Search Bar Placeholder"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "terms_of_use",
|
||||
@@ -139,13 +128,6 @@
|
||||
"fieldname": "column_break_12",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "Course Creator Role",
|
||||
"fieldname": "portal_course_creation",
|
||||
"fieldtype": "Select",
|
||||
"label": "Course Creation Access Through Website To",
|
||||
"options": "Course Creator Role\nAnyone"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_9",
|
||||
"fieldtype": "Column Break"
|
||||
@@ -203,19 +185,6 @@
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Signup Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "mentor_request_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"hidden": 1,
|
||||
"label": "Mentor Request"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "allow_student_progress",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Allow students to see each others progress in class"
|
||||
},
|
||||
{
|
||||
"fieldname": "payment_section",
|
||||
"fieldtype": "Section Break"
|
||||
@@ -230,15 +199,6 @@
|
||||
"fieldname": "column_break_cfcv",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "course_settings_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Course Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_iqxy",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "razorpay_key",
|
||||
"fieldtype": "Data",
|
||||
@@ -423,7 +383,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-27 21:57:02.193336",
|
||||
"modified": "2024-08-13 19:02:58.714080",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
<p> {{ _("Hey {0}").format(doc.member_name) }} </p>
|
||||
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, "medium"), frappe.utils.format_time(doc.start_time, "short"), timezone) }}</p>
|
||||
<p> {{ _("Your evaluator is {0}").format(evaluator_name) }}
|
||||
<p> {{ _("Your evaluator is {0}").format(evaluator_name) }} </p>
|
||||
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
"docstatus": 0,
|
||||
"doctype": "Notification",
|
||||
"document_type": "LMS Certificate Request",
|
||||
"enabled": 1,
|
||||
"enabled": 0,
|
||||
"event": "New",
|
||||
"idx": 0,
|
||||
"is_standard": 1,
|
||||
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }}\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
||||
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }} </p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
||||
"message_type": "HTML",
|
||||
"modified": "2024-07-10 15:51:03.429317",
|
||||
"modified_by": "sayali@erpnext.com",
|
||||
"modified": "2024-08-01 12:17:40.647724",
|
||||
"modified_by": "jannat@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "Certificate Request Creation",
|
||||
"owner": "Administrator",
|
||||
|
||||
18
lms/lms/telemetry.py
Normal file
18
lms/lms/telemetry.py
Normal 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"),
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.utils import getdate
|
||||
|
||||
from lms.lms.doctype.lms_course.test_lms_course import new_course, new_user
|
||||
|
||||
from .utils import get_evaluation_details, slugify
|
||||
from .utils import slugify
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
@@ -20,58 +16,3 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
slugify("Hello World", ["hello-world", "hello-world-2"]), "hello-world-3"
|
||||
)
|
||||
|
||||
def test_evaluation_details(self):
|
||||
user = new_user("Eval", "eval@test.com")
|
||||
|
||||
course = new_course(
|
||||
"Test Evaluation Details",
|
||||
{
|
||||
"enable_certification": 1,
|
||||
"grant_certificate_after": "Evaluation",
|
||||
"evaluator": "evaluator@example.com",
|
||||
"max_attempts": 3,
|
||||
"duration": 2,
|
||||
"instructors": [{"instructor": user.name}],
|
||||
},
|
||||
)
|
||||
|
||||
# Two evaluations failed within max attempts. Check eligibility for a third evaluation
|
||||
create_evaluation(user.name, course.name, getdate("21-03-2022"), 0.4, "Fail")
|
||||
create_evaluation(user.name, course.name, getdate("12-04-2022"), 0.4, "Fail")
|
||||
details = get_evaluation_details(course.name, user.name)
|
||||
self.assertTrue(details.eligible)
|
||||
|
||||
# Three evaluations failed within max attempts. Check eligibility for a forth evaluation
|
||||
create_evaluation(user.name, course.name, getdate("21-03-2022"), 0.4, "Fail")
|
||||
create_evaluation(user.name, course.name, getdate("12-04-2022"), 0.4, "Fail")
|
||||
create_evaluation(user.name, course.name, getdate("16-04-2022"), 0.4, "Fail")
|
||||
details = get_evaluation_details(course.name, user.name)
|
||||
self.assertFalse(details.eligible)
|
||||
|
||||
# Three evaluations failed within max attempts. Check eligibility for a forth evaluation. Different Dates
|
||||
create_evaluation(user.name, course.name, getdate("01-03-2022"), 0.4, "Fail")
|
||||
create_evaluation(user.name, course.name, getdate("12-04-2022"), 0.4, "Fail")
|
||||
create_evaluation(user.name, course.name, getdate("16-04-2022"), 0.4, "Fail")
|
||||
details = get_evaluation_details(course.name, user.name)
|
||||
self.assertFalse(details.eligible)
|
||||
|
||||
frappe.db.delete("LMS Certificate Evaluation", {"course": course.name})
|
||||
frappe.db.delete("LMS Course", course.name)
|
||||
frappe.db.delete("User", user.name)
|
||||
|
||||
|
||||
def create_evaluation(user, course, date, rating, status):
|
||||
evaluation = frappe.get_doc(
|
||||
{
|
||||
"doctype": "LMS Certificate Evaluation",
|
||||
"member": user,
|
||||
"course": course,
|
||||
"date": date,
|
||||
"start_time": "12:00:00",
|
||||
"end_time": "13:00:00",
|
||||
"rating": rating,
|
||||
"status": status,
|
||||
}
|
||||
)
|
||||
evaluation.save()
|
||||
|
||||
@@ -452,45 +452,6 @@ def get_popular_courses():
|
||||
return course_membership[:3]
|
||||
|
||||
|
||||
def get_evaluation_details(course, member=None):
|
||||
info = frappe.db.get_value(
|
||||
"LMS Course",
|
||||
course,
|
||||
["grant_certificate_after", "max_attempts", "duration"],
|
||||
as_dict=True,
|
||||
)
|
||||
request = frappe.db.get_value(
|
||||
"LMS Certificate Request",
|
||||
{
|
||||
"course": course,
|
||||
"member": member or frappe.session.user,
|
||||
"date": [">=", getdate()],
|
||||
},
|
||||
["date", "start_time", "end_time"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
no_of_attempts = frappe.db.count(
|
||||
"LMS Certificate Evaluation",
|
||||
{
|
||||
"course": course,
|
||||
"member": member or frappe.session.user,
|
||||
"status": ["!=", "Pass"],
|
||||
"creation": [">=", add_months(getdate(), -abs(cint(info.duration)))],
|
||||
},
|
||||
)
|
||||
|
||||
return frappe._dict(
|
||||
{
|
||||
"eligible": info.grant_certificate_after == "Evaluation"
|
||||
and not request
|
||||
and no_of_attempts < info.max_attempts,
|
||||
"request": request,
|
||||
"no_of_attempts": no_of_attempts,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def format_amount(amount, currency):
|
||||
amount_reduced = amount / 1000
|
||||
if amount_reduced < 1:
|
||||
@@ -556,13 +517,6 @@ def can_create_courses(course, member=None):
|
||||
if has_course_instructor_role(member) and member in instructors:
|
||||
return True
|
||||
|
||||
portal_course_creation = frappe.db.get_single_value(
|
||||
"LMS Settings", "portal_course_creation"
|
||||
)
|
||||
|
||||
if portal_course_creation == "Anyone" and member in instructors:
|
||||
return True
|
||||
|
||||
if not course and has_course_instructor_role(member):
|
||||
return True
|
||||
|
||||
@@ -612,14 +566,6 @@ def get_courses_under_review():
|
||||
)
|
||||
|
||||
|
||||
def get_certificates(member=None):
|
||||
return frappe.get_all(
|
||||
"LMS Certificate",
|
||||
{"member": member or frappe.session.user},
|
||||
["course", "member", "issue_date", "expiry_date", "name"],
|
||||
)
|
||||
|
||||
|
||||
def validate_image(path):
|
||||
if path and "/private" in path:
|
||||
file = frappe.get_doc("File", {"file_url": path})
|
||||
@@ -944,19 +890,13 @@ def has_graded_assessment(submission):
|
||||
return False if status == "Not Graded" else True
|
||||
|
||||
|
||||
def get_evaluator(course, batch=None):
|
||||
def get_evaluator(course, batch):
|
||||
evaluator = None
|
||||
|
||||
if batch:
|
||||
evaluator = frappe.db.get_value(
|
||||
"Batch Course",
|
||||
{"parent": batch, "course": course},
|
||||
"evaluator",
|
||||
)
|
||||
|
||||
if not evaluator:
|
||||
evaluator = frappe.db.get_value("LMS Course", course, "evaluator")
|
||||
|
||||
evaluator = frappe.db.get_value(
|
||||
"Batch Course",
|
||||
{"parent": batch, "course": course},
|
||||
"evaluator",
|
||||
)
|
||||
return evaluator
|
||||
|
||||
|
||||
@@ -1285,6 +1225,7 @@ def get_course_details(course):
|
||||
"course_price",
|
||||
"currency",
|
||||
"amount_usd",
|
||||
"enable_certification",
|
||||
],
|
||||
as_dict=1,
|
||||
)
|
||||
@@ -1508,6 +1449,7 @@ def get_batch_details(batch):
|
||||
"evaluation_end_date",
|
||||
"allow_self_enrollment",
|
||||
"timezone",
|
||||
"category",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"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",
|
||||
"custom_blocks": [],
|
||||
"docstatus": 0,
|
||||
@@ -145,7 +145,7 @@
|
||||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2024-06-27 21:19:06.273056",
|
||||
"modified": "2024-08-09 13:19:06.273056",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS",
|
||||
|
||||
4181
lms/locale/main.pot
4181
lms/locale/main.pot
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,10 @@ class CustomUser(User):
|
||||
super().validate()
|
||||
self.validate_username_duplicates()
|
||||
|
||||
def after_insert(self):
|
||||
super().after_insert()
|
||||
self.add_roles("LMS Student")
|
||||
|
||||
def validate_username_duplicates(self):
|
||||
while not self.username or self.username_exists():
|
||||
self.username = append_number_if_name_exists(
|
||||
|
||||
BIN
lms/public/images/desk.png
Normal file
BIN
lms/public/images/desk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -8,10 +8,11 @@
|
||||
<br>
|
||||
<p>
|
||||
<b>
|
||||
{{ _("Important Details:") }}
|
||||
{{ title }}
|
||||
</b>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b>{{ _("Batch Start Date:") }}</b> {{ frappe.utils.format_date(start_date, "medium") }}
|
||||
</p>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<p> {{ _("Hey {0}").format(member_name) }} </p>
|
||||
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, date, start_time, timezone) }}</p>
|
||||
<p> {{ _("Your evaluator is {0}").format(evaluator) }} </p>
|
||||
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>
|
||||
@@ -1,14 +0,0 @@
|
||||
{% set search_placeholder = frappe.db.get_single_value("LMS Settings", "search_placeholder") %}
|
||||
{% set portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
|
||||
|
||||
|
||||
<div class="modal fade search-modal" id="search-modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<input class="search search-course" id="search-course" placeholder="{{ _(search_placeholder) or 'Search for courses' }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script> {% include "lms/templates/search_course/search_course.js" %} </script>
|
||||
@@ -1,72 +0,0 @@
|
||||
frappe.ready(() => {
|
||||
$("#search-course").keyup((e) => {
|
||||
search_course(e);
|
||||
});
|
||||
|
||||
$("#open-search").click((e) => {
|
||||
show_search_bar(e);
|
||||
});
|
||||
|
||||
$("#search-modal").on("hidden.bs.modal", () => {
|
||||
hide_search_bar();
|
||||
});
|
||||
|
||||
$(document).keydown(function (e) {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key == "k") {
|
||||
show_search_bar(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const search_course = (e) => {
|
||||
let input = $(e.currentTarget).val();
|
||||
if (input == window.input) return;
|
||||
window.input = input;
|
||||
|
||||
if (input.length < 3 || input.trim() == "") {
|
||||
$(".result-row").remove();
|
||||
return;
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_course.lms_course.search_course",
|
||||
args: {
|
||||
text: input,
|
||||
},
|
||||
callback: (data) => {
|
||||
render_course_list(data);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const render_course_list = (data) => {
|
||||
let courses = data.message;
|
||||
$(".result-row").remove();
|
||||
|
||||
if (!courses.length) {
|
||||
let element = `<a class="result-row">
|
||||
${__("No result found")}
|
||||
</a>`;
|
||||
$(element).insertAfter("#search-course");
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i in courses) {
|
||||
let element = `<a class="result-row" href="/courses/${courses[i].name}">
|
||||
${courses[i].title}
|
||||
</a>`;
|
||||
$(element).insertAfter("#search-course");
|
||||
}
|
||||
};
|
||||
|
||||
const show_search_bar = (e) => {
|
||||
$("#search-modal").modal("show");
|
||||
setTimeout(() => {
|
||||
$("#search-course").focus();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const hide_search_bar = (e) => {
|
||||
$("#search-course").val("");
|
||||
$(".result-row").remove();
|
||||
};
|
||||
@@ -26,5 +26,8 @@
|
||||
"devDependencies": {
|
||||
"cypress": "^13.9.0",
|
||||
"cypress-file-upload": "^5.0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"pre-commit": "^1.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user