Yusuf Sultan
05/12/2025, 11:07 AMYusuf Sultan
05/12/2025, 11:07 AMYusuf Sultan
05/12/2025, 11:08 AMYusuf Sultan
05/12/2025, 11:11 AMSam Lock (Cerbos)
05/12/2025, 2:03 PMTEACHER
. If your roles aren't quite so granular (e.g. STAFF
), you can provide this context as a principal attribute "teacher" in P.attr.teams
.
> The teacher is grading within office hours (they cannot grade outside of that)
Something like the following would work (I've arbitrarily passed "GB" as a timezone here, it would be up to you to handle this accordingly). If requests aren't real-time or if you want absolute guarantees over time comparisons, you'd probably pass the client's version of now()
rather than relying on the PDPs understanding of it:
timestamp(now()).getHours("GB") >= 9 && timestamp(now()).getHours("GB") <= 17
> The teacher is part of staff of the course under which the homework is
Something like: R.attr.course in P.attr.courses
> The teacher must have downloaded all of homework's files before they're allowed to grade it
The PDP is stateless, so you'd need to assert this in your application code or provide all of the necessary context in the request for the PDP to make the decision, e.g.
P.attr.assignments_downloaded[R.id] == R.attr.n_candidates
Where assignments_downloaded
is a map of resource IDs to the number of unique downloads (maybe not the most elegant approach, but indicative 🙂)
> The homework was not already graded by another teach BUT if it's the same teacher updating the grade WITHIN 30 minutes of prior grading it's fine that can go through
Similarly, the statelessness of the PDP require some level of inference here from your application, specifically with regards to determining previous access. So if done in the PDP, you'd need to pass required context in the request. This particular case might be better off at the app level, but again, it depends!Yusuf Sultan
05/12/2025, 5:28 PMP
and R
have enough relationships preloaded in them for Cerbos to make a decisionYusuf Sultan
05/12/2025, 5:29 PM