Prevent student from opening pending lesson

This commit is contained in:
rotimi-best
2021-09-13 14:02:18 +03:00
parent 7160fa5cf8
commit 1ab70a9698
2 changed files with 54 additions and 26 deletions
@@ -24,11 +24,11 @@
import { course, group } from '../../store';
import { updateCourse } from '../../../../utils/services/courses';
import { profile } from '../../../../utils/store/user';
import People from '../../../../routes/people.svelte';
// export let lessonId;
export let path;
let show = null;
let isStudent = null;
const { page } = stores();
@@ -99,7 +99,9 @@
(member) => member.profile_id === profileId
);
return user ? user.role_id !== 3 : false;
isStudent = user ? user.role_id === 3 : true;
return !isStudent;
},
},
{
@@ -153,9 +155,12 @@
<a
class="item flex items-center {(path || $page.path).includes(
item.id
) && 'active'} pl-7 py-2 {!item.is_complete &&
'cursor-not-allowed'}"
href={getLessonsRoute($course.id, item.id)}
) && 'active'} pl-7 py-2 {isStudent && !item.is_complete
? 'cursor-not-allowed'
: ''}"
href={isStudent && !item.is_complete
? $page.path
: getLessonsRoute($course.id, item.id)}
>
<span class="course-counter">
{getLectureNo(index + 1)}