Added more filters to the classroom

This commit is contained in:
Tiago Ribeiro
2024-10-17 22:41:20 +01:00
parent 4917583c67
commit 87d7d6f12b
7 changed files with 90 additions and 15 deletions

View File

@@ -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}>