5.1. Questions (Questions.sl)
(****
*
* Module Question defines the objects and operations related to the Management of the Questions.
*
*)
module Question;
object QuestionDatabase
components: questions;
description: (* The complete DB of questions availible to be used. *);
end;
object questions = Question*;
object Question
components: ID and question and images* and key and difficulty and timeLimit and course and lastTaken and parentID;
description: (*"A Question is the information stored about a complete question. The ID a unique identifier by which the question is identifiied. Images is a list of Images shown in a question. Key is the solution to the question. Difficulty is the level of difficulty of the question, either E = Easy , M = Medium, H = Hard. timeLimit is ammount of time allocated to complete the question. course is the course this question is designed for. lastTaken is the date the question was last used. *);
end Question;
object Date = string;
object Images = string;
object ID = integer;
object question = string;
object images = Images*;
object key = string;
object difficulty = integer;
object timeLimit = integer;
object course = string;
object lastTaken = Date;
object parentID = ID;
object AnsweredQuestion
components: answer;
description: (* An AnsweredQuestion contains the students answer to a Question *);
end AnsweredQuestion;
object answer = string;
object GradedQuestion
components: score;
description: (* A GradedQuestion contains the score for a completed and graded question *);
end GradedQuestion;
object score = integer;
object MultipleChoice
components: options and answeredIndeces and numAllowedChoices;
description: (* A MultipleChoice questions contains the specific information for this type of question. *);
end MultipleChoice;
object options = string*;
object answeredIndeces = integer*;
object numAllowedChoices = integer;
object Coding
components: script and answer;
description: (* A Coding question contains the file script for grading and the solution to the question *);
end Coding;
object File = string;
object script = File;
object Answer = string;
object LongAnswer
components: keywords and orderMatters and wordCountLimit;
description: (* A LongAnswer question contains the information for creation this type of question *);
end LongAnswer;
object keywords = string*;
object orderMatters = boolean;
object wordCountLimit = integer;
object Fillin
components: answers;
description: (* A Fillin question contains a list of answers to the question *);
end Fillin;
object answers = string*;
operation addQestion
inputs: q:Question, qd:QuestionDatabase;
outputs: qd':QuestionDatabase;
precondition: forall(q1 in qd)
q1 != q;
postcondition: qd' = qd + q;
description: (* Adds a question to the database *);
end addQuestion;
operation editQuestion
inputs: q:Question, qd:QuestionDatabase;
outputs:qd':QuestionDatabase;
precondition: q in qd;
postcondition: q in qd';
description: (* Edits an existing question in the database *);
end editQuestion;
operation deleteQuestion
inputs: q:Question, qd:QuestionDatabase;
outputs: qd':QuestionDatabase;
precondition: q in qd;
postcondition: qd' = qd - q;
description: (* Deletes a question from the database *);
end deleteQuestion;
operation setScore
inputs: sc:score, AnsweredQuestion;
outputs: GradedQuestion;
precondition: sc >= 0;
description: (* Sets the specific score of an Answered Question *);
end setScore;
operation getScore
inputs: GradedQuestion;
outputs: score;
description: (* Gets the score for a GradedQuetion *);
end getScore;
end Question;
Prev:
| Next: TestGroup.sl
| Up: spec
| Top: index