app/soc/models/survey_record.py
changeset 2446 0cf8f034f52d
parent 2444 6276c3340c30
child 2493 0aabd2d76606
equal deleted inserted replaced
2445:761906e4254d 2446:0cf8f034f52d
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14 # See the License for the specific language governing permissions and
    14 # See the License for the specific language governing permissions and
    15 # limitations under the License.
    15 # limitations under the License.
    16 
    16 
    17 """SurveyRecord represents a single Survey result.
    17 """SurveyRecord represents a single Survey result.
    18 
       
    19 ProjectSurveyRecord allows linking two result sets by StudentProject.
       
    20 
       
    21 GradingProjectSurveyRecord stores the grade in an evaluation survey.
       
    22 """
    18 """
    23 
    19 
    24 __authors__ = [
    20 __authors__ = [
    25   '"Daniel Diniz" <ajaksu@gmail.com>',
    21   '"Daniel Diniz" <ajaksu@gmail.com>',
    26   '"James Levy" <jamesalexanderlevy@gmail.com>',
    22   '"James Levy" <jamesalexanderlevy@gmail.com>',
    31 from google.appengine.ext import db
    27 from google.appengine.ext import db
    32 
    28 
    33 from django.utils.translation import ugettext
    29 from django.utils.translation import ugettext
    34 
    30 
    35 from soc.models.survey import Survey
    31 from soc.models.survey import Survey
    36 from soc.models.grading_project_survey import GradingProjectSurvey
       
    37 from soc.models.project_survey import ProjectSurvey
       
    38 import soc.models.student_project
       
    39 import soc.models.user
    32 import soc.models.user
    40 
    33 
    41 
    34 
    42 class BaseSurveyRecord(db.Expando):
    35 class BaseSurveyRecord(db.Expando):
    43   """Record produced each time Survey is taken.
    36   """Record produced each time Survey is taken.
    78 
    71 
    79   def getSurvey(self):
    72   def getSurvey(self):
    80     """Returns the Survey belonging to this record.
    73     """Returns the Survey belonging to this record.
    81     """
    74     """
    82     return self.survey
    75     return self.survey
    83 
       
    84 class ProjectSurveyRecord(SurveyRecord):
       
    85   """Record linked to a Project, enabling to store which Projects had their
       
    86   Survey done.
       
    87   """
       
    88 
       
    89   #: The survey for which this entity is a record.
       
    90   project_survey = db.ReferenceProperty(ProjectSurvey,
       
    91                                 collection_name="project_survey_records")
       
    92 
       
    93   #: Reference to the Project that this record belongs to.
       
    94   project = db.ReferenceProperty(soc.models.student_project.StudentProject,
       
    95                                  collection_name="survey_records")
       
    96 
       
    97   def getSurvey(self):
       
    98     """Returns the ProjectSurvey that belongs to this record.
       
    99     """
       
   100     return self.project_survey
       
   101 
       
   102 
       
   103 class GradingProjectSurveyRecord(ProjectSurveyRecord):
       
   104   """Grading record for evaluation surveys.
       
   105 
       
   106   Represents the grading part of a evaluation survey group (usually a pair)
       
   107   where the grading (e.g. Mentor's) survey is linked to a non-grading (e.g
       
   108   Student's) one by a project.
       
   109   """
       
   110 
       
   111   #: The survey for which this entity is a record.
       
   112   grading_survey = db.ReferenceProperty(GradingProjectSurvey,
       
   113                                 collection_name="grading_survey_records")
       
   114 
       
   115   #: Required grade given to the project that this survey is about.
       
   116   grade = db.BooleanProperty(required=True)
       
   117 
       
   118   def getSurvey(self):
       
   119     """Returns the GradingProjectSurvey that belongs to this record.
       
   120     """
       
   121     return self.grading_survey