Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yarin-zhang authored Nov 22, 2024
2 parents 4ee1693 + 7cafaf5 commit cb324f6
Show file tree
Hide file tree
Showing 56 changed files with 3,644 additions and 1,536 deletions.
26 changes: 25 additions & 1 deletion frontend/src/components/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import { getSidebarLinks } from '../utils'
import { usersStore } from '@/stores/user'
import { sessionStore } from '@/stores/session'
import { useSidebar } from '@/stores/sidebar'
import { useSettings } from '@/stores/settings'
import { ChevronRight, Plus } from 'lucide-vue-next'
import { createResource, Button } from 'frappe-ui'
import PageModal from '@/components/Modals/PageModal.vue'
Expand All @@ -114,6 +115,7 @@ const isModerator = ref(false)
const isInstructor = ref(false)
const pageToEdit = ref(null)
const showWebPages = ref(false)
const settingsStore = useSettings()
onMounted(() => {
socket.on('publish_lms_notifications', (data) => {
Expand Down Expand Up @@ -183,6 +185,28 @@ const addQuizzes = () => {
}
}
const addPrograms = () => {
if (settingsStore.learningPaths.data) {
let activeFor = ['Programs', 'ProgramForm']
let index = 1
if (!isInstructor.value && !isModerator.value) {
sidebarLinks.value = sidebarLinks.value.filter(
(link) => link.label !== 'Courses'
)
activeFor.push('CourseDetail')
activeFor.push('Lesson')
index = 0
}
sidebarLinks.value.splice(index, 0, {
label: 'Programs',
icon: 'Route',
to: 'Programs',
activeFor: activeFor,
})
}
}
const openPageModal = (link) => {
showPageModal.value = true
pageToEdit.value = link
Expand Down Expand Up @@ -215,11 +239,11 @@ watch(userResource, () => {
isModerator.value = userResource.data.is_moderator
isInstructor.value = userResource.data.is_instructor
addQuizzes()
addPrograms()
}
})
const toggleSidebar = () => {
console.log(sidebarStore.isSidebarCollapsed)
sidebarStore.isSidebarCollapsed = !sidebarStore.isSidebarCollapsed
}
</script>
2 changes: 1 addition & 1 deletion frontend/src/components/Controls/Autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
{{ option.label }}
</div>
<div
v-if="option.label != option.description"
v-if="option.description"
class="text-xs text-gray-700"
v-html="option.description"
></div>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/Controls/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</div>
</template>
</Autocomplete>
<p v-if="description" class="text-sm text-gray-600">{{ description }}</p>
</div>
</template>

Expand All @@ -67,6 +68,10 @@ const props = defineProps({
type: String,
default: '',
},
description: {
type: String,
default: '',
},
})
const emit = defineEmits(['update:modelValue', 'change'])
Expand Down Expand Up @@ -118,7 +123,7 @@ const options = createResource({
transform: (data) => {
return data.map((option) => {
return {
label: option.value,
label: option.label || option.value,
value: option.value,
description: option.description,
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CourseOutline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ const trashChapter = (chapterName) => {
}
const redirectToChapter = (chapter) => {
if (!chapter.is_scorm_package) return
event.preventDefault()
if (props.allowEdit) return
if (!chapter.is_scorm_package) return
if (!user.data) {
showToast(
__('You are not enrolled'),
Expand Down
30 changes: 11 additions & 19 deletions frontend/src/components/Modals/ChapterModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
>
<template #body-content>
<div class="space-y-4 text-base">
<FormControl
ref="chapterInput"
label="Title"
v-model="chapter.title"
:required="true"
/>
<FormControl
:label="__('Is SCORM Package')"
<FormControl label="Title" v-model="chapter.title" :required="true" />
<Switch
size="sm"
:label="__('SCORM Package')"
:description="
__(
'Enable this only if you want to upload a SCORM package as a chapter.'
)
"
v-model="chapter.is_scorm_package"
type="checkbox"
/>
<div v-if="chapter.is_scorm_package">
<FileUploader
Expand Down Expand Up @@ -75,15 +75,15 @@ import {
Dialog,
FileUploader,
FormControl,
Switch,
} from 'frappe-ui'
import { defineModel, reactive, watch, ref } from 'vue'
import { defineModel, reactive, watch } from 'vue'
import { showToast, getFileSize } from '@/utils/'
import { capture } from '@/telemetry'
import { FileText, X } from 'lucide-vue-next'
const show = defineModel()
const outline = defineModel('outline')
const chapterInput = ref(null)
const props = defineProps({
course: {
Expand Down Expand Up @@ -209,14 +209,6 @@ watch(
}
)
/* watch(show, () => {
if (show.value) {
setTimeout(() => {
chapterInput.value.$el.querySelector('input').focus()
}, 100)
}
}) */
const validateFile = (file) => {
let extension = file.name.split('.').pop().toLowerCase()
if (extension !== 'zip') {
Expand Down
31 changes: 20 additions & 11 deletions frontend/src/components/Modals/LiveClassModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,34 @@ const submitLiveClass = (close) => {
return createLiveClass.submit(liveClass, {
validate() {
if (!liveClass.title) {
return 'Please enter a title.'
return __('Please enter a title.')
}
if (!liveClass.date) {
return 'Please select a date.'
}
if (dayjs(liveClass.date).isSameOrBefore(dayjs(), 'day')) {
return 'Please select a future date.'
return __('Please select a date.')
}
if (!liveClass.time) {
return 'Please select a time.'
return __('Please select a time.')
}
if (!liveClass.timezone) {
return __('Please select a timezone.')
}
if (!valideTime()) {
return 'Please enter a valid time in the format HH:mm.'
return __('Please enter a valid time in the format HH:mm.')
}
if (!liveClass.duration) {
return 'Please select a duration.'
const liveClassDateTime = dayjs(`${liveClass.date}T${liveClass.time}`).tz(
liveClass.timezone,
true
)
if (
liveClassDateTime.isSameOrBefore(
dayjs().tz(liveClass.timezone, false),
'minute'
)
) {
return __('Please select a future date and time.')
}
if (!liveClass.timezone) {
return 'Please select a timezone.'
if (!liveClass.duration) {
return __('Please select a duration.')
}
},
onSuccess() {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/Modals/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
id="existing"
value="existing"
v-model="questionType"
class="w-3 h-3 accent-gray-900"
class="w-3 h-3 cursor-pointer"
/>
<label for="existing">
<label for="existing" class="cursor-pointer">
{{ __('Add an existing question') }}
</label>
</div>
Expand All @@ -25,9 +25,9 @@
id="new"
value="new"
v-model="questionType"
class="w-3 h-3"
class="w-3 h-3 cursor-pointer"
/>
<label for="new">
<label for="new" class="cursor-pointer">
{{ __('Create a new question') }}
</label>
</div>
Expand Down Expand Up @@ -127,7 +127,7 @@ const populateFields = () => {
let counter = 1
fields.forEach((field) => {
while (counter <= 4) {
question[`${field}_${counter}`] = field === 'is_correct' ? false : ''
question[`${field}_${counter}`] = field === 'is_correct' ? false : null
counter++
}
})
Expand Down
37 changes: 32 additions & 5 deletions frontend/src/components/Modals/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,31 @@ const tabsStructure = computed(() => {
hideLabel: true,
items: [
{
label: 'Members',
description: 'Manage the members of your learning system',
icon: 'UserRoundPlus',
label: 'General',
icon: 'Wrench',
fields: [
{
label: 'Enable Learning Paths',
name: 'enable_learning_paths',
description:
'This will enforce students to go through programs assigned to them in the correct order.',
type: 'checkbox',
},
{
label: 'Send calendar invite for evaluations',
name: 'send_calendar_invite_for_evaluations',
description:
'If enabled, it sends google calendar invite to the student for evaluations.',
type: 'checkbox',
},
{
label: 'Unsplash Access Key',
name: 'unsplash_access_key',
description:
'Optional. If this is set, students can pick a cover image from the unsplash library for their profile page. https://unsplash.com/documentation#getting-started.',
type: 'text',
},
],
},
],
},
Expand Down Expand Up @@ -156,9 +178,14 @@ const tabsStructure = computed(() => {
],
},
{
label: 'Settings',
hideLabel: true,
label: 'Lists',
hideLabel: false,
items: [
{
label: 'Members',
description: 'Manage the members of your learning system',
icon: 'UserRoundPlus',
},
{
label: 'Categories',
description: 'Manage the members of your learning system',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Quiz.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ const attempts = createResource({
watch(
() => quiz.data,
() => {
if (quiz.data) {
populateQuestions()
}
if (quiz.data && quiz.data.max_attempts) {
attempts.reload()
resetQuiz()
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/SettingDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<script setup>
import { Button, Badge } from 'frappe-ui'
import SettingFields from '@/components/SettingFields.vue'
import { showToast } from '@/utils'
const props = defineProps({
fields: {
Expand All @@ -54,7 +55,14 @@ const update = () => {
props.data.doc[f.name] = f.value
}
})
props.data.save.submit()
props.data.save.submit(
{},
{
onError(err) {
showToast('Error', err.messages?.[0] || err, 'x')
},
}
)
}
</script>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/SettingFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
:type="field.type"
:rows="field.rows"
:options="field.options"
:description="field.description"
/>
</div>
</div>
Expand All @@ -100,7 +101,7 @@
import { FormControl, FileUploader, Button, Switch } from 'frappe-ui'
import { computed } from 'vue'
import { getFileSize, validateFile } from '@/utils'
import { X, FileText } from 'lucide-vue-next'
import { X } from 'lucide-vue-next'
import Link from '@/components/Controls/Link.vue'
import CodeEditor from '@/components/Controls/CodeEditor.vue'
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/SidebarLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
>
<div
class="flex items-center w-full duration-300 ease-in-out group"
:class="isCollapsed ? 'p-1' : 'px-2 py-1'"
:class="isCollapsed ? 'p-1 relative' : 'px-2 py-1'"
>
<Tooltip :text="link.label" placement="right">
<slot name="icon">
Expand All @@ -29,7 +29,15 @@
>
{{ __(link.label) }}
</span>
<span v-if="link.count" class="!ml-auto block text-xs text-gray-600">
<span
v-if="link.count"
class="!ml-auto block text-xs text-gray-600"
:class="
isCollapsed && link.count > 9
? 'absolute top-[2px] right-0 bg-white'
: ''
"
>
{{ link.count }}
</span>
<div
Expand Down
Loading

0 comments on commit cb324f6

Please sign in to comment.