fix: edit permission and other issues
This commit is contained in:
@@ -166,5 +166,13 @@ function enrollStudent() {
|
||||
}
|
||||
}
|
||||
|
||||
const is_instructor = () => {}
|
||||
const is_instructor = () => {
|
||||
let user_is_instructor = false
|
||||
props.course.data.instructors.forEach((instructor) => {
|
||||
if (!user_is_instructor && instructor.name == user.data?.name) {
|
||||
user_is_instructor = true
|
||||
}
|
||||
})
|
||||
return user_is_instructor
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -323,7 +323,6 @@ watch(activeQuestion, (value) => {
|
||||
watch(
|
||||
() => props.quizName,
|
||||
(newName) => {
|
||||
console.log(newName)
|
||||
if (newName) {
|
||||
quiz.reload()
|
||||
}
|
||||
@@ -392,7 +391,7 @@ const addToLocalStorage = () => {
|
||||
let quizData = JSON.parse(localStorage.getItem(quiz.data.title))
|
||||
let questionData = {
|
||||
question_index: activeQuestion.value,
|
||||
answers: getAnswers().join(),
|
||||
answer: getAnswers().join(),
|
||||
is_correct: showAnswers.filter((answer) => {
|
||||
return answer != undefined
|
||||
}),
|
||||
|
||||
@@ -26,7 +26,12 @@
|
||||
"
|
||||
>
|
||||
<div class="text-base font-medium text-gray-900 leading-none">
|
||||
<span v-if="branding.data?.brand_name">
|
||||
<span
|
||||
v-if="
|
||||
branding.data?.brand_name &&
|
||||
branding.data?.brand_name != 'Frappe'
|
||||
"
|
||||
>
|
||||
{{ branding.data?.brand_name }}
|
||||
</span>
|
||||
<span v-else> Learning </span>
|
||||
|
||||
@@ -126,7 +126,10 @@
|
||||
<div class="text-lg font-semibold mt-5 mb-4">
|
||||
{{ __('Settings') }}
|
||||
</div>
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div
|
||||
v-if="user.data?.is_moderator"
|
||||
class="flex items-center justify-between mb-4"
|
||||
>
|
||||
<FormControl
|
||||
type="checkbox"
|
||||
v-model="course.published"
|
||||
@@ -207,6 +210,7 @@ import CourseOutline from '@/components/CourseOutline.vue'
|
||||
const user = inject('$user')
|
||||
const newTag = ref('')
|
||||
const router = useRouter()
|
||||
const instructors = ref([])
|
||||
|
||||
const props = defineProps({
|
||||
courseName: {
|
||||
@@ -231,9 +235,14 @@ const course = reactive({
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (!user.data?.is_moderator && !user.data?.is_instructor) {
|
||||
if (
|
||||
props.courseName == 'new' &&
|
||||
!user.data?.is_moderator &&
|
||||
!user.data?.is_instructor
|
||||
) {
|
||||
router.push({ name: 'Courses' })
|
||||
}
|
||||
|
||||
if (props.courseName !== 'new') {
|
||||
courseResource.reload()
|
||||
}
|
||||
@@ -245,7 +254,7 @@ const courseCreationResource = createResource({
|
||||
return {
|
||||
doc: {
|
||||
doctype: 'LMS Course',
|
||||
image: course.course_image.file_url,
|
||||
image: course.course_image?.file_url || '',
|
||||
...values,
|
||||
},
|
||||
}
|
||||
@@ -260,7 +269,7 @@ const courseEditResource = createResource({
|
||||
doctype: 'LMS Course',
|
||||
name: values.course,
|
||||
fieldname: {
|
||||
image: course.course_image.file_url,
|
||||
image: course.course_image?.file_url || '',
|
||||
...course,
|
||||
},
|
||||
}
|
||||
@@ -292,6 +301,8 @@ const courseResource = createResource({
|
||||
}
|
||||
|
||||
if (data.image) imageResource.reload({ image: data.image })
|
||||
instructors.value = data.instructors
|
||||
check_permission()
|
||||
},
|
||||
})
|
||||
|
||||
@@ -397,6 +408,21 @@ const removeImage = () => {
|
||||
course.course_image = null
|
||||
}
|
||||
|
||||
const check_permission = () => {
|
||||
let user_is_instructor = false
|
||||
if (user.data?.is_moderator) return
|
||||
|
||||
instructors.value.forEach((instructor) => {
|
||||
if (!user_is_instructor && instructor.instructor == user.data?.name) {
|
||||
user_is_instructor = true
|
||||
}
|
||||
})
|
||||
|
||||
if (!user_is_instructor) {
|
||||
router.push({ name: 'Courses' })
|
||||
}
|
||||
}
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
let crumbs = [
|
||||
{
|
||||
|
||||
@@ -18,12 +18,16 @@
|
||||
}}
|
||||
</p>
|
||||
<router-link
|
||||
v-if="user.data"
|
||||
:to="{ name: 'CourseDetail', params: { courseName: courseName } }"
|
||||
>
|
||||
<Button variant="solid">
|
||||
{{ __('Start Learning') }}
|
||||
</Button>
|
||||
</router-link>
|
||||
<Button v-else @click="redirectToLogin()">
|
||||
{{ __('Login') }}
|
||||
</Button>
|
||||
</div>
|
||||
<div v-else class="border-r container pt-5 pb-10 px-5">
|
||||
<div class="flex flex-col md:flex-row md:items-center justify-between">
|
||||
@@ -332,6 +336,10 @@ const allowInstructorContent = () => {
|
||||
if (lesson.data?.instructors.includes(user.data?.name)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
const redirectToLogin = () => {
|
||||
window.location.href = `/login?redirect-to=/lms/courses/${props.courseName}`
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.avatar-group {
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="grid grid-cols-3 md:grod-cols-4 gap-4 mb-4"
|
||||
class="grid grid-cols-3 md:grid-cols-4 gap-4 mb-4"
|
||||
v-show="showSlotsTemplate"
|
||||
>
|
||||
<FormControl
|
||||
|
||||
Reference in New Issue
Block a user