Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/assets/vue/components/session/SessionCardSimple.vue

59 lines
1.2 KiB

<template>
<div
v-for="course in courses"
no-body
style="max-width: 540px;"
>
<CourseCard
:session="session"
:course="course"
:session-id="session._id"
/>
</div>
</template>
<script setup>
import CourseCard from '../course/CourseCard.vue'
import {ref} from "vue"
import isEmpty from 'lodash/isEmpty'
const props = defineProps({
session: {
type: Object,
required: true,
},
})
const courses = ref([])
let showAllCourses = false
if (!isEmpty(props.session.users) && !isEmpty(props.session.users.edges)) {
props.session.users.edges.forEach(({node}) => {
// User is Session::SESSION_ADMIN
if (4 === node.relationType) {
showAllCourses = true
}
})
}
if (showAllCourses) {
courses.value = props.session.courses.edges.map(({node}) => {
return node.course
})
} else {
if (
!isEmpty(props.session.courses)
&& !isEmpty(props.session.courses.edges)
) {
props.session.courses.edges.map(({node}) => {
const courseExists = props.session.courses.edges.findIndex(courseItem => courseItem.node.course._id === node.course._id) >= 0
if (courseExists) {
courses.value.push(node.course);
}
})
}
}
</script>