Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: learning paths #1145

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 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,6 +239,7 @@ watch(userResource, () => {
isModerator.value = userResource.data.is_moderator
isInstructor.value = userResource.data.is_instructor
addQuizzes()
addPrograms()
}
})

Expand Down
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
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
21 changes: 18 additions & 3 deletions frontend/src/pages/Courses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,45 @@

<script setup>
import {
Breadcrumbs,
Tabs,
Badge,
Breadcrumbs,
Button,
FormControl,
call,
createResource,
FormControl,
Tabs,
} from 'frappe-ui'
import CourseCard from '@/components/CourseCard.vue'
import { BookOpen, Plus, Search } from 'lucide-vue-next'
import { ref, computed, inject, onMounted, watch } from 'vue'
import { updateDocumentTitle } from '@/utils'
import { useRouter } from 'vue-router'
import { useSettings } from '@/stores/settings'

const user = inject('$user')
const searchQuery = ref('')
const currentCategory = ref(null)
const hasCourses = ref(false)
const router = useRouter()
const settings = useSettings()

onMounted(() => {
checkLearningPath()
let queries = new URLSearchParams(location.search)
if (queries.has('category')) {
currentCategory.value = queries.get('category')
}
})

const checkLearningPath = () => {
if (
settings.learningPaths.data &&
(!user.data?.is_moderator || !user.data?.is_instructor)
) {
router.push({ name: 'Programs' })
}
}

const courses = createResource({
url: 'lms.lms.utils.get_courses',
cache: ['courses', user.data?.email],
Expand Down
Loading
Loading