|
1 #!/usr/bin/python2.5 |
|
2 # |
|
3 # Copyright 2008 the Melange authors. |
|
4 # |
|
5 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 # you may not use this file except in compliance with the License. |
|
7 # You may obtain a copy of the License at |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
11 # Unless required by applicable law or agreed to in writing, software |
|
12 # distributed under the License is distributed on an "AS IS" BASIS, |
|
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 # See the License for the specific language governing permissions and |
|
15 # limitations under the License. |
|
16 |
|
17 """This module contains the Response Model.""" |
|
18 |
|
19 __authors__ = [ |
|
20 '"Todd Larsen" <tlarsen@google.com>', |
|
21 ] |
|
22 |
|
23 |
|
24 import polymodel |
|
25 |
|
26 from google.appengine.ext import db |
|
27 |
|
28 from django.utils.translation import ugettext_lazy |
|
29 |
|
30 import soc.models.quiz |
|
31 import soc.models.user |
|
32 |
|
33 |
|
34 class Response(polymodel.PolyModel): |
|
35 """Model of a Response to a Quiz. |
|
36 |
|
37 A Response is the "collection point" for a set of specific Answers to the |
|
38 Questions that make up a Quiz. |
|
39 |
|
40 In addition to the explicit ReferenceProperties in the Response Model, a |
|
41 Response entity participates in these relationships: |
|
42 |
|
43 answers) a 1:many relationship between Answer entities and this |
|
44 Response. Each Answer points to the Response to which it is a part. |
|
45 The collection of Answers that make up a Response is implemented as |
|
46 the 'answers' back-reference Query of the Answer model 'response' |
|
47 reference. |
|
48 """ |
|
49 |
|
50 #: a required many:1 relationship between Responses and a Quiz that |
|
51 #: defines what Questions for which each Response collects Answers |
|
52 #: (that is, there can be many Responses to the same Quiz) |
|
53 quiz = db.ReferenceProperty(reference_class=soc.models.quiz.Quiz, |
|
54 required=True, collection_name="responses") |
|
55 |
|
56 #: a required many:1 relationship with a User that indicates which User |
|
57 #: submitted the Response (answered the Questions in the Quiz) |
|
58 respondent = db.ReferenceProperty( |
|
59 reference_class=soc.models.user.User, required=True, |
|
60 collection_name="responses") |
|
61 |
|
62 # TODO(tlarsen): should 'respondent' be a ReferenceProperty to some Role |
|
63 # instead? |