예제 #1
0
def _build_user_graph(name):
    if name.endswith("lang"):
        name = name[: -len("lang")]
        dist = stats.get_language_data(name)
        return charts.PieChart(dist.items(), max_options=8)

    elif name == "dropout":
        data = stats.get_dropout_figures()
        approx_data = stats.approximate(data)
        chart = charts.MultiLineChart(approx_data, data_name="histogram", x_axis=(0.4, 1.0, 0.1), y_axis=(0, 1.0, 0.1))
        chart.add_data("raw", data)
        return chart

    elif name == "prepostdiff":
        data = [r["pre_post_diff"] for r in stats.get_global_rater_stats() if r["n_tests"] > 2 and r["pre_post_diff"]]
        hist_data = stats.histogram(data, n_bins=11, normalize=False, x_min=-0.7, x_max=0.7)
        chart = charts.LineChart(hist_data, data_name="histogram", x_axis=(-0.8, 0.8, 0.2))
        chart.add_data("raw", data)
        return chart

    elif name == "abilityjlpt3":
        data = stats.get_user_scores("jlpt 3")
        hist_data = stats.histogram(data, x_min=0.0, x_max=1.0, normalize=False)
        chart = charts.LineChart(hist_data, data_name="histogram", x_axis=(0.0, 1.0, 0.1))
        chart.add_data("raw", data)
        return chart

    elif name == "abilityjlpt4":
        data = stats.get_user_scores("jlpt 4")
        hist_data = stats.histogram(data, x_min=0.0, x_max=1.0, normalize=False)
        chart = charts.LineChart(hist_data, data_name="histogram", x_axis=(0.0, 1.0, 0.1))
        chart.add_data("raw", data)
        return chart

    raise KeyError(name)
예제 #2
0
def _build_user_graph(name):
    if name.endswith('lang'):
        name = name[:-len('lang')]
        dist = stats.get_language_data(name)
        return charts.PieChart(dist.items(), max_options=8)

    elif name == 'dropout':
        data = stats.get_dropout_figures()
        approx_data = stats.approximate(data)
        chart = charts.MultiLineChart(approx_data,
                                      data_name='histogram',
                                      x_axis=(0.4, 1.0, 0.1),
                                      y_axis=(0, 1.0, 0.1))
        chart.add_data('raw', data)
        return chart

    elif name == 'prepostdiff':
        data = [
            r['pre_post_diff'] for r in stats.get_global_rater_stats()
            if r['n_tests'] > 2 and r['pre_post_diff']
        ]
        hist_data = stats.histogram(data,
                                    n_bins=11,
                                    normalize=False,
                                    x_min=-0.7,
                                    x_max=0.7)
        chart = charts.LineChart(hist_data,
                                 data_name='histogram',
                                 x_axis=(-0.8, 0.8, 0.2))
        chart.add_data('raw', data)
        return chart

    elif name == 'abilityjlpt3':
        data = stats.get_user_scores('jlpt 3')
        hist_data = stats.histogram(data,
                                    x_min=0.0,
                                    x_max=1.0,
                                    normalize=False)
        chart = charts.LineChart(hist_data,
                                 data_name='histogram',
                                 x_axis=(0.0, 1.0, 0.1))
        chart.add_data('raw', data)
        return chart

    elif name == 'abilityjlpt4':
        data = stats.get_user_scores('jlpt 4')
        hist_data = stats.histogram(data,
                                    x_min=0.0,
                                    x_max=1.0,
                                    normalize=False)
        chart = charts.LineChart(hist_data,
                                 data_name='histogram',
                                 x_axis=(0.0, 1.0, 0.1))
        chart.add_data('raw', data)
        return chart

    raise KeyError(name)
예제 #3
0
def _build_test_graph(name):
    if name == 'mean':
        score_data = stats.get_mean_score_nth_test()
        data = stats.group_by_points(score_data, y_max=1.0, y_min=0.0)
        chart = charts.MultiLineChart(data,
                                      y_axis=(0, 1, 0.1),
                                      data_name='grouped')
        chart.add_data('raw', score_data)
        return chart

    elif name == 'volume':
        user_data = stats.get_users_by_n_tests()
        return charts.LineChart(user_data)

    elif name == 'length':
        return charts.PieChart(stats.get_test_length_volume())

    elif name == 'normtime':
        user_data = stats.get_score_over_norm_time()
        return charts.LineChart(user_data)

    elif name == 'time':
        base_data = stats.get_score_over_time()
        data = stats.approximate(base_data)
        chart = charts.MultiLineChart(data,
                                      y_axis=(0, 1.05, 0.1),
                                      data_name='approximate')
        chart.add_data('raw', base_data)
        two_colours = charts.color_desc(2).split(',')
        three_colours = ','.join(
            (two_colours[0], two_colours[1], two_colours[1]))
        chart['chco'] = three_colours
        return chart

    elif name == 'dropout':
        return charts.LineChart(stats.get_mean_score_by_n_tests())

    elif name == 'firstlast':
        data = stats.get_first_last_test()
        hist_data = stats.histogram(data,
                                    n_bins=11,
                                    normalize=False,
                                    x_min=-0.5,
                                    x_max=0.5)
        chart = charts.LineChart(hist_data,
                                 data_name='histogram',
                                 x_axis=(-0.5, 0.5, 0.1))
        chart.add_data('raw', data)
        return chart

    raise KeyError(name)
예제 #4
0
def _build_time_graph(name):
    if name == "betweentests":
        data = stats.get_time_between_tests()
        hist_data = stats.log_histogram(data, start=1.0 / (24 * 60))
        chart = charts.LineChart(hist_data, data_name="histogram")
        chart.add_data("raw", [(x,) for x in data])
        return chart

    elif name == "sessions":
        data = stats.get_mean_score_over_sessions()
        approx_data = stats.approximate(data, n_points=12)
        chart = charts.MultiLineChart(approx_data, y_axis=(0.0, 1, 0.1), x_axis=(0, 1, 0.1), data_name="approximate")
        chart.add_data("raw", data)
        two_colours = charts.color_desc(2).split(",")
        three_colours = ",".join((two_colours[0], two_colours[1], two_colours[1]))
        chart["chco"] = three_colours
        return chart

    raise KeyError(name)
예제 #5
0
def _build_test_graph(name):
    if name == "mean":
        score_data = stats.get_mean_score_nth_test()
        data = stats.group_by_points(score_data, y_max=1.0, y_min=0.0)
        chart = charts.MultiLineChart(data, y_axis=(0, 1, 0.1), data_name="grouped")
        chart.add_data("raw", score_data)
        return chart

    elif name == "volume":
        user_data = stats.get_users_by_n_tests()
        return charts.LineChart(user_data)

    elif name == "length":
        return charts.PieChart(stats.get_test_length_volume())

    elif name == "normtime":
        user_data = stats.get_score_over_norm_time()
        return charts.LineChart(user_data)

    elif name == "time":
        base_data = stats.get_score_over_time()
        data = stats.approximate(base_data)
        chart = charts.MultiLineChart(data, y_axis=(0, 1.05, 0.1), data_name="approximate")
        chart.add_data("raw", base_data)
        two_colours = charts.color_desc(2).split(",")
        three_colours = ",".join((two_colours[0], two_colours[1], two_colours[1]))
        chart["chco"] = three_colours
        return chart

    elif name == "dropout":
        return charts.LineChart(stats.get_mean_score_by_n_tests())

    elif name == "firstlast":
        data = stats.get_first_last_test()
        hist_data = stats.histogram(data, n_bins=11, normalize=False, x_min=-0.5, x_max=0.5)
        chart = charts.LineChart(hist_data, data_name="histogram", x_axis=(-0.5, 0.5, 0.1))
        chart.add_data("raw", data)
        return chart

    raise KeyError(name)
예제 #6
0
def _build_time_graph(name):
    if name == 'betweentests':
        data = stats.get_time_between_tests()
        hist_data = stats.log_histogram(data, start=1.0 / (24 * 60))
        chart = charts.LineChart(hist_data, data_name='histogram')
        chart.add_data('raw', [(x, ) for x in data])
        return chart

    elif name == 'sessions':
        data = stats.get_mean_score_over_sessions()
        approx_data = stats.approximate(data, n_points=12)
        chart = charts.MultiLineChart(approx_data,
                                      y_axis=(0.0, 1, 0.1),
                                      x_axis=(0, 1, 0.1),
                                      data_name='approximate')
        chart.add_data('raw', data)
        two_colours = charts.color_desc(2).split(',')
        three_colours = ','.join(
            (two_colours[0], two_colours[1], two_colours[1]))
        chart['chco'] = three_colours
        return chart

    raise KeyError(name)