(* *RSL Operations *2.3.3.3 Create Question *2.3.3.4 Edit Question *Joe DeBruycker *) operation CreateQuestion inputs: id:ID, tp:Type, qt:QuestionText*, df:Difficulty, tm:Time, ca:CorrectAnswer, cls:ClassName, top:Topic*, auth:Author, crtd:Created, nts:Notes; outputs: q:Question; description: (* combines all the fields that make up a Question into a Question object *); precondition: (* * Type must be chosen *) tp != nil and (* * QuestionText cannot be blank *) #qt >= 1 and (* * Difficulty must be chosen *) df != nil and (* * Time cannot be blank *) #tm >= 1 and (* * CorrectAnswer must be chosen/inputted *) ca != nil and (* * ClassName cannot be blank *) cls != nil; postcondition: (* * A question object is properly created *) ; end CreateQuestion; operation AddQuestion inputs: q:Question, qb:QuestionBank; outputs: qb':QuestionBank; description: (* returns the QuestionBank (qb') with the new Question added *); precondition: (* * The QuestionBank exists *) qb != nil and (* * The Question exists (it was created properly) *) q != nil and (* * The ID of the new Question does not refer to a question already in QuestionBank. *) qb.contains(q.ID) = false; postcondition: (* * The QuestionBank is returned with the new Question added *) ; end AddQuestion; operation EditQuestion inputs: qb:QuestionBank, q:Question; outputs: qb':QuestionBank; description: (* changes the Question in the QuestionBank with the matching ID to the new inputted Question, and returns the updated QuestionBank *); precondition: (* * The QuestionBank exists *) qb != nil and (* * The Question exists (it was created properly) *) q != nil and (* * The ID of the new Question refers to a question already in QuestionBank. *) qb.contains(q.ID) = true; postcondition: (* * The QuestionBank (qp') now contains the edited Question *) ; end EditQuestion; (* * Auxiliary Functions. *) function contains(ID)->boolean = ( (* * The ID number is found in the QuestionBank on which this function is called *) ) end;