module Roster; from View import all; from Lecture import all; from Layers import all; export all; object StudentRoster is components: stu:Student*, num:NumStudents; operations: BanStudent, SetStudentMode, AnswerStudentQuestion, AnswerStudentComment, LoadStudentRoster; description: (* A StudentRoster is a list of students in to manage the modes and communication between each of them. *); end StudentRoster; object OnlineOfflineStudentRoster is components: onmem:OnlineMembers, offmem:OfflineMembers, notonlist:NotOnClassListMembers, num:NumStudents, vm:ViewMode; description: (* When a class list is loaded, is is sorted into 3 groups. This is the new roster which contains the 3 seperated groups for proper displaying. *); end OnlineOfflineStudentRoster; object OnlineMembers is components: num:NumStudents, sl:Student*; description: (* The section of the OnlineOfflineStudentRoster which contains online members. *); end OnlineMembers; object OfflineMembers is components: num:NumStudents, sl:Student*; description: (* The section of the OnlineOfflineStudentRoster which contains offline members. *); end OfflineMembers; object NotOnClassListMembers is components: num:NumStudents, sl:Student*; description: (* The section of the OnlineOfflineStudentRoster which contains members who are not on the class list. *); end NotOnClassListMembers; object NumStudents is integer description: (* This is the number of students inside of the collection. *); end NumStudents; operation LoadStudentRoster is inputs: cl:ClassList, sr:StudentRoster; outputs: oosr:OnlineOfflineStudentRoster; precondition: (* The classList is a valid list of student names *) cl != nil; postcondition: (* A new sorted roster called the oNlineOfflineStudentRoster is created. This is sorted by who is online from the class list, who is offline from the class list, and who is not on the class list. The default view goes to onlineoffline when one of these is created. *) oosr.vm?onoff and (forall (name in cl) (exists (stu in sr.stu) (stu.name = name) iff (stu in oosr.onmem.sl) ) or (exists (stu in sr.stu) (stu.name != name) iff (stu in oosr.offmem.sl) ) ) and (forall (stu in sr.stu) if (not (stu.name in cl)) then (stu in oosr.notonlist.sl) ); description: (* Sorts the Student Roster list by using a ClassList to define who is online, offline, and not on the class list but on the network. *); end LoadStudentRoster; operation ChangeViewMode is inputs: oosr:OnlineOfflineStudentRoster, newvm:ViewMode; outputs: oosr':OnlineOfflineStudentRoster; precondition: (* the new view mode is either online/offline or online, it can't be the normal mode which is viewed when a class list is not loaded *) newvm?onoff or newvm?on; postcondition: (* the roster has the new view mode *) oosr'.vm = newvm; description: (* Changes the viewmode to view either both Online and Offline members or strictly online members. *); end ChangeViewMode; object ClassList is components: name:Name*; description: (* A class list is a list of student names who are in the class *); end ClassList; object ViewMode is onoff:OnlineOffline or on:Online description: (* The viewmode in which the roster is seen in. *); end ViewMode; object OnlineOffline is description: (* The viewmode which shows both online and offline members on the roster. *); end OnlineOffline; object Online is description: (* The Viewmode which shows only the online members on the roster. *); end Online; object Student is components: name:Name, mode:Mode, act:Activity; description: (* A Student has a name, a current mode they are in, and if they have an activity tag on. *); end Student; operation BanStudent is inputs: stu:Student, sr:StudentRoster; outputs: stu':Student, sr':StudentRoster; precondition: (* student's mode is either freedom, feedback, or lockdown. *) stu.mode?lockdown or stu.mode?feedback or stu.mode?freedom; postcondition: (* student's mode is banned. *) stu'.mode?banned and (stu' in sr'.stu); description: (* Bans a student from viewing the lecture from the unsorted viewing roster, from the roster which a class list hasnt been loaded onto yet. *); end BanStudent; operation BanStudent is inputs: stu:Student, oosr:OnlineOfflineStudentRoster; outputs: stu':Student, oosr':OnlineOfflineStudentRoster; precondition: (* student's mode is either freedom, feedback, or lockdown. *) stu.mode?lockdown or stu.mode?feedback or stu.mode?freedom; postcondition: (* student's mode is banned. *) stu'.mode?banned and ((stu' in oosr'.onmem.sl) or (stu' in oosr'.notonlist.sl)); description: (* Bans a student from viewing the lecture from the sorted viewing roster. *); end BanStudent; operation SetStudentMode is inputs: stu:Student, sr:StudentRoster; outputs: stu':Student, sr':StudentRoster; precondition: (* student's mode is either freedom, feedback, or lockdown. *) stu.mode?lockdown or stu.mode?feedback or stu.mode?freedom; postcondition: (* student's mode is either freedom, feedback, or lockdown. *) (stu'.mode?lockdown or stu'.mode?feedback or stu'.mode?freedom) and (stu' in sr'.stu); description: (* Changes a student mode to the one specified through the unsorted viewing roster, the roster whcih a class list hasn't been loaded onto yet. *); end SetStudentMode; operation SetStudentMode is inputs: stu:Student, oosr:OnlineOfflineStudentRoster; outputs: stu':Student, oosr':OnlineOfflineStudentRoster; precondition: (* student's mode is either freedom, feedback, or lockdown. *) stu.mode?lockdown or stu.mode?feedback or stu.mode?freedom; postcondition: (* student's mode is either freedom, feedback, or lockdown. *) (stu'.mode?lockdown or stu'.mode?feedback or stu'.mode?freedom) and ((stu' in oosr'.onmem.sl) or (stu' in oosr'.notonlist.sl)); description: (* Changes a student mode to the one specified through the OnlineOfflineStudentRoster. *); end SetStudentMode; operation AnswerStudentQuestion is inputs: stu:Student, sr:StudentRoster, ss:StudentScreen, ts:TeacherScreen; outputs: stu':Student, sr':StudentRoster, ts':TeacherScreen; precondition: (* student activity is Question *) stu.act?ques; postcondition: (* student activity is NoActivity and the students current layer is on the teachers screen*) stu'.act?noact and (stu' in sr'.stu) and (if (ss.ls.curlay != nil) then (ss.ls.curlay in ts'.lecscr.lay)); description: (* Takes the students current layer and makes it part of the professors layer list, and removes the activity tag from the student roster. *); end AnswerStudentQuestion; operation AnswerStudentQuestion is inputs: stu:Student, oosr:OnlineOfflineStudentRoster, ss:StudentScreen, ts:TeacherScreen; outputs: stu':Student, oosr':OnlineOfflineStudentRoster, ts':TeacherScreen; precondition: (* student activity is Question *) stu.act?ques; postcondition: (* student activity is NoActivity *) stu'.act?noact and ((stu' in oosr'.onmem.sl) or (stu' in oosr'.notonlist.sl)) and (if (ss.ls.curlay != nil) then (ss.ls.curlay in ts'.lecscr.lay)); description: (* Takes the students current layer and makes it part of the professors layer list, and removes the activity tag from the OnlineOfflineStudentRoster. *); end AnswerStudentQuestion; operation AnswerStudentComment is inputs: stu:Student, sr:StudentRoster, ss:StudentScreen, ts:TeacherScreen; outputs: stu':Student, sr':StudentRoster, ts':TeacherScreen; precondition: (* student's activity is set to Comment *) stu.act?com; postcondition: (* student's activity is set to NoActivity *) stu'.act?noact and (stu' in sr'.stu) and (if (ss.ls.curlay != nil) then (ss.ls.curlay in ts'.lecscr.lay)); description: (* Takes the students current layer and makes it part of the professors layer list, and removes the activity tag from the StudentRoster. *); end AnswerStudentComment; operation AnswerStudentComment is inputs: stu:Student, oosr:OnlineOfflineStudentRoster, ss:StudentScreen, ts:TeacherScreen; outputs: stu':Student, oosr':OnlineOfflineStudentRoster, ts':TeacherScreen; precondition: (* student's activity is set to Comment *) stu.act?com; postcondition: (* student's activity is set to NoActivity *) stu'.act?noact and ((stu' in oosr'.onmem.sl) or (stu' in oosr'.notonlist.sl)) and (if (ss.ls.curlay != nil) then (ss.ls.curlay in ts'.lecscr.lay)); description: (* Takes the students current layer and makes it part of the professors layer list, and removes the activity tag from the OnlineOfflineStudentRoster. *); end AnswerStudentComment; object Name is string description: (* This is simply a string name of the student. *); end Name; object Mode is banned:Banned or lockdown:Lockdown or feedback:Feedback or freedom:Freedom description: (* The four modes the student or guest with communication can be in. *); end Mode; object Banned is description: (* The mode which the viewer is banned from watching and interacting with the lecture. *); end Banned; object Lockdown is description: (* The mode which the viewer is only able to watch the lecture and take notes. *); end Lockdown; object Feedback is description: (* The mode which the viewer can watch the lecture and use communication abilities. *); end Feedback; object Freedom is description: (* The mode which the viewer can watch the lecture, navigate through the lecture, and use the communication abilties. *); end Freedom; object Activity is noact:NoActivity or ques:Question or com:Comment description: (* The current activity tag for the student or guest with communication abilities; *); end Activity; object NoActivity is description: (* The activity tag is "off", the student or guest has no activity. *); end NoActivity; object Question is description: (* The student or guest with communication abilities has a question. *); end Question; object Comment is description: (* The student or guest with commuinication abilities has a comment to make. *); end Comment; operation ChangeStudentName is inputs: stu:Student, new:NewName, sr:StudentRoster; outputs: stu':Student, sr':StudentRoster; precondition: (* the new name can't be null since the user has to enter in data *) new != nil; postcondition: (* students name is changed to whatever specified. *) (stu'.name = new) and (stu' in sr'.stu); description: (* This changes the display name of the selected student on the studentRoster. *); end ChangeStudentName; operation ChangeStudentName is inputs: stu:Student, new:NewName, oosr:OnlineOfflineStudentRoster; outputs: stu':Student, oosr':OnlineOfflineStudentRoster; precondition: (* the new name can't be null since the user has to enter in data *) new != nil; postcondition: (* students name is changed to whatever specified. *) (stu'.name = new) and ((stu' in oosr'.onmem.sl) or (stu' in oosr'.notonlist.sl) or (stu' in oosr'.offmem.sl)); description: (* This changes the display name of the selected student on the OnlineOfflineStudentRoster to the one specified. *); end ChangeStudentName; object NewName is string description: (* The new name that the Student/Guest name is going to be changed to. *); end NewName; object GuestRoster is components: gues:Guest*, isenabled:GuestRosterEnabled, num:NumGuests; operations: GuestRosterEnabled, BanGuest, SetGuestMode, AnswerGuestQuestion, AnswerGuestComment, EnableGuestRoster, DisableGuestRoster, EnableGuestCommunication, DisableGuestCommunication; description: (* A GuestRoster is a list of guests in to manage the modes and communication between each of them. *); end GuestRoster; object NumGuests is integer description: (* This is the number of guests inside of the collection. *); end NumGuests; object GuestRosterEnabled is boolean description: (* If true then the guest roster is enabled for guests to sign in, if false, it is disabled and remote viewers can not sign in. *); end GuestRosterEnabled; object Guest is components: name:Name, mode:Mode, act:Activity, comallow:CommunicationAllowed; description: (* A Guest has a name, a current mode they are in, if they have an activity tag on, and if they have communication abilities. *); end Guest; operation AnswerGuestQuestion is inputs: gues:Guest, gr:GuestRoster, ss:StudentScreen, ts:TeacherScreen; outputs: gues':Guest, gr':GuestRoster, ts':TeacherScreen; precondition: (* Guest activity is Question *) gues.act?ques and gues.comallow = true; postcondition: (* Guest activity is NoActivity *) (gues'.act?noact and gues'.comallow = true) and (gues' in gr'.gues) and (if (ss.ls.curlay != nil) then (ss.ls.curlay in ts'.lecscr.lay)); description: (* Takes the guests current layer and makes it part of the professors layer list, and removes the activity tag from the GuestRoster. *); end AnswerGuestQuestion; operation AnswerGuestComment is inputs: gues:Guest, gr:GuestRoster, ss:StudentScreen, ts:TeacherScreen; outputs: gues':Guest, gr':GuestRoster, ts':TeacherScreen; precondition: (* Guest activity is Comment *) gues.act?com and gues.comallow = true; postcondition: (* Guest activity is NoActivity *) (gues'.act?noact and gues'.comallow = true) and (gues' in gr'.gues) and (if (ss.ls.curlay != nil) then (ss.ls.curlay in ts'.lecscr.lay)); description: (* Takes the guests current layer and makes it part of the professors layer list, and removes the activity tag from the GuestRoster. *); end AnswerGuestComment; object CommunicationAllowed is boolean description: (* If true then the guest communication is enabled if false, it is disabled. *); end CommunicationAllowed; operation BanGuest is inputs: gues:Guest, gr:GuestRoster; outputs: gues':Guest, gr':GuestRoster; precondition: (* Guest's mode is either freedom, feedback, or lockdown*) gues.mode?lockdown or gues.mode?feedback or gues.mode?freedom; postcondition: (* Guest's mode is banned. *) (gues'.mode?banned) and (gues' in gr'.gues); description: (* Bans a guest from watching/interacting with the lecture and changes the display of the guest on the guest roster to reflect that. *); end BanGuest; operation SetGuestMode is inputs: gues:Guest, gr:GuestRoster; outputs: gues':Guest, gr':GuestRoster; precondition: (* Guest's mode is either freedom, feedback, or lockdown. *) gues.mode?lockdown or gues.mode?feedback or gues.mode?freedom; postcondition: (* Guest's mode is either freedom, feedback, or lockdown. *) (gues'.mode?lockdown or gues'.mode?feedback or gues'.mode?freedom) and (gues' in gr'.gues); description: (* changes a guests mode to the one specified through the GuestRoster. *); end SetGuestMode; operation ChangeGuestName is inputs: gues:Guest, new:NewName, gr:GuestRoster; outputs: gues':Guest, gr':GuestRoster; precondition: (* the new name can't be null since the user has to enter in data *) new != nil; postcondition: (* Guests name is changed to whatever specified. *) (gues'.name = new) and (gues' in gr'.gues); description: (* This changes the display name of the selected guest on the GuestRoster to the one specified. *); end ChangeStudentName; operation EnableGuestRoster is inputs: gr:GuestRoster; outputs: gr':GuestRoster; precondition: (* GuestRosterEnabled is false *) gr.isenabled = false; postcondition: (* GuestRosterEnabled is true *) gr'.isenabled = true; description: (* Enables the guest roster for remote viewers to join in. *); end EnableGuestRoster; operation DisableGuestRoster is inputs: gr:GuestRoster; outputs: gr':GuestRoster; precondition: (* GuestRosterEnabled is true*) gr.isenabled = true; postcondition: (* GuestRosterEnabled is false*) gr'.isenabled = false; description: (* Disables the guest roster so remote viewers can not join in. *); end DisableGuestRoster; operation EnableGuestCommunication inputs: gues:Guest, gr:GuestRoster; outputs: gues':Guest, gr':GuestRoster; precondition: (* The guest's communication is disabled *) gues.comallow = false; postcondition: (* CommunicationAllowed is true *) (gues'.comallow = true) and (gues' in gr'.gues); description: (* Allows a guest to have communication abilities just like a normal student and makes the Guest Roster reflect that change. *); end EnableGuestCommunication; operation DisableGuestCommunication inputs: gues:Guest, gr:GuestRoster; outputs: gues':Guest, gr':GuestRoster; precondition: (* The guest's communication is enabled *) gues.comallow = true; postcondition: (* CommunicationAllowed is false *) (gues'.comallow = false) and (gues' in gr'.gues); description: (* Disallows a guest to have communication abilities just like a normal student and makes the Guest Roster reflect that change. *); end DisableGuestCommunication; end Roster;