app/soc/models/survey_record_group.py
changeset 2567 0162efa63bb6
parent 2566 03ea1e3be104
child 2568 5c456c4d0a0b
equal deleted inserted replaced
2566:03ea1e3be104 2567:0162efa63bb6
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2009 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 """SurveyRecordGroup represents a cluster (mentor/student) of SurveyRecords
       
    18 for an evaluation period.
       
    19 """
       
    20 
       
    21 __authors__ = [
       
    22   '"Daniel Diniz" <ajaksu@gmail.com>',
       
    23   '"James Levy" <jamesalexanderlevy@gmail.com>',
       
    24 ]
       
    25 
       
    26 
       
    27 from google.appengine.ext import db
       
    28 
       
    29 from soc.models.grading_project_survey_record import GradingProjectSurveyRecord
       
    30 from soc.models.project_survey_record import ProjectSurveyRecord
       
    31 import soc.models.user
       
    32 
       
    33 
       
    34 class SurveyRecordGroup(db.Expando):
       
    35   """Explicitly group SurveyRecords with a common project.
       
    36 
       
    37   Because Mentors and Students take different surveys,
       
    38   we cannot simply link survey records by a common project and survey.
       
    39 
       
    40   Instead, we establish a SurveyRecordGroup.
       
    41 
       
    42   A SurveyRecordGroup links a group of survey records with a common
       
    43   project, and links back to its records. 
       
    44 
       
    45   This entity also includes the current project_status at its creation.
       
    46   This property is used as a filter in lookups and acts as a safeguard
       
    47   against unpredictable behavior. 
       
    48   """
       
    49 
       
    50   # TODO Create SurveyGroup model that contains the two Surveys as to make
       
    51   # it possible to setup which surveys should be grouped.
       
    52 
       
    53   #: Mentor SurveyRecord for this evaluation.
       
    54   mentor_record = db.ReferenceProperty(GradingProjectSurveyRecord,
       
    55                                        required=False,
       
    56                                        collection_name='mentor_record_groups')
       
    57 
       
    58   #: Student SurveyRecord for this evaluation.
       
    59   student_record = db.ReferenceProperty(
       
    60       ProjectSurveyRecord, required=False,
       
    61       collection_name='student_record_groups')
       
    62 
       
    63   #: Project for this evaluation.
       
    64   project = db.ReferenceProperty(soc.models.student_project.StudentProject,
       
    65                                 collection_name="survey_record_groups",
       
    66                                 required=True)
       
    67 
       
    68   # Status of project at start of evaluation.
       
    69   initial_status = db.StringProperty(required=True)
       
    70 
       
    71   #: Status of project at end of evaluation.
       
    72   final_status = db.StringProperty(required=False)
       
    73 
       
    74   #: Property containing the date that this SurveyRecordGroup was created.
       
    75   created = db.DateTimeProperty(auto_now_add=True)
       
    76 
       
    77   #: Property containing the last date that this SurveyRecordGroup was modified.
       
    78   modified = db.DateTimeProperty(auto_now=True)