(* this file must be compiled with gradeditems.rsl at the same time *) module NewClass; from GradedItems import Gradebook, total, Item; export all; object RawStudent is components: name:Name and id:ID and major:Major and email:Email and unix:UNIXLogin; description: (* student without classwork attached *); end RawStudent; object Name is components: string; description: (* name *); end Name; object ID is components: integer; description: (* ID *); end ID; object Major is components: string; description: (* major *); end Major; object Email is components: string; description: (* email *); end Email; object UNIXLogin is components: string; description: (* UNIX login *); end UNIXLogin; object Column is components: total* or Item*; description: (* contains total column or Item column for purposes of statistics calculation *); end Column; object NewClassInfo is components: coursename:CourseName and downlod:Download and login:Login and password:Password; description: (* info for a new class *); end NewClassInfo; object CourseName is components: string; description: (* course name *); end CourseName; object Download is components: boolean; description: (* whether to download roster from SIS *); end Download; object Login is components: string; description: (* instructor's login *); end Login; object Password is components: string; description: (* password *); end Password; object Server is components: users:Users and db:Database; description: (* server info *); end Server; object Users is components: ur:UserRecord*; description: (* users *); end Users; object UserRecord is components: uid:UserID and password:Password; description: (* user record *); end UserRecord; object UserID is components: string; description: (* user id *); end UserID; object Database is components: ...; description: (* server-side student database *); end Database; object StatsBar is components: Mean and Median and StdDev and Range and DataPoints; description: (* statistics bar *); end StatsBar; object Mean is components: real; description: (* mean *); end Mean; object Median is components: real; description: (* median *); end Median; object StdDev is components: real; description: (* standard deviation *); end StdDev; object Range is components: real; description: (* range *); end Range; object DataPoints is components: integer; description: (* number of data points *); end DataPoints; object List is components: ListElement*; description: (* list object for stats operations *); end List; object ListElement is components: real; description: (* list element object for stats operations *); end ListElement; operation CreateNewClass is inputs: nci:NewClassInfo; outputs: g:Gradebook; precondition: ; postcondition: ; description: (* creates a new class *); end CreateNewClass; operation Login inputs: s:Server, uid:UserID, passwd:Password; outputs: db:Database; precondition: exists (u:User) u in s.users (u.uid = uid) and (u.passwd = passwd); postcondition: db = s.db; description: (* logs in to the specified server for roster retrieval or gradebook updating *); end Login; operation AddStudent is inputs: s:Student, g:Gradebook; outputs: g':Gradebook; precondition: (not (exists (s':Student) s in g and s'.ID = s.ID)) and (s.ID != nil) and (#(s.ID) <= 8); postcondition: forall (s':Student) (s' in g') iff ((s' = s) or (s' in g)); description: (* adds a student to the class *); end AddStudent; operation EditStudent is inputs: g:Gradebook, old_s:Student, new_s:Student; outputs: g':Gradebook; precondition: (old_s != new_s) and (old_s in g) and (not (exists (new_s' in g) new_s'.id = new_s.id)) and (new_s.id != nil) and (#(new_s.id) <= 8) and (new_s.email != nil); postcondition: forall (s':Student) (s' in g') iff (((s' = new_s) or (s' in g)) and (s' != old_s)); description: (* edits a student already in the class *); end EditUser; operation DeleteStudent is inputs: g:Gradebook, s:Student; outputs: g':Gradebook; precondition: s in g; postcondition: (forall (s':Student) (s' in g') iff ((s' != s) and (s' in g))); description: (* removes a student from the class *); end DeleteUser; operation Sum is inputs: r:real*; outputs: s:real; precondition: ; postcondition: ; description: (* adds inputs together and outputs the sum *); end Sum; operation CalcMean is inputs: g:Gradebook, c:Column; outputs: m:Mean; precondition: ; postcondition: (* forall (i:integer | (i >= 1) and (i < #c)) s:integer = s + c[i]; <-- not sure if this is right so i put Sum() in late work *) m = Sum(c)/#c; description: (* calculates mean *); end CalcMean; operation SortA is inputs: l:List; outputs: l':List; precondition: ; postcondition: (forall (i:integer | (i >= 1) and (i < #l)) l[i].ListElement < l[i+1].ListElement); description: (* sorts data in list *); end SortA; operation CalcMedian is inputs: g:Gradebook, c:Column; outputs: m:Median; precondition: ; postcondition: m = SortA(c)[#c/2]; description: (* calculates median *); end CalcMedian; operation CalcStdDev is inputs: g:Gradebook, c:Column; outputs: s:StdDev; precondition: ; postcondition: ; description: (* calculates standard deviation *); end CalcStdDev; operation CalcRange is inputs: g:Gradebook, c:Column; outputs: r:Range; precondition: ; postcondition: r = SortA(c)[#c] - SortA(c)[1]; description: (* calculates range *); end CalcRange; operation CalcDataPoints is inputs: g:Gradebook, c:Column; outputs: d:DataPoints; precondition: ; postcondition: d = #c; description: (* returns number of data points *); end CalcDataPoints; end NewClass;