Reputation: 1461
In the class diagram a User can take multiple exams. An Exam is made up of several categories. Each Category has many questions. Each Question has many choices.
The two places I have questions about are where the User interacts with the Exam.
A friend of mine said I should have an association class between User and Exam called Examination. I guess, as attributes, it could have DateTime and Score. Why can't Exam store the score and have a completion date? (Doesn't that mean that when the exam is complete it simply changes states?) With this design i guess it will have to have an attribute for User as well. This will couple User and Exam. (If i need Examination to store the score, then will I need a CompletedCategory to store the individual scores for each Category?)
The other place is the relationship between User and Question. Or should it be User and Choice? I need somewhere to store the response to the questions before the score is calculated. These responses have to be saved to the Database as well. Should Response be an association class or a list in Question?
Can someone explain to me the pros and cons? Is there a good resource I can read? I've read lots of StackOverflow articles. I learned a lot but still not sure which are the best designs.
The following article was helpful: http://www.codeproject.com/Articles/9900/Identifying-Object-Oriented-Classes
But I'm still not sure why this is true: "For example, a Student class has an association to a Course class. A student can take many courses, and a course can be taken by many students. However, who is responsible for the grade? Placing the grade in the Student class gives a student the same grade for all courses. Placing the grade in the Course class gives all students taking the same course the same grade."
Why can't each Exam, in my case, not simply have a User assigned to it. True that does seem to imply an Exam Session or Examination as my friend said. I can't justify it by clear explanation. Then what do i do with Category which has it own scores and Responses?
Thanks!
Upvotes: 1
Views: 1322
Reputation: 5673
The model below includes all your entity types (except categories). Notice that while a test (as an instance of Test
) is an event type, a test execution (as an instance of TestExecution
) is a specific event (with occurrence time). It's a general modeling pattern that events have participations by objects, such as the participation of a person in a test execution. Such a participation is also an event.
Since participations can as well be viewed as links (relationships) between events and their participants, we may model an association Participation
.
In the case of test participations, we want to record the grade achieved by the participant. For this purpose, the UML concept of an association class comes in handy. It allows to define attributes (and other class features) for an association, with a visual notation that clearly indicates its nature as an association, as shown in the following class diagram:
Notice that since association ends are unique by default, this model implies that the same person can have at most one participation link with a particular test execution, which is a constraint that holds for participations in test executions, indeed. If we wouldn't model Participation
as an association class, but rather as a class, as in the following model, we have to express this constraint explicitly:
As requested, here are some additional explanations about the basic categories of information modeling: entities, subsuming objects and events, and entity types.
In Ontology, which is the philosophical study of what there is, the following fundamental distinctions are made:
These ontological distinctions are discussed, e.g., in (Guizzardi and Guarino 2015) and in (Guizzardi et al. 2013).
Clearly, objects and events are the most basic categories for modeling information systems and information management apps.
UML links (understood as material relationships) are based on events. For instance, an is-married-to link between two persons is based on their marriage (or wedding) event. The fact that links are based on events implies that associations (as link types) are based on event types, and there is a certain ambiguity whether to model certain concepts as an event type or as an association.
Objects participate in events. Events are ontologically dependent entities in the sense that they existentially depend on their participants in order to exist. Take for instance the event of Caesar being stabbed by Brutus. In this event we have the participation of Caesar himself, of Brutus and of the dagger.
There is an interesting, and fundamental, duality between objects and events: while all temporal properties of objects are defined in terms of the events they participate in, all spatial properties of events are defined in terms of the spatial properties of their participants.
After modeling all relevant object types in the first step, we model the relevant event types in a second step. The main type of association between events and objects is participation. When adding event types to the object types in our (conceptual) information model, we therefore also model the participation types between them.
Upvotes: 3
Reputation: 36323
The Examination
class would relate the Student
and the Exam
. The Student
is an entity and lives (hopefully) on its own. The Exam
is also an individual entity (it's all the questions and answers that relate to each other). Now the Examination
comes in and relates both. Since a Student
can have many Exams
and vice versa you need something to couple both.
Now whether you take a simple class or an association class is (as I see it) more a matter of taste. You would use a simple association like
if you just combine two objects and add some attributes (like
score
and completionDate
).
The use of an association class
should be used if you add also operations which enhance the association between
Student
and Exam
(e.g. to deliver a set of students the have a specific grade).
However, I'd say that both notations are interchangeable.
Regarding the question/answer I'd simply add a question/answer class and make an exam composed of them:
Though this is quite simplistic but from here I would start to go into details.
Upvotes: 3
Reputation: 24484
Why can't Exam store the score and have a completion date?
You are right. "The Exam on Math/Algebra 2nd semester" COULD have several examinations, if we take exam as finishing the course and examination as a try for the finishing. But here, as you have put questions in the Exam, the date and time belong to it, too. Your exam IS the examination already.
Without any doubt, your model can be greatly improved by dividing your huge classes into smaller and more convenient ones. But your model can work, too.
Upvotes: 1