app/soc/models/survey_record_group.py
author Lennard de Rijk <ljvderijk@gmail.com>
Wed, 01 Jul 2009 16:28:27 +0200
changeset 2474 b8e25769880d
parent 2446 0cf8f034f52d
child 2515 a3513142ae01
permissions -rw-r--r--
Move getMenusForScope to the end of the View class. Adhering to our principle that we the methods we use for generating our menus can be usually found at the bottom of the View class.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     2
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     4
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     8
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    10
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    16
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    17
"""SurveyRecordGroup represents a cluster (mentor/student) of SurveyRecords
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    18
for an evaluation period.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    19
"""
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    20
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    21
__authors__ = [
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    22
  '"Daniel Diniz" <ajaksu@gmail.com>',
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    23
  '"James Levy" <jamesalexanderlevy@gmail.com>',
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    24
]
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    25
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    26
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    27
from google.appengine.ext import db
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    28
2446
0cf8f034f52d Extracted the ProjectSurvey and ProjectGradingSurvey records to a new module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2442
diff changeset
    29
from soc.models.grading_project_survey_record import GradingProjectSurveyRecord
0cf8f034f52d Extracted the ProjectSurvey and ProjectGradingSurvey records to a new module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2442
diff changeset
    30
from soc.models.project_survey_record import ProjectSurveyRecord
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    31
import soc.models.user
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    32
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    33
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    34
class SurveyRecordGroup(db.Expando):
2442
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    35
  """Explicitly group SurveyRecords with a common project.
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    36
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    37
  Because Mentors and Students take different surveys,
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    38
  we cannot simply link survey records by a common project and survey.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    39
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    40
  Instead, we establish a SurveyRecordGroup.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    41
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    42
  A SurveyRecordGroup links a group of survey records with a common
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    43
  project, and links back to its records. 
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    44
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    45
  This entity also includes the current project_status at its creation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    46
  This property is used as a filter in lookups and acts as a safeguard
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    47
  against unpredictable behavior. 
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    48
  """
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    49
2442
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    50
  # TODO Create SurveyGroup model that contains the two Surveys as to make
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    51
  # it possible to setup which surveys should be grouped.
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    52
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    53
  #: Mentor SurveyRecord for this evaluation.
2442
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    54
  mentor_record = db.ReferenceProperty(GradingProjectSurveyRecord, required=False,
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    55
                              collection_name='mentor_record_groups')
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    56
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    57
  #: Student SurveyRecord for this evaluation.
2442
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2430
diff changeset
    58
  student_record = db.ReferenceProperty(ProjectSurveyRecord, required=False,
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    59
                              collection_name='student_record_groups')
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    60
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    61
  #: Project for this evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    62
  project = db.ReferenceProperty(soc.models.student_project.StudentProject,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    63
                                collection_name="survey_record_groups",
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    64
                                required=True)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    65
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    66
  # Status of project at start of evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    67
  initial_status = db.StringProperty(required=True)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    68
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    69
  #: Status of project at end of evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    70
  final_status = db.StringProperty(required=False)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    71
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    72
  #: Property containing the date that this SurveyRecordGroup was created.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    73
  created = db.DateTimeProperty(auto_now_add=True)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    74
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    75
  #: Property containing the last date that this SurveyRecordGroup was modified.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    76
  modified = db.DateTimeProperty(auto_now=True)