5.7. testtaking.fmsl

module TestTaking;

	import TestGeneration.GeneratedTest;
	import TestGeneration.GeneratedSection;
	import TestGeneration.TestQuestion;
	import TestGeneration.AuthorizedStudent;
	
   import Questions.Question;
	import Questions.Answer;
	import Courses.Course;
	import Courses.TestType;

	(*from Answer import CodeAnswer;
	from Answer import MatchingAnswer;
	from Answer import MultipleChoiceAnswer;
	from Answer import EssayAnswer;*)

	export 	AnsweredTest, AnsweredSection, AnsweredQuestion,
    MultipleChoiceAnswer, CodeAnswer, FreeResponseAnswer, EssayAnswer,
    MatchingAnswer;	
	
	object AnsweredTest extends GeneratedTest
		components:		answeredSections:AnsweredSection*,
					taker:AuthorizedStudent, answers:AnsweredQuestion*;
		description: (*
			A set of sections that contain questions with corrosponding answers (initally blank). With
			associated information such as a student name, id
			number.
		*);
	end AnsweredTest;

	object AnsweredSection extends GeneratedSection
		components:		answerdQuestions:AnsweredQuestion*;
	end AnsweredSection;

	object AnsweredQuestion extends TestQuestion
		components:		selected:Answer;
	end AnsweredQuestion;

	operation takeTest
		inputs: name:string, id:integer, test:GeneratedTest;
		outputs: AnsweredTest;
		description: (*
			Creates a new AnsweredTest with no answers.
		*);
	end takeTest;

	operation saveAnswer
		inputs: test:AnsweredTest, answer:AnsweredQuestion, 
questionNumber:integer;
		outputs: test':AnsweredTest;
		 precondition: ;
        postcondition: forall(aq:AnsweredQuestion)
            (aq in test'.answers <=>
            (aq = answer xor aq in test.answers))
 
        (* answer is in test at questionNumber's location 
		answer in AnsweredTest'*);
		description: (*
			Adds an answer to a question.
		*);
	end saveAnswer;

	operation setInProgress 
		inputs: test:AnsweredTest, questionNumber:integer;
		outputs: AnsweredTest;
		 precondition: ;
       postcondition: 
        (* answer is marked in test at questionNumber's location to be in progress
		answer in AnsweredTest' *);
		description: (*
			Toggles the given question as in progress or not.
		*);
	end setInProgress;

	operation typeCodeAnswer 
		inputs: test:AnsweredTest, questionNumber:integer, code:string;
		outputs: CodeAnswer;
	    precondition: ;
       postcondition:        (* code is in test at questionNumber's location 
		code in AnsweredTest' *);
		description: (*
			Saves the answer to a code question
		*);
	end typeCodeAnswer;
	
	operation saveRev
		inputs: test:AnsweredTest, questionNumber:integer, code:string;
		outputs: AnsweredTest, integer;
		 precondition: ;
         postcondition: 
        (* code is in test at questionNumber's location marked with a revision number
		code in test'
		answer in AnsweredTest' *);
		description: (*
			Adds a revision to the code question.
		*);
	end saveRev;
	
	   operation loadRev 
		inputs: test:AnsweredTest, questionNumber:integer, selection:integer;
		outputs: AnsweredTest;
		description: (*
			Changes which revision of a code answer is displayed.
		*);
	end loadRev;

	operation openIDE 
		inputs: test:AnsweredTest, questionNumber:integer;
		outputs: AnsweredTest;
		description: (*
			Opens an IDE for answering code questions. The answer 
			is saved when the IDE is closed.
		*);
	end openIDE;

	operation testRun 
		inputs: test:AnsweredTest, questionNumber:integer;
		outputs: string;
		description: (*
			Runs the code and outputs the results of the run.
		*);
	end testRun;

	operation testCompile 
		inputs: test:AnsweredTest, questionNumber:integer;
		outputs: string;
		description: (*
			Attempts to compile the code answer and displays the 
			results.
		*);
	end testCompile;

	operation dragMatching 
		inputs: test:AnsweredTest, questionNumber:integer, left:integer, right:integer;
		outputs: MatchingAnswer;
		description: (*
			<>
		*);
	end dragMatching;
	
	operation checkMultipleChoice 
		inputs: test:AnsweredTest, question:Question, choice:integer;
		outputs: MultipleChoiceAnswer;
		description: (*
		*);
	end checkMultipleChoice;

   operation spellCheck 
		inputs: question:Question, text:string;
		outputs: ;
		description: (*
			.
		*);
	end spellCheck;

	operation typeEssayAnswer 
		inputs: question:Question, essay:string;
		outputs: EssayAnswer;
		description: (*
		*);
	end typeEssayAnswer;

	operation typeShortAnswer 
		inputs: question:Question, essay:string;
		outputs: EssayAnswer;
		description: (*
		*);
	end typeShortAnswer;

	object CodeAnswer
	end CodeAnswer;

	object MatchingAnswer
	end MatchingAnswer;

	object MultipleChoiceAnswer
	end MultipleChoiceAnswer;

	object EssayAnswer
	end EssayAnswer;

    object FreeResponseAnswer
    end FreeResponseAnswer;

end TestTaking;

 


Prev: testgrading.fmsl | Next: workspace.fmsl | Up: specification | Top: index