Grant Tutor Rights
grantTutorRights(ident uid, ident username, ident exerciseId, ident groupId) {
assume exists /account[uid]/assistant[exerciseId];
assume exists /account[username]; # implicitly true in OO implementations
assume exists /exercise[exerciseId]/group[groupId];
assume not exists /account[username]/tutor[exerciseId]/group[groupId]);
assume not exists /exercise[exerciseId]/group[groupId]/tutor[username];
# implied by integrity and the assumption before
if not exists /account[username]/tutor[exerciseId] then # we could split the tutor rights here
insert /account[username] <tutor exercise=[exerciseId] />;
fi
insert /account[username]/tutor[exerciseId] <group id=[groupId] />;
insert /exercise[exerciseId]/group[groupId] <tutor account=[account] />;
}