module Test_Preferences;
export all;

object TestPreferences is
	components: df:DifficultyVariance and tv:TimeVariance and qtv:QTimeVariance and tlv:TestLengthVariance and fv:FormatVariance;
	description: (*
		The test preferences object contains the maximum allowed variances for both the difficulty of the questions on a test as well as the total time length of the test.
	*) ;
end TestPreferences;

object DifficultyVariance is
	components: v:integer ;
	description: (*
		Contains the maximum allowed deviation from the specified question difficulty level. This number must be between zero and five.
	*) ;
end DifficultyVariance;

object TimeVariance is
	components: v:integer ;
	description: (*
		Contains the maximum allowed deviation from the specified test length (in minutes).
	*) ;
end TimeVariance;

object TestLengthVariance is
	components: v:integer ;
	description: (*
		Contains the maximum allowed deviation from the specified number of questions
	*) ;
end TestLengthVariance;

object FormatVariance is
	components: v:integer ;
	description: (* the number of questions that can be varied on a test for a particular format *);
end FormatVariance;

object QTimeVariance is
	components: v:integer;
	description: (* the amount each particular question may vary from the question time given *);
end QTimeVariance;

end Test_Preferences;



module Menus; 
from TestGeneration import all;
from QuestionManagement import all;
from TestPackage import all;
from Test_Preferences import all;
export all;

operation FileNewTest is
	inputs: ;
	outputs: Test ;
	description: (*
		Creates a new blank test. *);
end FileNewTest;

operation FileOpenTest is
	inputs: FilePath ;
	outputs: Test ;
	description: (*
		Opens a specified path and displays the test on the screen *);
end FileOpenTest ;

operation FileSaveTest is
	inputs: FilePath ;
	outputs: ;
	description: (*
		Saves the currently open test to a file on the hard disk. *) ;
end FileSaveTest ;

operation EditPreferences is
	inputs: DifficultyVariance and TimeVariance and TestLengthVariance and QTimeVariance and FormatVariance;
	outputs: TestPreferences ;
	description: (*
		Opens the preferences dialog box and allows for editing. *) ;
end EditPreferences ;

operation TestGenerate is
	inputs: TestFilter, Test ;
	outputs: Test ;
	description: 
		(* Opens the test generation wizard. Creates a filter based on the wizard and generates a test. *) ;
end TestGenerate ;

operation TestPreview is
	inputs: Test;
	outputs: PreviewTest;
	description: (*
		This displays what the test how the student will view it when he is taking it 	*) ;
end TestPreview ;

operation QuestionAdd is
	inputs: q:TestQuestion, tst:Test;
	outputs: tst':Test ;
	description: (*
		This will open the question database and allow a user to select a question to add to the test (this may also mean creaitng a new question to add to the DB *) ;
	precondition: ;
	postcondition:
	       (forall(q' in tst.qs)
			(q' in tst'.qs))
		and (q in tst'.qs)
		and (#tst'.qs = #tst.qs + 1);
end QuestionAdd;

operation QuestionDelete is
	inputs: q:TestQuestion, tst:Test ;
	outputs: tst':Test ;
	description: (*
		Removes the currently selected question. If no question is selected, the user is prompted to select a question before continuing. *) ;
	precondition: q in tst.qs;
	postcondition:
		forall(q' in tst.qs)
			(q' in tst'.qs iff q' != q)
		and #tst'.qs = #tst.qs - 1;
end QuestionDelete ;



obj FilePath is string;
obj PreviewTest is integer;

end Menus;