Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
FahidLatheef committed Nov 9, 2024
2 parents 9dbe8fb + c5f091f commit 8226031
Show file tree
Hide file tree
Showing 37 changed files with 2,600 additions and 1,297 deletions.
25 changes: 8 additions & 17 deletions frontend/src/components/Annoucements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
</template>
<script setup>
import { createListResource, Avatar } from 'frappe-ui'
import { createResource, Avatar } from 'frappe-ui'
import { timeAgo } from '@/utils'
const props = defineProps({
Expand All @@ -35,24 +35,15 @@ const props = defineProps({
},
})
const communications = createListResource({
doctype: 'Communication',
fields: [
'subject',
'content',
'recipients',
'cc',
'communication_date',
'sender',
'sender_full_name',
],
filters: {
reference_doctype: 'LMS Batch',
reference_name: props.batch,
const communications = createResource({
url: 'lms.lms.api.get_announcements',
makeParams(value) {
return {
batch: props.batch,
}
},
orderBy: 'communication_date desc',
auto: true,
cache: ['batch', props.batch],
cache: ['announcement', props.batch],
})
</script>
<style>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/CourseCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
>
<div
class="flex items-center flex-wrap space-y-1 space-x-1 relative top-4 px-2 w-fit"
class="flex items-center flex-wrap 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"
variant="subtle"
theme="gray"
size="md"
v-for="tag in course.tags"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/LiveClass.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<a
:href="cls.join_url"
target="_blank"
class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
class="w-full cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
>
<Video class="h-4 w-4 stroke-1.5" />
{{ __('Join') }}
Expand Down
22 changes: 7 additions & 15 deletions frontend/src/components/Modals/AnnouncementModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<script setup>
import { Dialog, Input, TextEditor, createResource } from 'frappe-ui'
import { reactive } from 'vue'
import { createToast } from '@/utils/'
import { showToast } from '@/utils/'
const show = defineModel()
Expand Down Expand Up @@ -94,22 +94,14 @@ const makeAnnouncement = (close) => {
},
onSuccess() {
close()
createToast({
title: 'Success',
text: 'Announcement has been sent successfully',
icon: 'Check',
iconClasses: 'bg-green-600 text-white rounded-md p-px',
})
showToast(
__('Success'),
__('Announcement has been sent successfully'),
'check'
)
},
onError(err) {
createToast({
title: 'Error',
text: err.messages?.[0] || err,
icon: 'x',
iconClasses: 'bg-red-600 text-white rounded-md p-px',
position: 'top-center',
timeout: 10,
})
showToast(__('Error'), __(err.messages?.[0] || err), 'check')
},
}
)
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/components/Modals/EvaluationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ function submitEvaluation(close) {
const getCourses = () => {
let courses = []
for (const course of props.courses) {
courses.push({
label: course.title,
value: course.course,
})
if (course.evaluator) {
courses.push({
label: course.title,
value: course.course,
})
}
}
return courses
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Batch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const breadcrumbs = computed(() => {
const isStudent = computed(() => {
return (
user?.data &&
batch.data?.students.length &&
batch.data?.students?.length &&
batch.data?.students.includes(user.data.name)
)
})
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/BatchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
v-model="instructors"
doctype="User"
:label="__('Instructors')"
:filters="{ ignore_user_type: 1 }"
/>
<div class="mb-4">
<FormControl
Expand Down
67 changes: 44 additions & 23 deletions frontend/src/pages/CourseForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
>
<Breadcrumbs class="h-7" :items="breadcrumbs" />
<div class="flex items-center mt-3 md:mt-0">
<Button v-if="courseResource.data?.name" @click="trashCourse()">
<template #prefix>
<Trash2 class="w-4 h-4 stroke-1.5" />
</template>
<span>
{{ __('Delete') }}
</span>
</Button>
<Button variant="solid" @click="submitCourse()" class="ml-2">
<span>
{{ __('Save') }}
Expand Down Expand Up @@ -144,6 +152,7 @@
v-model="instructors"
doctype="User"
:label="__('Instructors')"
:filters="{ ignore_user_type: 1 }"
:required="true"
/>
</div>
Expand Down Expand Up @@ -247,15 +256,11 @@ import {
ref,
reactive,
watch,
getCurrentInstance,
} from 'vue'
import {
convertToTitleCase,
showToast,
getFileSize,
updateDocumentTitle,
} from '@/utils'
import { showToast, updateDocumentTitle } from '@/utils'
import Link from '@/components/Controls/Link.vue'
import { FileText, Image, X } from 'lucide-vue-next'
import { Image, Trash2, X } from 'lucide-vue-next'
import { useRouter } from 'vue-router'
import CourseOutline from '@/components/CourseOutline.vue'
import MultiSelect from '@/components/Controls/MultiSelect.vue'
Expand All @@ -267,6 +272,8 @@ const newTag = ref('')
const router = useRouter()
const instructors = ref([])
const settingsStore = useSettings()
const app = getCurrentInstance()
const { $dialog } = app.appContext.config.globalProperties
const props = defineProps({
courseName: {
Expand Down Expand Up @@ -439,23 +446,37 @@ const submitCourse = () => {
}
}
const validateMandatoryFields = () => {
const mandatory_fields = [
'title',
'short_introduction',
'description',
'video_link',
'course_image',
]
for (const field of mandatory_fields) {
if (!course[field]) {
let fieldLabel = convertToTitleCase(field.split('_').join(' '))
return `${fieldLabel} is mandatory`
const deleteCourse = createResource({
url: 'lms.lms.api.delete_course',
makeParams(values) {
return {
course: props.courseName,
}
}
if (course.paid_course && (!course.course_price || !course.currency)) {
return __('Course price and currency are mandatory for paid courses')
}
},
onSuccess() {
showToast(__('Success'), __('Course deleted successfully'), 'check')
router.push({ name: 'Courses' })
},
})
const trashCourse = () => {
$dialog({
title: __('Delete Course'),
message: __(
'Deleting the course will also delete all its chapters and lessons. Are you sure you want to delete this course?'
),
actions: [
{
label: __('Delete'),
theme: 'red',
variant: 'solid',
onClick(close) {
deleteCourse.submit()
close()
},
},
],
})
}
watch(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Courses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<div class="text-xl font-medium">
{{ __('No courses found') }}
</div>
<div>
<div class="leading-5">
{{
__(
'There are no courses available at the moment. Keep an eye out, fresh learning experiences are on the way soon!'
Expand Down
42 changes: 33 additions & 9 deletions frontend/src/pages/Lesson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
)
}}
</p>
<router-link
v-if="user.data"
:to="{ name: 'CourseDetail', params: { courseName: courseName } }"
>
<Button variant="solid">
{{ __('Start Learning') }}
</Button>
</router-link>
<Button v-if="user.data" @click="enrollStudent()" variant="solid">
{{ __('Start Learning') }}
</Button>
<Button v-else @click="redirectToLogin()">
{{ __('Login') }}
</Button>
Expand Down Expand Up @@ -194,7 +189,7 @@ import { createResource, Breadcrumbs, Button } from 'frappe-ui'
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'
import { useRouter, useRoute } from 'vue-router'
import { ChevronLeft, ChevronRight } from 'lucide-vue-next'
import Discussions from '@/components/Discussions.vue'
import { getEditorTools, updateDocumentTitle } from '../utils'
Expand All @@ -204,6 +199,7 @@ import CourseInstructors from '@/components/CourseInstructors.vue'
import ProgressBar from '@/components/ProgressBar.vue'
const user = inject('$user')
const router = useRouter()
const route = useRoute()
const allowDiscussions = ref(false)
const editor = ref(null)
Expand Down Expand Up @@ -243,6 +239,10 @@ const lesson = createResource({
},
auto: true,
onSuccess(data) {
if (Object.keys(data).length === 0) {
router.push({ name: 'Courses' })
return
}
lessonProgress.value = data.membership?.progress
if (data.content) editor.value = renderEditor('editor', data.content)
if (
Expand Down Expand Up @@ -379,6 +379,30 @@ const allowInstructorContent = () => {
return false
}
const enrollment = createResource({
url: 'frappe.client.insert',
makeParams() {
return {
doc: {
doctype: 'LMS Enrollment',
course: props.courseName,
member: user.data?.name,
},
}
},
})
const enrollStudent = () => {
enrollment.submit(
{},
{
onSuccess() {
window.location.reload()
},
}
)
}
const redirectToLogin = () => {
window.location.href = `/login?redirect-to=/lms/courses/${props.courseName}`
}
Expand Down
18 changes: 17 additions & 1 deletion frontend/src/pages/Quizzes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
</ListRows>
</ListView>
</div>
<div
v-else
class="text-center p-5 text-gray-600 mt-52 w-3/4 md:w-1/2 mx-auto space-y-2"
>
<BookOpen class="size-10 mx-auto stroke-1 text-gray-500" />
<div class="text-xl font-medium">
{{ __('No quizzes found') }}
</div>
<div class="leading-5">
{{
__(
'You have not created any quizzes yet. To create a new quiz, click on the "New Quiz" button above.'
)
}}
</div>
</div>
</template>
<script setup>
import {
Expand All @@ -61,7 +77,7 @@ import {
} from 'frappe-ui'
import { useRouter } from 'vue-router'
import { computed, inject, onMounted } from 'vue'
import { Plus } from 'lucide-vue-next'
import { BookOpen, Plus } from 'lucide-vue-next'
import { updateDocumentTitle } from '@/utils'
const user = inject('$user')
Expand Down
2 changes: 1 addition & 1 deletion lms/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.9.0"
__version__ = "2.10.0"
2 changes: 2 additions & 0 deletions lms/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import frappe
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
from lms.lms.api import give_dicussions_permission


def after_install():
add_pages_to_nav()
create_batch_source()
give_dicussions_permission()


def after_sync():
Expand Down
Loading

0 comments on commit 8226031

Please sign in to comment.