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}>
|
||||
|
||||
Reference in New Issue
Block a user