Table of Contents

Exercise Groups

This page describes a minor part of the STAT System XCend Schema, namely the exercise groups. It is a part of Exercise Management and Sheets.

Schema

    element group * id {        [ count(./id, ..exercise/student/group) <= ./maxSize ]
      attribute day             { "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday" }
      attribute time            { string }
      attribute location        { string }
      attribute curSize         { integer [ . = count(../id, ..exercise/student/group) ]}
      attribute maxSize         { integer [ . >= 0 ]}
 
      element tutor * account   {[ exists /account[./account]/tutor[..exercise/id]/group[..group/id] ]}
    }                           

Procedures

Change Attributes

changeAttributes(ident uid, ident id, ident groupId, string day, string time, string location, integer maxSize) {
  assume exists /account[uid]/assistant[id];
 
  assume exists /exercise[id]/group[groupId]; # implicitly true in OO implementations
 
  assume maxSize >= 0;
  assume /exercise[id]/group[groupId]/curSize <= maxSize;
 
  update /exercise[id]/group[groupId]/day day;
  update /exercise[id]/group[groupId]/time time;
  update /exercise[id]/group[groupId]/location location;
  update /exercise[id]/group[groupId]/maxSize maxSize;
}

Tutor Management

The procedures for tutor management can be directly taken from the User Accounts and Roles section. In an OO setting this placement of the method in the Group class takes the least number of explicit parameters, as the exercise and group ids are implicit.

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] />;
}
revokeTutorRights(ident uid, ident username, ident exerciseId, ident groupId) {
  assume exists /account[uid]/assistant[exerciseId];
 
  assume exists /account[username]/tutor[exerciseId]/group[groupId];
  assume exists /exercise[exerciseId]/group[groupId]/tutor[username];
    # implied by integrity and the assumption before
 
  remove /account[username]/tutor[exerciseId]/group[groupId];
  if size(/account[username]/tutor[exerciseId]/group) = 0 then # should this be an additional procedure?
    remove /account[username]/tutor[exerciseId];
  fi
  remove /exercise[exerciseId]/group[groupId]/tutor[username];
}

Member Management

Another example of another association of procedures; The sign up and out procedures for students from the Exercise Management and Sheets section could also be offered on groups, as they have the necessary parameters (It is not currently realized like this in the implementation).

signUpGroup(ident uid, ident id, ident studentId, ident groupId) {
  assume exists /exercise[id] && /exercise[id]/open && 
         exists /account[uid]/student && /account[uid]/student/id = studentId
      || exists /account[uid]/assistant[id];
 
  assume exists /exercise[id]/student[studentId]; # implies the existence of the exercise
  assume exists /exercise[id]/group[groupId]; # also implies it, but once is really enough
 
  assume not exists /exercise[id]/student[studentId]/group;
  assume /exercise[id]/group[groupId]/curSize < /exercise[id]/group[groupId]/maxSize;
 
  insert /exercise[id]/student[studentId]/group groupId;
  update /exercise[id]/group[groupId]/curSize (/exercise[id]/group[groupId]/curSize + 1);
}
signOutGroup(ident uid, ident id, ident studentId) {
  assume exists /exercise[id] && /exercise[id]/open && 
         exists /account[uid]/student && /account[uid]/student/id = studentId
      || exists /account[uid]/assistant[id];
 
  assume exists /exercise[id]/student[studentId]/group;
    # implies existence of the exercise and student, even the group
 
 
  update /exercise[id]/group[/exercise[id]/student[studentId]/group]/curSize
    (/exercise[id]/group[/exercise[id]/student[studentId]/group]/curSize - 1)
  remove /exercise[id]/student[studentId]/group;
}