Exemplo n.º 1
0
def get_session_stats():
    finished = PracticeSession.objects.filter(duration__gt=0)
    unfinished = PracticeSession.objects.filter(duration=0) # or expired
    return SessionStats(
            length_median = median([s.duration for s in finished]),
            solved_ratio = len(finished) / len(unfinished),
            unfinished = len(unfinished))
Exemplo n.º 2
0
def get_session_stats():
    finished = PracticeSession.objects.filter(duration__gt=0)
    unfinished = PracticeSession.objects.filter(duration=0)  # or expired
    return SessionStats(
        length_median=median([s.duration for s in finished]),
        solved_ratio=len(finished) / len(unfinished),
        unfinished=len(unfinished),
    )
Exemplo n.º 3
0
def get_attempts_median(task):
    attempts = TaskInstanceModel.objects \
            .filter(task=task) \
            .values_list('attempt_count', flat=True)
    return median(attempts)
Exemplo n.º 4
0
def get_time_median(task):
    times = TaskInstanceModel.objects.filter(task=task) \
            .values_list('time_spent', flat=True)
    return median(times)
Exemplo n.º 5
0
def get_attempts_median(task):
    attempts = TaskInstanceModel.objects.filter(task=task).values_list("attempt_count", flat=True)
    return median(attempts)
Exemplo n.º 6
0
def get_time_median(task):
    times = TaskInstanceModel.objects.filter(task=task).values_list("time_spent", flat=True)
    return median(times)