Esempio n. 1
0
  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
Esempio n. 2
0
  def activateGrades(self, survey):
    """Activates the grades on a Grading Survey.

    TODO(James) Fix this Docstring

    params:
      survey = survey entity
    """
    if survey.taking_access != "mentor evaluation":
      logging.error("Cannot grade survey %s with taking access %s"
      % (survey.key().name(), survey.taking_access))
      return False

    program = survey.scope or Program.get_by_key_name(survey.scope_path)

    for project in program.student_projects.fetch(1000):
      this_record_group = SurveyRecordGroup.all().filter(
      "project = ", project).filter(
      "initial_status = ", project.status).get()

      if not this_record_group:
         logging.warning('neither mentor nor student has \
         taken the survey for project %s' % project.key().name() )
         continue

      if not this_record_group.mentor_record:
        # student has taken survey, but not mentor
        logging.warning('not continuing without mentor record...')
        continue

      status_options = PROJECT_STATUSES.get(project.status)

      if not status_options:
        logging.warning('unable to find status options for project \
        status %s' % project.status)
        continue

      new_project_grade = this_record_group.mentor_record.grade
      new_project_status = status_options.get(new_project_grade)

      if getattr(this_record_group, 'final_status'):
         logging.warning('project %s record group should not \
         yet have a final status %s' % (
         project.key().name(), this_record_group.final_status ) )
         continue

      # assign the new status to the project and surveyrecordgroup
      project.status = new_project_status
      this_record_group.final_status = new_project_status