예제 #1
0
def recalculateGCIRanking(request, entities, context, *args, **kwargs):
    """Recalculates student ranking for a program with the specified key_name.
  """

    program = gci_program_logic.getFromKeyName(kwargs['key_name'])
    if not program:
        return responses.terminateTask()

    # prefetch all task difficulties
    all_d = gci_task_model.TaskDifficultyTag.all().fetch(100)

    for entity in entities:
        # check if the entity refers to the program in scope
        if entity.scope.key() != program.key():
            continue

        # get all the tasks that the student has completed
        filter = {
            'student': entity,
            'status': 'Closed',
        }
        tasks = gci_task_logic.getForFields(filter=filter)

        # calculate ranking with all the tasks
        gci_student_ranking_logic.calculateRankingForStudent(
            entity, tasks, all_d)

        # this task should not be repeated after the program is over
        timeline = program.timeline
        if timeline_helper.isAfterEvent(timeline, 'program_end'):
            raise responses.DoNotRepeatException()
예제 #2
0
def recalculateGCIRanking(request, entities, context, *args, **kwargs):
  """Recalculates student ranking for a program with the specified key_name.
  """

  program = gci_program_logic.getFromKeyName(kwargs['key_name'])
  if not program:
    return responses.terminateTask()

  # prefetch all task difficulties
  all_d = gci_task_model.TaskDifficultyTag.all().fetch(100)

  for entity in entities:
    # check if the entity refers to the program in scope
    if entity.scope.key() != program.key():
      continue

    # get all the tasks that the student has completed
    filter = {
        'student': entity,
        'status': 'Closed',
        }
    tasks = gci_task_logic.getForFields(filter=filter)

    # calculate ranking with all the tasks
    gci_student_ranking_logic.calculateRankingForStudent(entity, tasks, all_d)

    # this task should not be repeated after the program is over
    timeline = program.timeline
    if timeline_helper.isAfterEvent(timeline, 'program_end'):
      raise responses.DoNotRepeatException()
예제 #3
0
def recalculateGCIStudentRanking(request, *args, **kwargs):
    """Recalculates GCI Student Ranking for the specified student.
  """

    student = gci_student_logic.getFromKeyName(kwargs['key_name'])
    if not student:
        return responses.terminateTask()

    # find ranking entity for the student and clear it
    filter = {'student': student}
    ranking = gci_student_ranking_logic.getForFields(filter=filter,
                                                     unique=True)
    ranking.points = 0
    ranking.tasks = []
    ranking.put()

    # get all the tasks that the student has completed
    filter = {
        'student': student,
        'status': 'Closed',
    }
    tasks = gci_task_logic.getForFields(filter=filter)

    for task in tasks:
        gci_student_ranking_logic.updateRanking(task)

    return responses.terminateTask()
예제 #4
0
def recalculateGCIStudentRanking(request, *args, **kwargs):
  """Recalculates GCI Student Ranking for the specified student.
  """

  student = gci_student_logic.getFromKeyName(kwargs['key_name'])
  if not student:
    return responses.terminateTask()

  # find ranking entity for the student and clear it
  filter = {
      'student': student
      }
  ranking = gci_student_ranking_logic.getForFields(filter=filter,
      unique=True)
  ranking.points = 0
  ranking.tasks = []
  ranking.put()

  # get all the tasks that the student has completed
  filter = {
      'student': student,
      'status': 'Closed',
      }
  tasks = gci_task_logic.getForFields(filter=filter)

  for task in tasks:
    gci_student_ranking_logic.updateRanking(task)

  return responses.terminateTask()