Removed two obsolete/outdated methods in Survey Logic.
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 02 Jul 2009 11:25:52 +0200
changeset 2480 0079e1038740
parent 2479 b83c9b1ea0e1
child 2481 031e5828f3a4
Removed two obsolete/outdated methods in Survey Logic. The updateSurveyRecord can be found in the SurveyRecord logic.
app/soc/logic/models/survey.py
--- a/app/soc/logic/models/survey.py	Thu Jul 02 10:46:39 2009 +0200
+++ b/app/soc/logic/models/survey.py	Thu Jul 02 11:25:52 2009 +0200
@@ -93,92 +93,6 @@
 
     return survey_content
 
-  def updateSurveyRecord(self, user, survey, survey_record, fields):
-    """ Create a new survey record, or get an existing one.
-
-    params:
-      user = user taking survey
-      survey = survey entity
-      survey_record = existing record, if one exists
-      fields = submitted responses to survey fields
-    """
-    if survey_record:
-      create = False
-      for prop in survey_record.dynamic_properties():
-        delattr(survey_record, prop)
-    else:
-      create = True
-      survey_record = SurveyRecord(user=user, survey=survey)
-
-    schema = eval(survey.survey_content.schema)
-
-    for name, value in fields.items():
-      if name == 'project':
-        project = student_project.StudentProject.get(value)
-        survey_record.project = project
-      elif name == 'grade':
-        survey_record.grade = GRADES[value]
-      else:
-        pick_multi = name in schema and schema[name]['type'] == 'pick_multi'
-        if pick_multi and hasattr(fields, 'getlist'): # it's a multidict
-          setattr(survey_record, name, ','.join(fields.getlist(name)))
-        else:
-          setattr(survey_record, name, value)
-
-    # if creating evaluation record, set SurveyRecordGroup
-    db.put(survey_record)
-    if 'evaluation' in survey.taking_access and create:
-      if not project: return False
-      role = self.getUserRole(user, survey, project)
-      survey_record_group = self.setSurveyRecordGroup(survey,
-      survey_record, project)
-      if survey_record_group:  db.put(survey_record_group)
-
-    return survey_record
-
-  def setSurveyRecordGroup(self, survey, survey_record, project):
-    """First looks for an existing SurveyRecordGroup, using the
-    project and its current status as a filter.
-
-    IOW SurveyRecordGroup cannot consist of surveys taken with
-    two different statuses.
-
-    This means that a student cannot take a survey after the mentor
-    has taken the accompanying survey and the project has since
-    changed. (Assuming we want this strict behavior)
-
-    params:
-      survey = survey entity
-      survey_record = saved response to survey
-      project = student project for survey taker
-    """
-
-    group_query = SurveyRecordGroup.all(
-    ).filter("project = ", project
-    ).filter("initial_status = ", project.status
-    )
-
-    if survey.taking_access == 'mentor evaluation':
-      survey_record_group = group_query.filter(
-      "mentor = ", None ).get()
-    elif survey.taking_access == 'student evaluation':
-      survey_record_group = group_query.filter(
-      "student = ", None ).get()
-
-    if not survey_record_group:
-      #create Survey Record Group if it doesn't already exist
-      survey_record_group = SurveyRecordGroup(
-      project=project,
-      initial_status = project.status
-      )
-
-    if survey.taking_access == 'mentor evaluation':
-      survey_record_group.mentor_record = survey_record
-    elif survey.taking_access == 'student evaluation':
-      survey_record_group.student_record = survey_record
-
-    return survey_record_group
-
   def getSurveyForContent(self, survey_content):
     """Returns the Survey belonging to the given SurveyContent.