summaryrefslogtreecommitdiff
path: root/assignment-6
diff options
context:
space:
mode:
authorCamil Staps2017-10-23 08:48:59 +0200
committerCamil Staps2017-10-23 08:48:59 +0200
commit5013deccab55d3f6782a8a803214206928e1eff7 (patch)
tree16ece7ab86a65c7bfb13215d06ce84b734493092 /assignment-6
parentDon't accept incorrect correct answer indices (diff)
Use roles
Diffstat (limited to 'assignment-6')
-rw-r--r--assignment-6/multiplechoice.icl10
1 files changed, 6 insertions, 4 deletions
diff --git a/assignment-6/multiplechoice.icl b/assignment-6/multiplechoice.icl
index b26d11c..e76ef9d 100644
--- a/assignment-6/multiplechoice.icl
+++ b/assignment-6/multiplechoice.icl
@@ -11,7 +11,7 @@ import iTasks
Start w = startEngine (allTasks createUsers >>| authedMain) w
where
createUsers :: [Task UserAccount]
- createUsers = [catchAll (createUser u) (\_ -> return u) \\ u <- myUsers]
+ createUsers = [catchAll (createUser u) (const $ return u) \\ u <- myUsers]
authedMain :: Task ()
authedMain = doAuthenticated (get currentUser >>- main) >>*
@@ -50,9 +50,11 @@ main u
| isAdmin u = adminTask
| otherwise = studentTask
where
- isTeacher (AuthenticatedUser s _ _) = isMember s ["Rinus", "Pieter"]
- isTeacher _ = False
- isAdmin u = u =: (AuthenticatedUser "admin" _ _)
+ isTeacher = hasRole TEACHER
+ isAdmin = hasRole ADMIN
+
+ hasRole r (AuthenticatedUser _ rs _) = isMember r rs
+ hasRole _ _ = False
teacherTask :: Task ()
teacherTask = enterChoiceWithShared