Compare commits

...

76 Commits

Author SHA1 Message Date
Frappe PR Bot
a710183bc7 chore(release): Bumped to Version 2.2.0 2024-08-14 05:57:31 +00:00
Jannat Patel
669316ba14 Merge pull request #965 from pateljannat/make-release
ci: automated release PR
2024-08-14 11:08:26 +05:30
Jannat Patel
6c18f9a02f ci: automated release PR 2024-08-14 10:44:11 +05:30
Jannat Patel
363edb9a50 Merge pull request #964 from pateljannat/settings
feat: Settings
2024-08-13 19:14:07 +05:30
Jannat Patel
afbf64170a fix: removed old settings 2024-08-13 19:03:17 +05:30
Jannat Patel
14f36d0c64 chore: removed unnecessary file 2024-08-13 18:59:39 +05:30
Jannat Patel
ceecab395b feat: settings 2024-08-13 18:53:27 +05:30
Jannat Patel
b8eb9fd717 Merge branch 'develop' of https://github.com/frappe/lms into settings 2024-08-13 09:42:17 +05:30
Jannat Patel
230a52f06b Merge pull request #963 from pateljannat/issues-31
fix: misc issues
2024-08-13 09:16:12 +05:30
Jannat Patel
3e82608d5f chore: fixed linters 2024-08-12 20:13:57 +05:30
Jannat Patel
cf2c2345c3 fix: discussions text 2024-08-12 20:10:10 +05:30
Jannat Patel
05ebe4b787 fix: lesson structure issue 2024-08-12 20:09:56 +05:30
Frappe PR Bot
a744a43d14 chore(release): Bumped to Version 2.1.0 2024-08-12 12:32:42 +00:00
Jannat Patel
5abdbfec1f Merge pull request #962 from pateljannat/posthog
chore: product analytics
2024-08-12 18:01:45 +05:30
Jannat Patel
0335b3b4d0 chore: fixed linters 2024-08-12 17:38:59 +05:30
Jannat Patel
703fafd6c3 chore: analytics 2024-08-12 17:13:31 +05:30
Jannat Patel
b956c4e383 Merge branch 'develop' of https://github.com/frappe/lms into posthog 2024-08-12 14:17:04 +05:30
Jannat Patel
d0d1fb2c8c Merge pull request #944 from pateljannat/quiz-creation
Quiz creation
2024-08-12 14:13:23 +05:30
Jannat Patel
d18a6f6e73 chore: removed workspaces from package.json 2024-08-12 13:13:21 +05:30
Jannat Patel
2994144718 feat: quiz creation from lesson form 2024-08-12 12:47:17 +05:30
Jannat Patel
62ab853605 feat: quiz creation from lesson form 2024-08-12 12:46:38 +05:30
Jannat Patel
7f7986d77a chore: fixed linters 2024-08-12 10:04:42 +05:30
Jannat Patel
61f01cc51b chore: resolved conflicts 2024-08-12 10:02:22 +05:30
Jannat Patel
86af8c6301 Merge pull request #960 from mohsinalimat/patch-1
fix: lms setting to lms settings
2024-08-09 22:21:35 +05:30
Jannat Patel
f1b0fcfbfc Merge pull request #961 from frappe/pot_develop_2024-08-09
chore: update POT file
2024-08-09 21:50:21 +05:30
frappe-pr-bot
ab5ce39645 chore: update POT file 2024-08-09 16:04:06 +00:00
Jannat Patel
685e09ce4b feat: question update 2024-08-09 20:38:14 +05:30
MohsinAli
8ed4f775e5 fix: lms setting to lms settings 2024-08-09 13:58:50 +05:30
Jannat Patel
a3a3085b1f fix: update question title in quiz 2024-08-08 22:16:21 +05:30
Jannat Patel
ed97640107 feat: allow updating questions 2024-08-07 18:15:50 +05:30
Jannat Patel
a9e93a679b feat: posthog initialization 2024-08-07 11:31:58 +05:30
Jannat Patel
418c36c09f Merge pull request #957 from frappe/pot_develop_2024-08-06
chore: update POT file
2024-08-06 12:17:49 +05:30
frappe-pr-bot
935f7f1f7b chore: update POT file 2024-08-06 06:32:08 +00:00
Jannat Patel
9a0056b6ca Merge branch 'develop' of https://github.com/frappe/lms into develop 2024-08-06 11:50:23 +05:30
Jannat Patel
cd56da5d85 fix: changed upstream command for pot file generation 2024-08-06 11:47:37 +05:30
Jannat Patel
97d5d853fc Merge pull request #955 from pateljannat/issues-30
fix: lesson auto save
2024-08-06 11:11:50 +05:30
Jannat Patel
8adfe247b2 fix: lesson auto save 2024-08-05 18:14:35 +05:30
Jannat Patel
afe7df2989 fix: fetch question 2024-08-05 16:29:43 +05:30
Jannat Patel
cdb028c69c feat: settings 2024-08-05 15:12:45 +05:30
Jannat Patel
eed330662b Merge pull request #953 from pateljannat/issues-29
fix: course cards home page rendering
2024-08-05 14:20:36 +05:30
Jannat Patel
26db10bbe0 fix: course cards home page rendering 2024-08-05 14:04:08 +05:30
Jannat Patel
14230bd588 Merge pull request #951 from pateljannat/issues-28
fix: spacing and widths
2024-08-05 11:32:12 +05:30
Jannat Patel
699c821edd fix: spacing and widths 2024-08-05 11:12:34 +05:30
Jannat Patel
27ca13ece6 feat: add questions to quiz 2024-08-02 20:20:43 +05:30
Jannat Patel
6820dfc820 fix: make question attachments public 2024-08-01 13:02:20 +05:30
Jannat Patel
471e7d9229 fix: fetch question details 2024-08-01 13:00:37 +05:30
Jannat Patel
e0855a2c1b fix: quiz question population issue 2024-07-31 22:30:29 +05:30
Jannat Patel
6a0b37a4d4 chore: changed release branch to develop 2024-07-31 12:43:04 +05:30
Jannat Patel
f7fd6916e2 chore: release notes action 2024-07-31 12:15:24 +05:30
Jannat Patel
30e61f4b7c Merge pull request #947 from pateljannat/semantic-release
chore: semantic release action
2024-07-31 11:45:42 +05:30
Jannat Patel
48b37d58d8 chore: semantic release action 2024-07-31 11:10:47 +05:30
Jannat Patel
b8c3bdc0b4 feat: open modal to edit question 2024-07-31 11:07:46 +05:30
Jannat Patel
e96f18df7c Merge pull request #946 from pateljannat/issues-27
fix: quiz shuffle issue
2024-07-30 18:04:26 +05:30
Jannat Patel
7d15527831 fix: quiz shuffle issue 2024-07-30 16:58:09 +05:30
Jannat Patel
794c0e760b Merge pull request #945 from pateljannat/issues-26
fix: eval request issues
2024-07-30 15:26:46 +05:30
Jannat Patel
e46a60d00a chore: linters 2024-07-30 15:05:24 +05:30
Jannat Patel
819aac70fd fix: linters 2024-07-30 14:54:21 +05:30
Jannat Patel
ed7db2d7c5 fix: eval request issues 2024-07-30 14:17:17 +05:30
Jannat Patel
a450c846a6 feat: questions table 2024-07-29 19:44:04 +05:30
Jannat Patel
fa774b0db2 feat: quiz creation 2024-07-19 20:05:28 +05:30
Jannat Patel
98a56f9117 Merge pull request #936 from pateljannat/image-pasting
fix: batch filters on desk
2024-07-19 12:19:34 +05:30
Jannat Patel
cbc4b8c59d chore: removed unused plugin 2024-07-19 12:07:35 +05:30
Jannat Patel
69d266e018 feat: image pasting 2024-07-19 11:55:36 +05:30
Jannat Patel
4bc3ac1665 fix: batch filters on desk 2024-07-18 21:29:40 +05:30
Jannat Patel
e0de9d70de Merge pull request #933 from pateljannat/issues-25
fix: misc issues
2024-07-17 11:40:35 +05:30
Jannat Patel
493bab8163 fix: multiline tags 2024-07-17 11:29:14 +05:30
Jannat Patel
25a2d82e82 fix: misc issues 2024-07-16 16:11:24 +05:30
Jannat Patel
0183677494 Merge pull request #932 from pateljannat/batch-categories
feat: batch categories filter
2024-07-15 14:45:57 +05:30
Jannat Patel
7ae9244896 feat: batch categories filter 2024-07-15 13:45:38 +05:30
Jannat Patel
15330cb41d Merge pull request #928 from pateljannat/completion-certificate
feat: completion certificate
2024-07-12 20:36:06 +05:30
Jannat Patel
166996d77a chore: removed unnecessary lines 2024-07-12 20:17:42 +05:30
Jannat Patel
4943e0e902 chore: fixed linters 2024-07-12 19:58:52 +05:30
Jannat Patel
1db6a8bfda chore: fixed linters 2024-07-12 19:56:01 +05:30
Jannat Patel
57f43b256a feat: enable certification from course form 2024-07-12 19:46:45 +05:30
Jannat Patel
23b2e8d682 feat: generate certificate from course page 2024-07-12 15:56:50 +05:30
Jannat Patel
6e1d62340f feat: completion certificate 2024-07-11 18:12:15 +05:30
82 changed files with 3761 additions and 3880 deletions

View File

@@ -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")

View File

@@ -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
View 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
View File

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

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

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

3
.gitignore vendored
View File

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

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "frappe-ui"]
path = frappe-ui
url = https://github.com/pateljannat/frappe-ui

21
.releaserc Normal file
View File

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

View File

@@ -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

View File

@@ -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",

View File

@@ -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>

View File

@@ -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

View File

@@ -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;
}

View File

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

View File

@@ -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>

View File

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

View File

@@ -13,6 +13,7 @@
<script setup>
import { Star } from 'lucide-vue-next'
import { ref } from 'vue'
const props = defineProps({
id: {
type: String,

View File

@@ -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>

View File

@@ -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>

View File

@@ -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,

View File

@@ -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'

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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 },
{

View File

@@ -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')

View File

@@ -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,
})

View 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>

View File

@@ -0,0 +1,270 @@
<template>
<Dialog v-model="show" :options="{ size: '6xl' }">
<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 class="flex flex-1 flex-col overflow-y-auto">
<SettingDetails
v-if="activeTab && data.doc"
:fields="activeTab.fields"
: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'
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: 'Payment Gateway',
icon: 'DollarSign',
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 amount',
name: 'apply_rounding',
type: 'checkbox',
},
],
},
],
},
{
label: 'Settings',
hideLabel: true,
items: [
{
label: 'Signup',
icon: 'LogIn',
fields: [
{
label: 'Show terms of use on signup page',
name: 'terms_of_use',
type: 'checkbox',
},
{
label: 'Terms of Use Page',
name: 'terms_page',
type: 'Link',
doctype: 'Web Page',
},
{
label: 'Ask user category during signup',
name: 'user_category',
type: 'checkbox',
},
{
type: 'Column Break',
},
{
label: 'Show privacy policy on signup page',
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 page',
name: 'cookie_policy',
type: 'checkbox',
},
{
label: 'Cookie Policy Page',
name: 'cookie_policy_page',
type: 'Link',
doctype: 'Web Page',
},
],
},
],
},
{
label: 'Settings',
hideLabel: true,
items: [
{
label: 'Sidebar',
icon: 'PanelLeftIcon',
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',
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: 'Members',
icon: "UserRoundPlus",
component: markRaw(MemberSettings),
},
],
}, */
]
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>

View File

@@ -3,9 +3,7 @@
<div class="bg-blue-100 py-2 px-2 mb-4 rounded-md text-sm text-blue-800">
<div class="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()
}
@@ -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 = () => {

View File

@@ -0,0 +1,89 @@
<template>
<div class="flex flex-col justify-between h-full p-8">
<div class="flex space-x-10">
<div v-for="(column, index) in columns" :key="index">
<div class="flex flex-col space-y-4">
<div v-for="field in column" :class="width">
<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, ref } from 'vue'
import Link from '@/components/Controls/Link.vue'
let width = ref('w-full')
const props = defineProps({
fields: {
type: Array,
required: true,
},
data: {
type: Object,
required: true,
},
})
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)
}
if (cols.length == 3) {
width.value = 'w-64'
} else {
width.value = 'w-96'
}
return cols
})
const update = () => {
props.fields.forEach((f) => {
props.data.doc[f.name] = f.value
})
props.data.save.submit()
}
</script>

View File

@@ -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,6 +56,10 @@
</button>
</template>
</Dropdown>
<SettingsModal
v-if="userResource.data?.is_moderator"
v-model="showSettingsModal"
/>
</template>
<script setup>
@@ -68,12 +72,16 @@ import {
LogOut,
User,
ArrowRightLeft,
Settings,
} from 'lucide-vue-next'
import { useRouter } from 'vue-router'
import { convertToTitleCase } from '../utils'
import { usersStore } from '@/stores/user'
import { ref } 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()
@@ -109,6 +117,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',

View File

@@ -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>

View File

@@ -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
})

View File

@@ -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',

View File

@@ -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>

View File

@@ -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
})

View File

@@ -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]

View File

@@ -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>

View File

@@ -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) => {

View File

@@ -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;
}

View File

@@ -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>

View 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>

View 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>

View File

@@ -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({

View File

@@ -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,
}
})

View File

@@ -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
View File

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

View File

@@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui'
export default function translationPlugin(app) {
app.config.globalProperties.__ = translate
window.__ = translate
if (!window.translatedMessages) fetchTranslations()
}

View File

@@ -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/,
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>",
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]
)
}

View File

@@ -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==

View File

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

View File

@@ -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": [],
}

View File

@@ -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,21 @@ 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

View File

@@ -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

View File

@@ -86,7 +86,6 @@
"label": "Comments"
},
{
"fetch_from": "course.evaluator",
"fieldname": "evaluator",
"fieldtype": "Link",
"label": "Evaluator",

View File

@@ -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",

View File

@@ -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,

View File

@@ -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",

View File

@@ -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"))

View File

@@ -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",

View File

@@ -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"):

View File

@@ -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",

View File

@@ -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",

View File

@@ -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 = [

View File

@@ -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",

View File

@@ -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:

View File

@@ -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",

View File

@@ -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",

View File

@@ -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>

View File

@@ -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
View File

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

View File

@@ -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()

View File

@@ -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,
)

View File

@@ -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",
@@ -213,4 +213,4 @@
}
],
"title": "LMS"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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();
};

View File

@@ -26,5 +26,8 @@
"devDependencies": {
"cypress": "^13.9.0",
"cypress-file-upload": "^5.0.8"
},
"dependencies": {
"pre-commit": "^1.2.2"
}
}

511
yarn.lock

File diff suppressed because it is too large Load Diff