Beispiel #1
0
def index():
    """Show user's grades for selected trimester"""
    if request.method == "POST":
        trimester = request.form.get("trimester")
        user = session["user_id"]
        index = db.execute(
            "SELECT * FROM grades WHERE id=:user AND trimester=:trimester ORDER BY subject ASC",
            user=user,
            trimester=trimester)
        for subject in index:
            test = subject["test"]
            cg1 = subject["cg1"]
            cg2 = subject["cg2"]
            cg3 = subject["cg3"]
            cg4 = subject["cg4"]
            cg5 = subject["cg5"]
            cgs = [cg1, cg2, cg3, cg4, cg5]
            if subject["subject"] in ["RE", "Sociology", "Philosophy"]:
                if test:
                    average = (test + cgavg(add(cgs), count(cgs))) / 2
                else:
                    average = cgavg(add(cgs), count(cgs)) / 2
            else:
                if test:
                    average = test * 0.4 + cgavg(add(cgs), count(cgs)) * 0.6
                else:
                    average = cgavg(add(cgs), count(cgs)) * 0.6
            rounded = approx(average)
            subject.update({"average": round(average, 5)})
            subject.update({"approx": rounded})
        return render_template("grades.html", trimester=trimester, index=index)
    else:
        return render_template("index.html")
Beispiel #2
0
def when_I_add_a_chart_with_categories_and_series(context, kind, cats, sers):
    chart_type = {
        'Area':                XL_CHART_TYPE.AREA,
        '100% Stacked Area':   XL_CHART_TYPE.AREA_STACKED_100,
        'Stacked Area':        XL_CHART_TYPE.AREA_STACKED,
        'Clustered Bar':       XL_CHART_TYPE.BAR_CLUSTERED,
        '100% Stacked Bar':    XL_CHART_TYPE.BAR_STACKED_100,
        'Stacked Bar':         XL_CHART_TYPE.BAR_STACKED,
        'Clustered Column':    XL_CHART_TYPE.COLUMN_CLUSTERED,
        '100% Stacked Column': XL_CHART_TYPE.COLUMN_STACKED_100,
        'Stacked Column':      XL_CHART_TYPE.COLUMN_STACKED,
        'Line':                XL_CHART_TYPE.LINE,
        'Pie':                 XL_CHART_TYPE.PIE,
    }[kind]
    category_count, series_count = int(cats), int(sers)
    category_source = ('Foo', 'Bar', 'Baz', 'Boo', 'Far', 'Faz')
    series_value_source = count(1.1, 1.1)

    chart_data = ChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = 'Series %d' % (idx+1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart = context.slide.shapes.add_chart(
        chart_type, Inches(1), Inches(1), Inches(8), Inches(5), chart_data
    ).chart
Beispiel #3
0
def when_I_replace_its_data_with_categories_and_series(context, cats, sers):
    category_count, series_count = int(cats), int(sers)
    category_source = ('Foo', 'Bar', 'Baz', 'Boo', 'Far', 'Faz')
    series_value_source = count(1.1, 1.1)

    chart_data = ChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = 'New Series %d' % (idx + 1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart.replace_data(chart_data)
Beispiel #4
0
def when_I_replace_its_data_with_categories_and_series(context, cats, sers):
    category_count, series_count = int(cats), int(sers)
    category_source = ("Foo", "Bar", "Baz", "Boo", "Far", "Faz")
    series_value_source = count(1.1, 1.1)

    chart_data = ChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = "New Series %d" % (idx + 1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart.replace_data(chart_data)
Beispiel #5
0
def calculator():
    """Calculate necessary score on an activity based on inputted values"""
    if request.method == "POST":
        subject = request.form.get("subject")
        test = request.form.get("test")
        cg1 = request.form.get("cg1")
        cg2 = request.form.get("cg2")
        cg3 = request.form.get("cg3")
        cg4 = request.form.get("cg4")
        cg5 = request.form.get("cg5")
        cgs = [cg1, cg2, cg3, cg4, cg5]
        average = float(request.form.get("average"))
        if subject == "1":
            if test:
                test = float(test)
                grade = ((count(cgs) + 1) * (average - 0.24 -
                                             (test * 0.4))) / 0.6 - add(cgs)
                evaluation = "test"
            else:
                grade = (average - 0.24 -
                         cgavg(add(cgs), count(cgs)) * 0.6) / 0.4
                evaluation = "class grade"
        else:
            if test:
                test = float(test)
                grade = (count(cgs) + 1) * (2 *
                                            (average - 0.24) - test) - add(cgs)
                evaluation = "test"
            else:
                grade = 2 * (average - 0.24) - cgavg(add(cgs), count(cgs))
                evaluation = "class grade"
        return render_template("calculated.html",
                               grade=round(grade, 3),
                               evaluation=evaluation)
    else:
        return render_template("calculator.html")
Beispiel #6
0
def when_I_add_a_chart_with_categories_and_series(context, kind, cats, sers):
    chart_type = {
        'Area': XL_CHART_TYPE.AREA,
        'Stacked Area': XL_CHART_TYPE.AREA_STACKED,
        '100% Stacked Area': XL_CHART_TYPE.AREA_STACKED_100,
        'Clustered Bar': XL_CHART_TYPE.BAR_CLUSTERED,
        'Stacked Bar': XL_CHART_TYPE.BAR_STACKED,
        '100% Stacked Bar': XL_CHART_TYPE.BAR_STACKED_100,
        'Clustered Column': XL_CHART_TYPE.COLUMN_CLUSTERED,
        'Stacked Column': XL_CHART_TYPE.COLUMN_STACKED,
        '100% Stacked Column': XL_CHART_TYPE.COLUMN_STACKED_100,
        'Doughnut': XL_CHART_TYPE.DOUGHNUT,
        'Exploded Doughnut': XL_CHART_TYPE.DOUGHNUT_EXPLODED,
        'Line': XL_CHART_TYPE.LINE,
        'Line with Markers': XL_CHART_TYPE.LINE_MARKERS,
        'Line Markers Stacked': XL_CHART_TYPE.LINE_MARKERS_STACKED,
        '100% Line Markers Stacked': XL_CHART_TYPE.LINE_MARKERS_STACKED_100,
        'Line Stacked': XL_CHART_TYPE.LINE_STACKED,
        '100% Line Stacked': XL_CHART_TYPE.LINE_STACKED_100,
        'Pie': XL_CHART_TYPE.PIE,
        'Exploded Pie': XL_CHART_TYPE.PIE_EXPLODED,
        'Radar': XL_CHART_TYPE.RADAR,
        'Filled Radar': XL_CHART_TYPE.RADAR_FILLED,
        'Radar with markers': XL_CHART_TYPE.RADAR_MARKERS,
    }[kind]
    category_count, series_count = int(cats), int(sers)
    category_source = ('Foo', 'Bar', 'Baz', 'Boo', 'Far', 'Faz')
    series_value_source = count(1.1, 1.1)

    chart_data = CategoryChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = 'Series %d' % (idx + 1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart = context.slide.shapes.add_chart(chart_type, Inches(1),
                                                   Inches(1), Inches(8),
                                                   Inches(5), chart_data).chart
def when_I_add_a_chart_with_categories_and_series(context, kind, cats, sers):
    chart_type = {
        "Area": XL_CHART_TYPE.AREA,
        "Stacked Area": XL_CHART_TYPE.AREA_STACKED,
        "100% Stacked Area": XL_CHART_TYPE.AREA_STACKED_100,
        "Clustered Bar": XL_CHART_TYPE.BAR_CLUSTERED,
        "Stacked Bar": XL_CHART_TYPE.BAR_STACKED,
        "100% Stacked Bar": XL_CHART_TYPE.BAR_STACKED_100,
        "Clustered Column": XL_CHART_TYPE.COLUMN_CLUSTERED,
        "Stacked Column": XL_CHART_TYPE.COLUMN_STACKED,
        "100% Stacked Column": XL_CHART_TYPE.COLUMN_STACKED_100,
        "Doughnut": XL_CHART_TYPE.DOUGHNUT,
        "Exploded Doughnut": XL_CHART_TYPE.DOUGHNUT_EXPLODED,
        "Line": XL_CHART_TYPE.LINE,
        "Line with Markers": XL_CHART_TYPE.LINE_MARKERS,
        "Line Markers Stacked": XL_CHART_TYPE.LINE_MARKERS_STACKED,
        "100% Line Markers Stacked": XL_CHART_TYPE.LINE_MARKERS_STACKED_100,
        "Line Stacked": XL_CHART_TYPE.LINE_STACKED,
        "100% Line Stacked": XL_CHART_TYPE.LINE_STACKED_100,
        "Pie": XL_CHART_TYPE.PIE,
        "Exploded Pie": XL_CHART_TYPE.PIE_EXPLODED,
        "Radar": XL_CHART_TYPE.RADAR,
        "Filled Radar": XL_CHART_TYPE.RADAR_FILLED,
        "Radar with markers": XL_CHART_TYPE.RADAR_MARKERS,
    }[kind]
    category_count, series_count = int(cats), int(sers)
    category_source = ("Foo", "Bar", "Baz", "Boo", "Far", "Faz")
    series_value_source = count(1.1, 1.1)

    chart_data = CategoryChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = "Series %d" % (idx + 1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart = context.slide.shapes.add_chart(
        chart_type, Inches(1), Inches(1), Inches(8), Inches(5), chart_data
    ).chart
Beispiel #8
0
def when_I_add_a_chart_with_categories_and_series(context, kind, cats, sers):
    chart_type = {
        'Clustered Bar': XL_CHART_TYPE.BAR_CLUSTERED,
        '100% Stacked Bar': XL_CHART_TYPE.BAR_STACKED_100,
        'Clustered Column': XL_CHART_TYPE.COLUMN_CLUSTERED,
        'Line': XL_CHART_TYPE.LINE,
        'Pie': XL_CHART_TYPE.PIE,
    }[kind]
    category_count, series_count = int(cats), int(sers)
    category_source = ('Foo', 'Bar', 'Baz', 'Boo', 'Far', 'Faz')
    series_value_source = count(1.1, 1.1)

    chart_data = ChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = 'Series %d' % (idx + 1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart = context.slide.shapes.add_chart(chart_type, Inches(1),
                                                   Inches(1), Inches(8),
                                                   Inches(5), chart_data).chart
def when_I_add_a_chart_with_categories_and_series(context, kind, cats, sers):
    chart_type = {
        'Area':                      XL_CHART_TYPE.AREA,
        'Stacked Area':              XL_CHART_TYPE.AREA_STACKED,
        '100% Stacked Area':         XL_CHART_TYPE.AREA_STACKED_100,
        'Clustered Bar':             XL_CHART_TYPE.BAR_CLUSTERED,
        'Stacked Bar':               XL_CHART_TYPE.BAR_STACKED,
        '100% Stacked Bar':          XL_CHART_TYPE.BAR_STACKED_100,
        'Clustered Column':          XL_CHART_TYPE.COLUMN_CLUSTERED,
        'Stacked Column':            XL_CHART_TYPE.COLUMN_STACKED,
        '100% Stacked Column':       XL_CHART_TYPE.COLUMN_STACKED_100,
        'Doughnut':                  XL_CHART_TYPE.DOUGHNUT,
        'Exploded Doughnut':         XL_CHART_TYPE.DOUGHNUT_EXPLODED,
        'Line':                      XL_CHART_TYPE.LINE,
        'Line with Markers':         XL_CHART_TYPE.LINE_MARKERS,
        'Line Markers Stacked':      XL_CHART_TYPE.LINE_MARKERS_STACKED,
        '100% Line Markers Stacked': XL_CHART_TYPE.LINE_MARKERS_STACKED_100,
        'Line Stacked':              XL_CHART_TYPE.LINE_STACKED,
        '100% Line Stacked':         XL_CHART_TYPE.LINE_STACKED_100,
        'Pie':                       XL_CHART_TYPE.PIE,
        'Exploded Pie':              XL_CHART_TYPE.PIE_EXPLODED,
        'Radar':                     XL_CHART_TYPE.RADAR,
        'Filled Radar':              XL_CHART_TYPE.RADAR_FILLED,
        'Radar with markers':        XL_CHART_TYPE.RADAR_MARKERS,
    }[kind]
    category_count, series_count = int(cats), int(sers)
    category_source = ('Foo', 'Bar', 'Baz', 'Boo', 'Far', 'Faz')
    series_value_source = count(1.1, 1.1)

    chart_data = CategoryChartData()
    chart_data.categories = category_source[:category_count]
    for idx in range(series_count):
        series_title = 'Series %d' % (idx+1)
        series_values = tuple(islice(series_value_source, category_count))
        chart_data.add_series(series_title, series_values)

    context.chart = context.slide.shapes.add_chart(
        chart_type, Inches(1), Inches(1), Inches(8), Inches(5), chart_data
    ).chart
Beispiel #10
0
with open('misc/pages5.json', 'r') as f:
    pages=json.loads(f.read())
    
with open('misc/pages5.json', 'r') as f:
    pages=json.loads(f.read())
    
with open('misc/pages5.json', 'r') as f:
    pages=json.loads(f.read())
    
with open('misc/pages5.json', 'r') as f:
    pages=json.loads(f.read())
    
len(pages)
get_ipython().magic('ls ')
import helpers
helpers.count('abc13 a')
counts = [helpers.count(page) for page in pages]
len(counts)
import matplotlib.pyplot as plt
plt.plot(counts)
plt.ylabel('Zahlenanteil (%)')
plt.xlabel('Seitenzahl')
plt.suptitle('Anteil Ziffern pro Seite')
plt.show()
plot = plt.plot(counts)
plt.plot(counts)
plt.ylabel('Zahlenanteil (%)')
plt.xlabel('Seitenzahl')
plt.suptitle('Anteil Ziffern pro Seite')
plt.savefig('fig_300.png', dpi=300)
import matplotlib as mpl
Beispiel #11
0
    if val == 0.6666666666666666:
        digits[key] = 0.6
        
digits
pages3 = []
for page in pages:
    for word, digit in digits.items():
        page = page.replace(word, str(digit))
    pages3.append(page)
    
    
len(pages3)
get_ipython().magic('ls ')
import helpers
helpers.count
helpers.count()
counts = {}
counts = []
counts = [helpers.count(page) for page in pages3]
len(counts)
import matplotlib.pyplot as plt
plt.plot(counts)
plt.ylabel('Zahlenanteil (%)')
plt.xlabel('Seitenzahl')
plt.suptitle('Anteil Ziffern pro Seite')
plt.show()
for count in range(len(counts)):
    if count > 8:
        print('Page ' + str(count))
        print('\n')
        print(pages3[count])