People: filter, add student id, submit homework
This commit is contained in:
@@ -1,11 +1,17 @@
|
|||||||
<script>
|
<script>
|
||||||
import Modal from '../../../../Modal/index.svelte';
|
import Modal from '../../../../Modal/index.svelte';
|
||||||
|
import Select from '../../../../Form/Select.svelte';
|
||||||
import Preview from './Preview.svelte';
|
import Preview from './Preview.svelte';
|
||||||
|
import { SELECTABLE_STATUS } from './constants';
|
||||||
|
import { snackbarStore } from '../../../../Snackbar/store';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
export let open;
|
export let open;
|
||||||
export let onClose;
|
export let onClose;
|
||||||
|
|
||||||
export let submissionId;
|
// export let submissionId;
|
||||||
export let data = {};
|
export let data = {};
|
||||||
|
export let status = SELECTABLE_STATUS[0];
|
||||||
|
|
||||||
let grades = {};
|
let grades = {};
|
||||||
let total = 0;
|
let total = 0;
|
||||||
@@ -27,6 +33,16 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleStatusChange() {
|
||||||
|
console.log(`status`, status);
|
||||||
|
$snackbarStore.open = true;
|
||||||
|
$snackbarStore.message = `Submission updated to '${status.label}'`;
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
console.log('mounting');
|
||||||
|
});
|
||||||
|
|
||||||
$: setGrades(data);
|
$: setGrades(data);
|
||||||
$: total = calculateTotal(grades);
|
$: total = calculateTotal(grades);
|
||||||
</script>
|
</script>
|
||||||
@@ -49,7 +65,13 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-10 w-1/3">
|
<div class="ml-10 w-1/3">
|
||||||
<div class="border border-gray-300 rounded-md">
|
<Select
|
||||||
|
bind:value={status}
|
||||||
|
options={SELECTABLE_STATUS}
|
||||||
|
color="primary"
|
||||||
|
onChange={handleStatusChange}
|
||||||
|
/>
|
||||||
|
<div class="border border-gray-300 rounded-md mt-2">
|
||||||
<div
|
<div
|
||||||
class="hover:bg-gray-100 border-b border-t-0 border-l-0 border-r-0 border-gray-300 p-3"
|
class="hover:bg-gray-100 border-b border-t-0 border-l-0 border-r-0 border-gray-300 p-3"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { fade, fly, slide } from 'svelte/transition';
|
import { fly } from 'svelte/transition';
|
||||||
import { group, course } from '../../../store';
|
import { group, course } from '../../../store';
|
||||||
import { questionnaire } from '../store/exercise';
|
import { questionnaire } from '../store/exercise';
|
||||||
import { questionnaireMetaData } from '../store/answers';
|
import { questionnaireMetaData } from '../store/answers';
|
||||||
@@ -150,19 +150,19 @@
|
|||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex flex-col justify-between">
|
<div class="flex flex-col justify-between">
|
||||||
<h2 class="text-xl mb-2 mt-0">{$questionnaire.title}</h2>
|
<h2 class="text-xl mb-2 mt-0">{$questionnaire.title}</h2>
|
||||||
{#if STATUS.IN_PROGRESS === $questionnaireMetaData.status}
|
{#if STATUS.PENDING === $questionnaireMetaData.status}
|
||||||
<span
|
<span
|
||||||
class="bg-yellow-600 text-white rounded-full py-2 px-6 text-center"
|
class="bg-yellow-600 text-white rounded-full py-2 px-6 text-center"
|
||||||
title="Status: Pending Review"
|
title="Status: Pending Review"
|
||||||
>
|
>
|
||||||
Pending
|
Pending
|
||||||
</span>
|
</span>
|
||||||
{:else if STATUS.REVIEWED === $questionnaireMetaData.status && getTotalScores() > 0}
|
{:else if STATUS.GRADED === $questionnaireMetaData.status && getTotalScores() > 0}
|
||||||
<span
|
<span
|
||||||
class="bg-green-700 text-white rounded-full py-2 px-6 text-center"
|
class="bg-green-700 text-white rounded-full py-2 px-6 text-center"
|
||||||
title="Status: Pending Review"
|
title="Status: Pending Review"
|
||||||
>
|
>
|
||||||
Reviewed
|
Graded
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
export const STATUS = {
|
export const STATUS = {
|
||||||
IN_PROGRESS: 0,
|
PENDING: 0,
|
||||||
REVIEWED: 1,
|
IN_PROGRESS: 1,
|
||||||
|
GRADED: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const SELECTABLE_STATUS = [
|
||||||
|
{
|
||||||
|
label: 'Submitted',
|
||||||
|
value: STATUS.PENDING,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'In progress',
|
||||||
|
value: STATUS.IN_PROGRESS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Graded',
|
||||||
|
value: STATUS.GRADED,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { STATUS } from '../Exercise/constants';
|
|||||||
// currentQuestionIndex: 5,
|
// currentQuestionIndex: 5,
|
||||||
// isFinished: true,
|
// isFinished: true,
|
||||||
// progressValue: 100,
|
// progressValue: 100,
|
||||||
// status: STATUS.REVIEWED,
|
// status: STATUS.GRADED,
|
||||||
// });
|
// });
|
||||||
const initAnswerState = {
|
const initAnswerState = {
|
||||||
answers: {},
|
answers: {},
|
||||||
@@ -16,7 +16,7 @@ const initAnswerState = {
|
|||||||
currentQuestionIndex: 0,
|
currentQuestionIndex: 0,
|
||||||
isFinished: false,
|
isFinished: false,
|
||||||
progressValue: 100,
|
progressValue: 100,
|
||||||
status: STATUS.IN_PROGRESS,
|
status: STATUS.PENDING,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const questionnaireMetaData = writable(initAnswerState);
|
export const questionnaireMetaData = writable(initAnswerState);
|
||||||
|
|||||||
@@ -10,4 +10,11 @@ export interface Person {
|
|||||||
email?: string;
|
email?: string;
|
||||||
role_id: number;
|
role_id: number;
|
||||||
profile?: Profile;
|
profile?: Profile;
|
||||||
|
profile_id?: string;
|
||||||
|
assigned_student_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProfileRole {
|
||||||
|
label: string;
|
||||||
|
value: string | number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { writable } from 'svelte/store';
|
|||||||
import { lessons } from './components/Lesson/store/lessons';
|
import { lessons } from './components/Lesson/store/lessons';
|
||||||
import { ROLE } from '../../utils/constants/roles';
|
import { ROLE } from '../../utils/constants/roles';
|
||||||
|
|
||||||
export const course = writable({});
|
export const course = writable({ id: '' });
|
||||||
|
|
||||||
export const mockGroupMember = {
|
export const mockGroupMember = {
|
||||||
id: '434534534535',
|
id: '434534534535',
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
export let options = [];
|
export let options = [];
|
||||||
export let labelKey = 'label';
|
export let labelKey = 'label';
|
||||||
export let isRequired = false;
|
export let isRequired = false;
|
||||||
|
export let className = '';
|
||||||
|
export let color = 'default'; // primary
|
||||||
export let onChange = () => {}; // This is to know if element is 'dirty'
|
export let onChange = () => {}; // This is to know if element is 'dirty'
|
||||||
|
|
||||||
// onMount(() => {
|
// onMount(() => {
|
||||||
@@ -13,18 +15,37 @@
|
|||||||
// });
|
// });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="block">
|
<label class="block {className}">
|
||||||
{#if label} <span class="text-gray-700">{label}</span> {/if}
|
{#if label} <span class="text-gray-700 mr-2">{label}</span> {/if}
|
||||||
<select
|
<select
|
||||||
bind:value
|
bind:value
|
||||||
class="form-select block w-full mt-1"
|
class="form-select block w-auto mt-1"
|
||||||
required={isRequired}
|
required={isRequired}
|
||||||
on:blur={onChange}
|
on:change={onChange}
|
||||||
|
class:primary={color === 'primary'}
|
||||||
>
|
>
|
||||||
{#each options as option}
|
{#each options as option}
|
||||||
<option value={option}>
|
<option class="bg-white text-black" value={option}>
|
||||||
{option[labelKey]}
|
{option[labelKey]}
|
||||||
</option>
|
</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
select.primary {
|
||||||
|
font-weight: 700;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgba(255, 255, 255, var(--tw-text-opacity));
|
||||||
|
--tw-bg-opacity: 1;
|
||||||
|
background-color: rgba(29, 78, 216, var(--tw-bg-opacity));
|
||||||
|
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' class='text-white' viewBox='0 0 20 20'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
|
||||||
|
}
|
||||||
|
|
||||||
|
select.primary option {
|
||||||
|
background-color: #fff;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="root mt-4 mx-auto {width} {className} relative pb-5">
|
<div class="root mt-4 mx-auto {width} {className} relative pb-5">
|
||||||
{#if $$slots.header}
|
{#if $$slots.header}
|
||||||
<div
|
<div
|
||||||
class="head flex bg-white items-center justify-between sticky right-0 w-full py-3"
|
class="head flex items-center justify-between sticky right-0 w-full py-3"
|
||||||
>
|
>
|
||||||
<slot name="header" />
|
<slot name="header" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
|
|
||||||
{#if $snackbarStore.open}
|
{#if $snackbarStore.open}
|
||||||
<div
|
<div
|
||||||
transition:fly={{ y: 200, duration: 1000 }}
|
transition:fly={{ y: 200, duration: 500 }}
|
||||||
class="root text-white rounded-md flex justify-between items-center z-50 absolute {severityColor}"
|
class="root text-white rounded-md flex justify-between items-center absolute {severityColor}"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
{#if $snackbarStore.severity === SNACKBAR_SEVERITY.SUCCESS}
|
{#if $snackbarStore.severity === SNACKBAR_SEVERITY.SUCCESS}
|
||||||
@@ -64,5 +64,6 @@
|
|||||||
min-width: 288px;
|
min-width: 288px;
|
||||||
padding: 6px 16px;
|
padding: 6px 16px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
z-index: 51;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
allowUser = true;
|
allowUser = true;
|
||||||
} else if (!_isMvpUser) {
|
} else if (!_isMvpUser) {
|
||||||
if (!!path) {
|
if (!!path) {
|
||||||
goto('/');
|
goto('/courses');
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
getProfile();
|
getProfile();
|
||||||
} else {
|
} else {
|
||||||
console.log('not logged in, go to login');
|
console.log('not logged in, go to login');
|
||||||
return goto('/');
|
return goto('/courses');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { STATUS } from '../../utils/constants/answers';
|
|
||||||
import { QUESTION_TYPE } from '../../components/Question/constants';
|
import { QUESTION_TYPE } from '../../components/Question/constants';
|
||||||
|
|
||||||
const ROLE = {
|
const ROLE = {
|
||||||
@@ -349,7 +348,7 @@ const exercise_answers = [
|
|||||||
currentQuestionIndex: 0,
|
currentQuestionIndex: 0,
|
||||||
isFinished: false,
|
isFinished: false,
|
||||||
progressValue: 100,
|
progressValue: 100,
|
||||||
status: STATUS.PENDING,
|
status: 'STATUS.PENDING',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import {
|
import {
|
||||||
fetchCourse,
|
fetchCourse,
|
||||||
deleteGroupMember,
|
deleteGroupMember,
|
||||||
|
updatedGroupMember,
|
||||||
} from '../../../utils/services/courses';
|
} from '../../../utils/services/courses';
|
||||||
|
|
||||||
export async function preload({ params }) {
|
export async function preload({ params }) {
|
||||||
@@ -15,6 +16,8 @@
|
|||||||
import Delete24 from 'carbon-icons-svelte/lib/Delete24';
|
import Delete24 from 'carbon-icons-svelte/lib/Delete24';
|
||||||
import PageNav from '../../../components/PageNav/index.svelte';
|
import PageNav from '../../../components/PageNav/index.svelte';
|
||||||
import PrimaryButton from '../../../components/PrimaryButton/index.svelte';
|
import PrimaryButton from '../../../components/PrimaryButton/index.svelte';
|
||||||
|
import TextField from '../../../components/Form/TextField.svelte';
|
||||||
|
import Select from '../../../components/Form/Select.svelte';
|
||||||
import IconButton from '../../../components/IconButton/index.svelte';
|
import IconButton from '../../../components/IconButton/index.svelte';
|
||||||
import PageBody from '../../../components/PageBody/index.svelte';
|
import PageBody from '../../../components/PageBody/index.svelte';
|
||||||
import {
|
import {
|
||||||
@@ -28,8 +31,11 @@
|
|||||||
invitationModal,
|
invitationModal,
|
||||||
deleteMemberModal,
|
deleteMemberModal,
|
||||||
} from '../../../components/Course/components/People/store';
|
} from '../../../components/Course/components/People/store';
|
||||||
import type { Person } from '../../../components/Course/components/People/types';
|
import type {
|
||||||
import { ROLE, ROLE_LABEL } from '../../../utils/constants/roles';
|
Person,
|
||||||
|
ProfileRole,
|
||||||
|
} from '../../../components/Course/components/People/types';
|
||||||
|
import { ROLE_LABEL, ROLES } from '../../../utils/constants/roles';
|
||||||
import { profile } from '../../../utils/store/user';
|
import { profile } from '../../../utils/store/user';
|
||||||
|
|
||||||
export let courseId: string = '';
|
export let courseId: string = '';
|
||||||
@@ -37,6 +43,8 @@
|
|||||||
let people: Array<Person> = [];
|
let people: Array<Person> = [];
|
||||||
let borderBottomGrey = 'border-r-0 border-b border-l-0 border-gray-300';
|
let borderBottomGrey = 'border-r-0 border-b border-l-0 border-gray-300';
|
||||||
let member: { id?: string; email?: string; profile?: { email: string } } = {};
|
let member: { id?: string; email?: string; profile?: { email: string } } = {};
|
||||||
|
let shouldEditMemberId = false;
|
||||||
|
let filterBy: ProfileRole = ROLES[0];
|
||||||
|
|
||||||
// function setPeople(people: Array<Person>) {
|
// function setPeople(people: Array<Person>) {
|
||||||
// if (!Array.isArray(people)) return;
|
// if (!Array.isArray(people)) return;
|
||||||
@@ -55,13 +63,32 @@
|
|||||||
await deleteGroupMember(member.id);
|
await deleteGroupMember(member.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function editMemberId(person: Person) {
|
||||||
|
console.log(`person`, person);
|
||||||
|
await updatedGroupMember(
|
||||||
|
{ assigned_student_id: person.assigned_student_id },
|
||||||
|
{ id: person.id }
|
||||||
|
);
|
||||||
|
shouldEditMemberId = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortAndFilterPeople(_people: Array<Person>, filterBy: ProfileRole) {
|
||||||
|
people = (_people || [])
|
||||||
|
.filter((person) => {
|
||||||
|
if (filterBy.value === 'all') return true;
|
||||||
|
|
||||||
|
return person.role_id === filterBy.value;
|
||||||
|
})
|
||||||
|
.sort((a: Person, b: Person) => a.role_id - b.role_id);
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($course.id) return;
|
if ($course.id) return;
|
||||||
const { data } = await fetchCourse(courseId);
|
const { data } = await fetchCourse(courseId);
|
||||||
setCourseData(data);
|
setCourseData(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
$: people = ($group.people || []).sort((a, b) => a.role_id - b.role_id);
|
$: sortAndFilterPeople($group.people, filterBy);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<InviationModal />
|
<InviationModal />
|
||||||
@@ -81,49 +108,74 @@
|
|||||||
</slot:fragment>
|
</slot:fragment>
|
||||||
</PageNav>
|
</PageNav>
|
||||||
<PageBody className="">
|
<PageBody className="">
|
||||||
<div class="table rounded-md border border-gray-300 w-11/12 m-auto">
|
<div class="mb-3">
|
||||||
|
<Select
|
||||||
|
label="Filter by"
|
||||||
|
bind:value={filterBy}
|
||||||
|
options={ROLES}
|
||||||
|
className="flex items-center"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table rounded-md border border-gray-300 w-full">
|
||||||
<div
|
<div
|
||||||
class="flex items-center justify-evenly font-bold border-t-0 {borderBottomGrey} p-3"
|
class="flex items-center font-bold border-t-0 {borderBottomGrey} p-3"
|
||||||
>
|
>
|
||||||
<span class="mr-2">No</span>
|
<span class="mr-2 w-20 text-center">ID</span>
|
||||||
<!-- <span class="flex-grow" /> -->
|
<!-- <span class="flex-grow" /> -->
|
||||||
<p class="text-lg text-center w-1/4">Name</p>
|
<p class="text-lg w-2/4">Name</p>
|
||||||
<p class="text-lg text-center w-1/4">Email</p>
|
<p class="text-lg w-1/4 ">Role</p>
|
||||||
<p class="text-lg text-center w-1/4 ">Role</p>
|
<p class="text-lg w-20" />
|
||||||
<p class="text-lg w-20 text-center" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each people as person, index}
|
{#each people as person, index}
|
||||||
<div
|
<div
|
||||||
class="flex text-center relative items-center justify-evenly p-3 cursor-pointer {borderBottomGrey} hover:bg-gray-100"
|
class="flex relative items-center p-3 cursor-pointer {borderBottomGrey}"
|
||||||
>
|
>
|
||||||
<span class="mr-2">{index + 1}</span>
|
{#if !shouldEditMemberId}
|
||||||
|
<p
|
||||||
|
class="mr-2 w-20 text-center hover:bg-gray-100 p-3"
|
||||||
|
on:click={() => (shouldEditMemberId = true)}
|
||||||
|
>
|
||||||
|
{person.assigned_student_id || index + 1}
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
<TextField
|
||||||
|
bind:value={person.assigned_student_id}
|
||||||
|
type="string"
|
||||||
|
placeholder="Unique ID"
|
||||||
|
className="w-24"
|
||||||
|
onChange={() => editMemberId(person)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
<!-- <span class="flex-grow" /> -->
|
<!-- <span class="flex-grow" /> -->
|
||||||
{#if person.profile}
|
{#if person.profile}
|
||||||
<p class="text-lg w-1/4 break-all">{person.profile.fullname}</p>
|
<div class="break-all w-2/4 mx-2">
|
||||||
<a
|
<p class="text-lg">{person.profile.fullname}</p>
|
||||||
href="mailto:{person.profile.email}"
|
<a
|
||||||
class="text-md w-1/4 mx-2 text-blue-600"
|
href="mailto:{person.profile.email}"
|
||||||
>
|
class="text-md text-blue-600"
|
||||||
{person.profile.email}
|
>
|
||||||
</a>
|
{person.profile.email}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<p
|
<div class="break-all w-2/4 mx-2">
|
||||||
class="bg-yellow-500 w-1/4 text-sm text-center rounded-xl text-white"
|
<p
|
||||||
>
|
class="bg-yellow-500 pending text-sm text-center rounded-xl text-white"
|
||||||
Pending Invite
|
>
|
||||||
</p>
|
Pending Invite
|
||||||
<a
|
</p>
|
||||||
href="mailto:{person.email}"
|
<a href="mailto:{person.email}" class="text-md text-blue-600">
|
||||||
class="text-md w-1/4 mx-2 text-blue-600"
|
{person.email}
|
||||||
>
|
</a>
|
||||||
{person.email}
|
</div>
|
||||||
</a>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<p class="text-lg w-1/4 ">{ROLE_LABEL[person.role_id]}</p>
|
<p class="text-lg w-1/4 ">{ROLE_LABEL[person.role_id]}</p>
|
||||||
|
|
||||||
<div class="w-20">
|
<div class="w-20">
|
||||||
{#if person.profile && person.profile.id !== $profile.id}
|
{#if person.profile_id !== $profile.id}
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
member = person;
|
member = person;
|
||||||
@@ -139,3 +191,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</PageBody>
|
</PageBody>
|
||||||
</CourseContainer>
|
</CourseContainer>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.pending {
|
||||||
|
width: fit-content;
|
||||||
|
padding: 1px 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export const STATUS = {
|
|
||||||
PENDING: 0,
|
|
||||||
IN_PROGRESS: 1,
|
|
||||||
REVIEWED: 2,
|
|
||||||
};
|
|
||||||
@@ -9,3 +9,22 @@ export const ROLE_LABEL = {
|
|||||||
[ROLE.TUTOR]: 'Tutor',
|
[ROLE.TUTOR]: 'Tutor',
|
||||||
[ROLE.STUDENT]: 'Student',
|
[ROLE.STUDENT]: 'Student',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ROLES = [
|
||||||
|
{
|
||||||
|
label: 'All',
|
||||||
|
value: 'all',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: ROLE_LABEL[ROLE.ADMIN],
|
||||||
|
value: ROLE.ADMIN,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: ROLE_LABEL[ROLE.TUTOR],
|
||||||
|
value: ROLE.TUTOR,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: ROLE_LABEL[ROLE.STUDENT],
|
||||||
|
value: ROLE.STUDENT,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -122,6 +122,13 @@ export function addGroupMember(member) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updatedGroupMember(update, match) {
|
||||||
|
return supabase
|
||||||
|
.from('groupmember')
|
||||||
|
.update(update, { returning: 'minimal' })
|
||||||
|
.match(match);
|
||||||
|
}
|
||||||
|
|
||||||
export function deleteGroupMember(groupMemberId) {
|
export function deleteGroupMember(groupMemberId) {
|
||||||
return supabase.from('groupmember').delete().match({ id: groupMemberId });
|
return supabase.from('groupmember').delete().match({ id: groupMemberId });
|
||||||
}
|
}
|
||||||
@@ -296,13 +303,9 @@ export async function submitExercise(
|
|||||||
group,
|
group,
|
||||||
profile
|
profile
|
||||||
) {
|
) {
|
||||||
let groupMember;
|
const groupMember = group.people.find(
|
||||||
|
(person) => person.profile_id === profile.id
|
||||||
if (Array.isArray(group.tutors)) {
|
);
|
||||||
groupMember = group.tutors.find(
|
|
||||||
(student) => student.profile_id === profile.id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
console.log(`groupMember`, groupMember);
|
console.log(`groupMember`, groupMember);
|
||||||
if (!groupMember) {
|
if (!groupMember) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user