This shows you the differences between two versions of the page.
stats:schema:account [2011/09/27 20:47] Patrick Michel [Assistant Role] |
stats:schema:account [2013/07/10 12:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== User Accounts and Roles ====== | ||
- | This page describes a major part of the [[:stats:start]] [[:stats:schema]], namely the user accounts and the role handling. | ||
- | |||
- | ===== Schema ===== | ||
- | |||
- | <code xcend> | ||
- | element accounts { | ||
- | element account * username { | ||
- | attribute lastName { string } | ||
- | attribute firstName { string } | ||
- | attribute email { string } | ||
- | attribute password { string } | ||
- | |||
- | element admin ? { } | ||
- | element examiner * exam {[ exists //exams/exam[./exam] ]} | ||
- | element assistant * exercise {[ exists //exercises/exercise[./exercise] ]} | ||
- | element tutor * exercise { | ||
- | element group * id {[ exists //exercises/exercise[../exercise]/groups/group[./id] ]} | ||
- | } | ||
- | element student ? { | ||
- | attribute id { ident [ unique //acounts/account/student[.] ]} | ||
- | } | ||
- | } | ||
- | } | ||
- | </code> | ||
- | |||
- | ===== Procedures ===== | ||
- | |||
- | ==== Change Attributes ==== | ||
- | |||
- | {{page>stats:proc:changeAttributes (Account)&noheader&nofooter}} | ||
- | ==== Student Role ==== | ||
- | |||
- | The students in the [[exercise]] section, as well as the participants in the [[exam]] section, depend on the student role. This restricts the deletion of the role, i.e. the host language first has to delete these dependencies with corresponding procedures. | ||
- | |||
- | {{page>stats:proc:setStudentId&noheader&nofooter}} | ||
- | |||
- | {{page>stats:proc:removeStudentId&noheader&nofooter}} | ||
- | |||
- | |||
- | ==== Admin Role ==== | ||
- | |||
- | The admin role is pretty much just a flag, without any constraints at all. The precondition is therefore only concerned with uniqueness and trivial stuff. | ||
- | |||
- | {{page>stats:proc:grantAdminRights&noheader&nofooter}} | ||
- | |||
- | {{page>stats:proc:revokeAdminRights&noheader&nofooter}} | ||
- | |||
- | |||
- | ==== Examiner Role ==== | ||
- | |||
- | The examiner role has to fulfill integrity constraints and has a counterpart in the [[exam]] section of the document. | ||
- | |||
- | {{page>stats:proc:grantExaminerRights&noheader&nofooter}} | ||
- | |||
- | {{page>stats:proc:revokeExaminerRights&noheader&nofooter}} | ||
- | |||
- | ==== Assistant Role ==== | ||
- | |||
- | The assistant role relates to exercises like the examiner role relates to exams, so it also has to fulfill integrity constraints and has a counterpart in [[exercise]]. | ||
- | |||
- | {{page>stats:proc:grantAssistantRights&noheader&nofooter}} | ||
- | |||
- | {{page>stats:proc:revokeAssistantRights&noheader&nofooter}} | ||
- | |||
- | ==== Tutor Role ==== | ||
- | |||
- | The tutor role also behaves similarly, but this time it references two identifiers in the [[exercise]] section, where it also has a counterpart. | ||
- | |||
- | This modeling of tutor rights is different from the current implementation. It might also be a nice design, if you can be tutor for an exercise, without (yet) having a group. This would grant some access rights already, I think. | ||
- | |||
- | <code xcend> | ||
- | grantTutorRights(ident username, ident exerciseId, ident groupId) { | ||
- | assume exists //accounts/account[username]; # implicitly true in OO implementations | ||
- | assume exists //exercises/exercise[exerciseId]/groups/group[groupId]; | ||
- | | ||
- | assume not exists //accounts/account[username]/tutor[exerciseId]/group[groupId]); | ||
- | assume not exists //exercises/exercise[exerciseId]/groups/group[groupId]/tutor[account]; # implied by integrity and the assumption before | ||
- | |||
- | if not exists //accounts/account[username]/tutor[exerciseId] then # we could split the tutor rights here | ||
- | insert //accounts/account[username] <tutor exercise=[exerciseId] />; | ||
- | fi | ||
- | insert //accounts/account[username]/tutor[exerciseId] <group id=[groupId] />; | ||
- | insert //exercises/exercise[exerciseId]/groups/group[groupId] <tutor account=[account] />; | ||
- | } | ||
- | </code> | ||
- | |||
- | <code xcend> | ||
- | revokeTutorRights(ident username, ident exerciseId, ident groupId) { | ||
- | assume exists //accounts/account[username]/tutor[exerciseId]/group[groupId]; # implies the account exists, which is implicitly true anyway | ||
- | assume exists //exercises/exercise[exerciseId]/groups/group[groupId]/tutor[account]; # implied by integrity and the assumption before | ||
- | |||
- | remove //accounts/account[username]/tutor[exerciseId]/group[groupId]; | ||
- | if size(//accounts/account[username]/tutor[exerciseId]/group) = 0 then # should this be an additional procedure? | ||
- | remove //accounts/account[username]/tutor[exerciseId]; | ||
- | fi | ||
- | remove //exercises/exercise[exerciseId]/groups/group[groupId]/tutor[account]; | ||
- | } | ||
- | </code> |