From b7dd48888664a2efb101d6caeeb90d61e1722862 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 27 May 2024 15:30:15 +0530 Subject: [PATCH] feat: featured courses --- frontend/src/components/CourseCard.vue | 9 ++ frontend/src/components/CourseOutline.vue | 2 +- frontend/src/pages/CertifiedParticipants.vue | 3 - frontend/src/pages/Courses.vue | 7 -- frontend/src/pages/CreateCourse.vue | 87 ++++++++++++++------ frontend/src/pages/Statistics.vue | 11 +-- frontend/src/utils/index.js | 6 ++ lms/lms/api.py | 1 + lms/lms/doctype/lms_course/lms_course.json | 14 ++-- lms/lms/utils.py | 3 + lms/public/frontend/index.html | 6 +- lms/www/lms.py | 18 ++++ 12 files changed, 115 insertions(+), 52 deletions(-) diff --git a/frontend/src/components/CourseCard.vue b/frontend/src/components/CourseCard.vue index 8a4acdaa..443420cb 100644 --- a/frontend/src/components/CourseCard.vue +++ b/frontend/src/components/CourseCard.vue @@ -10,6 +10,15 @@ :style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }" >
+ + {{ __('Featured') }} +
{{ __(title) }} diff --git a/frontend/src/pages/CertifiedParticipants.vue b/frontend/src/pages/CertifiedParticipants.vue index b7bec2c4..3784ef55 100644 --- a/frontend/src/pages/CertifiedParticipants.vue +++ b/frontend/src/pages/CertifiedParticipants.vue @@ -38,9 +38,6 @@ {{ participant.full_name }}
-
- {{ __('is certified for') }} -
{{ course }}
diff --git a/frontend/src/pages/Courses.vue b/frontend/src/pages/Courses.vue index aed682d8..ee8f8527 100644 --- a/frontend/src/pages/Courses.vue +++ b/frontend/src/pages/Courses.vue @@ -26,14 +26,7 @@
-
- {{ __('Loading Courses...') }} -
{{ __('Settings') }}
-
- - - +
+
+ + +
+
+ + + +
-
@@ -196,11 +205,18 @@ import { TextEditor, Button, createResource, - createDocumentResource, FormControl, FileUploader, } from 'frappe-ui' -import { inject, onMounted, computed, ref, reactive, watch } from 'vue' +import { + inject, + onMounted, + onBeforeUnmount, + computed, + ref, + reactive, + watch, +} from 'vue' import { convertToTitleCase, showToast, getFileSize } from '../utils' import Link from '@/components/Controls/Link.vue' import { FileText, X } from 'lucide-vue-next' @@ -227,6 +243,7 @@ const course = reactive({ tags: '', published: false, published_on: '', + featured: false, upcoming: false, disable_self_learning: false, paid_course: false, @@ -246,6 +263,22 @@ onMounted(() => { if (props.courseName !== 'new') { courseResource.reload() } + window.addEventListener('keydown', keyboardShortcut) +}) + +const keyboardShortcut = (e) => { + if ( + e.key === 's' && + (e.ctrlKey || e.metaKey) && + !e.target.classList.contains('ProseMirror') + ) { + submitCourse() + e.preventDefault() + } +} + +onBeforeUnmount(() => { + window.removeEventListener('keydown', keyboardShortcut) }) const courseCreationResource = createResource({ diff --git a/frontend/src/pages/Statistics.vue b/frontend/src/pages/Statistics.vue index 89269ba8..c71a531b 100644 --- a/frontend/src/pages/Statistics.vue +++ b/frontend/src/pages/Statistics.vue @@ -13,7 +13,7 @@
- {{ chartDetails.data.courses }} + {{ formatNumber(chartDetails.data.courses) }}
{{ __('Published Courses') }} @@ -26,7 +26,7 @@
- {{ chartDetails.data.users }} + {{ formatNumber(chartDetails.data.users) }}
{{ __('Total Signups') }} @@ -39,7 +39,7 @@
- {{ chartDetails.data.enrollments }} + {{ formatNumber(chartDetails.data.enrollments) }}
{{ __('Enrolled Users') }} @@ -52,7 +52,7 @@
- {{ chartDetails.data.completions }} + {{ formatNumber(chartDetails.data.completions) }}
{{ __('Courses Completed') }} @@ -65,7 +65,7 @@
- {{ chartDetails.data.lesson_completions }} + {{ formatNumber(chartDetails.data.lesson_completions) }}
{{ __('Lessons Completed') }} @@ -109,6 +109,7 @@ - + + - +
diff --git a/lms/www/lms.py b/lms/www/lms.py index dff65c13..38d93fc0 100644 --- a/lms/www/lms.py +++ b/lms/www/lms.py @@ -112,3 +112,21 @@ def get_meta(app_path): "keywords": "Enrollment Count, Completion, Signups", "link": "/statistics", } + + if re.match(r"^user/.*$", app_path): + username = app_path.split("/")[1] + user = frappe.db.get_value( + "User", + { + "username": username, + }, + ["full_name", "user_image", "bio"], + as_dict=True, + ) + return { + "title": user.full_name, + "image": user.user_image, + "description": user.bio, + "keywords": f"{user.full_name}, {user.bio}", + "link": f"/user/{username}", + }