(**** * * This file defines operations related to Proctor Functionality. * *) module ProctorFunctionality; from Tests import all; from StudentFunctionality import all; export all; operation ChooseTest inputs: test:Test, tin:timeLimit; outputs: ptest:ProctorTest; precondition: ; postcondition: (* * If the proctor doesn't define a time, the time limit defined on the * test should be used. *) (if (tin = nil) then (ptest.time = test.time) else (ptest.time = tin)) and (* * Check that the list of questions on the test to be proctored is the * same as the list of questions on the test chosen. *) (ptest.questions = test.questions); description: (* The proctor chooses a test to distribute to the students, and has the opportunity to change the time limit for the test. *); end ChooseTest; operation BeginTest inputs: test:Test, s:Server; outputs: s':Server; precondition: ; postcondition: (* * Make sure all the answers on the list of TakenTests for the students * are blank, and that the InProgress flag is set to true. *) (forall (test:TakenTest) (test in s'.tests) iff ((test.answers = nil) and (test.flag))); (* (forall (test:s'.tests) ((test.answers = nil) and (test.flag))); *) description: (* Start the test for given students on a given server. *); end BeginTest; operation ExtendTime inputs: s:Server, new_time:timeLimit; outputs: s':Server; precondition: (* * Time limit input must be greater than zero *) (new_time > 0); postcondition: (* * Check that each test being taken on the Server has the updated time. *) (forall (test:TakenTest) (test in s'.tests) iff (test.time = new_time)); (* (forall (test:s'.tests) (test.time = new_time)); *) description: (* Adds the amount of minutes specified to the current timeLimit. *); end ExtendTime; operation EndTest inputs: s:Server; outputs: submitted:SubmittedTests; precondition: ; postcondition: (* * The two test lists must be equal, and the InProgress flag must be false. *) (forall (i:integer | (i >= 1) and (i < #s.tests) and (i < #submitted)) (s.tests[i] = submitted[i]) and (not submitted[i].flag)); description: (* Changes the time limit to zero. *); end EndTest; end ProctorFunctionality;