(**** * * Module File defines the operations related to opening a test, saving a test, saving a * test under a specific file name, and exiting the StudentInterface. * *) module File; operation OpenTest is inputs: TestFile; outputs: Test; description: (* OpenTest will open a test file from a specific directory and display it in the StudentInterface. The student may only open test files in the StudentInterface and not any other type of file. *); precondition: (* * A test file must exist and be located in a directory that is accessible by the * student. *) (exists (tf:TestFile) (tf = Test)); postcondition: (* * The test file is opened into the StudentInterface filling in the entire * StudentInterface area. *) (Test in StudentInterface); end OpenTest; operation SaveTest is inputs: Test and fsd: FileSaveDialog; outputs: tf':TestFile; description: (* SaveTest will save any changes made to the currently displayed Test in the StudentInterface to the test file that contains the test. This option only updates the test file with the new changes that are not contained in the old test file. The Save operation should be disabled when a student is taking an in class test. *); precondition: (* * A test file must exist and be located in a directory that is accessible by the * student. *) (exists (tf:TestFile) (tf = Test)); postcondition: (* * Changes must have been made to the test in the StudentInterface that are not * contained in the old test file. *) (tf = tf'); end SaveTest; operation SaveTestAs is inputs: Test and fsd:FileSaveDialog; outputs: tf':TestFile; description: (* SaveTestAs will save the test file currently displayed in the StudentInterface as a new file in a specific directory. This operation can either create a new file with a new name or overwrite an old file with the same name. If overwriting a file with the same name, the student must be prompted that saving the test file will overwrite the old file and if he wishes to continue. When a student does save a file using the Save As operation, the file can only be saved as a test file type. The Save As operation should be disabled when the student is taking an in class test. *); precondition: (* * A test object must exist as an object that can be saved as a file and be displayed * in the StudentInterface. *) (exists (t:Test) (t in StudentInterface)); postcondition: (* * A test file is made from the test object currently displayed in the StudentInterface * under a file name of the student's choosing. The test file is saved in a directory * accessible by the student. *) (tf' = Test); end SaveTestAs; operation ExitStudentInterface is inputs: t:Test; outputs: tf:TestFile, tf':TestFile; description: (* ExitStudentInterface will close the StudentInterface and exit the program. If there is a test in the StudentInterface that has been changed but not saved, a prompt will appear asking the student if he would like to save the changes to the Test before exiting the StudentInterface. *); postcondition: (* * If a test is displayed in the StudentInterface that has been changed but not saved, * the student is asked if he would like to save the changes to the test before exiting. *) if( tf = t) then ( tf = TestFile) or if( tf != Test) then ( tf' = TestFile); end ExitStudentInterface; end File;