Added more filters to the classroom
This commit is contained in:
@@ -52,8 +52,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res, params})
|
||||
const entity = await getEntityWithRoles(assignment.entity || "")
|
||||
if (!entity) return redirect("/assignments")
|
||||
|
||||
if (!doesEntityAllow(user, entity, 'view_assignments') && !["admin", "developer"].includes(user.type))
|
||||
return redirect("/assignments")
|
||||
if (!doesEntityAllow(user, entity, 'view_assignments')) return redirect("/assignments")
|
||||
|
||||
const users = await (checkAccess(user, ["developer", "admin"]) ? getUsers() : getEntityUsers(entity.id));
|
||||
|
||||
@@ -296,6 +295,12 @@ export default function AssignmentView({user, users, entity, assignment}: Props)
|
||||
return false;
|
||||
};
|
||||
|
||||
const copyLink = async () => {
|
||||
const origin = window.location.origin
|
||||
await navigator.clipboard.writeText(`${origin}/exam?assignment=${assignment.id}`)
|
||||
toast.success("The URL to the assignment has been copied to your clipboard!")
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
@@ -388,6 +393,9 @@ export default function AssignmentView({user, users, entity, assignment}: Props)
|
||||
</div>
|
||||
|
||||
<div className="flex gap-4 w-full items-center justify-end">
|
||||
<Button variant="outline" color="purple" className="w-full max-w-[200px]" onClick={copyLink}>
|
||||
Copy Link
|
||||
</Button>
|
||||
{assignment &&
|
||||
(assignment.results.length === assignment.assignees.length || moment().isAfter(moment(assignment.endDate))) && (
|
||||
<Button variant="outline" color="red" className="w-full max-w-[200px]" onClick={deleteAssignment}>
|
||||
|
||||
@@ -49,7 +49,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res, params})
|
||||
if (!assignment) return redirect("/assignments")
|
||||
|
||||
const entities = await (checkAccess(user, ["developer", "admin"]) ? getEntitiesWithRoles() : getEntitiesWithRoles(entityIDS));
|
||||
const entity = entities.find((e) => assignment.entity === assignment.entity)
|
||||
const entity = entities.find((e) => e.id === assignment.entity)
|
||||
|
||||
if (!entity) return redirect("/assignments")
|
||||
if (!doesEntityAllow(user, entity, 'edit_assignment')) return redirect("/assignments")
|
||||
@@ -197,6 +197,12 @@ export default function AssignmentsPage({assignment, user, users, entities, grou
|
||||
}
|
||||
};
|
||||
|
||||
const copyLink = async () => {
|
||||
const origin = window.location.origin
|
||||
await navigator.clipboard.writeText(`${origin}/exam?assignment=${assignment.id}`)
|
||||
toast.success("The URL to the assignment has been copied to your clipboard!")
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
@@ -558,6 +564,9 @@ export default function AssignmentsPage({assignment, user, users, entities, grou
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div className="flex gap-4 w-full justify-end">
|
||||
<Button variant="outline" color="purple" className="w-full max-w-[200px]" onClick={copyLink}>
|
||||
Copy Link
|
||||
</Button>
|
||||
<Button
|
||||
className="w-full max-w-[200px]"
|
||||
variant="outline"
|
||||
|
||||
@@ -96,9 +96,10 @@ export default function AssignmentsPage({user, users, groups, entities}: Props)
|
||||
const router = useRouter();
|
||||
|
||||
const classrooms = useMemo(() => groups.filter((e) => e.entity === entity), [entity, groups]);
|
||||
const allowedUsers = useMemo(() => users.filter((u) => mapBy(u.entities, 'id').includes(entity || "")), [users, entity])
|
||||
|
||||
const userStudents = useMemo(() => users.filter((x) => x.type === "student"), [users]);
|
||||
const userTeachers = useMemo(() => users.filter((x) => x.type === "teacher"), [users]);
|
||||
const userStudents = useMemo(() => allowedUsers.filter((x) => x.type === "student"), [allowedUsers]);
|
||||
const userTeachers = useMemo(() => allowedUsers.filter((x) => x.type === "teacher"), [allowedUsers]);
|
||||
|
||||
const {rows: filteredStudentsRows, renderSearch: renderStudentSearch} = useListSearch([["name"], ["email"]], userStudents);
|
||||
const {rows: filteredTeachersRows, renderSearch: renderTeacherSearch} = useListSearch([["name"], ["email"]], userTeachers);
|
||||
|
||||
Reference in New Issue
Block a user