diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc index 53d5fea..ff7b686 100644 Binary files a/__pycache__/main.cpython-39.pyc and b/__pycache__/main.cpython-39.pyc differ diff --git a/__pycache__/plots.cpython-39.pyc b/__pycache__/plots.cpython-39.pyc index 87e8156..a5218a0 100644 Binary files a/__pycache__/plots.cpython-39.pyc and b/__pycache__/plots.cpython-39.pyc differ diff --git a/main.py b/main.py index c9fed10..f28cd35 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import os from flask import Flask, make_response, request, render_template from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas import plots +import pandas as pd config = { "DEBUG": True # run app in debug mode @@ -10,27 +11,49 @@ config = { app = Flask(__name__) +params = [] + + +def grade_files(): + grade_files = {} + for file in os.listdir('./'): + if file.endswith(".csv"): + grade_files[file] = {} + grade_file = pd.read_csv(file, skiprows=2, sep=';') + for i in grade_file: + grade_files[file][i] = 'checked' + break # Could add exam fle at some point here as well + return grade_files + + def figure(): plots.plot() -@app.route('/', methods=["GET"]) -def root(): + +def value_to_list(given_list, old_value, new_value): + given_list = list(map(lambda x: x[1].replace(old_value, new_value), [j for j in given_list])) + return given_list + + +def initialize(): title = "Project Numeri" - figure() plots = os.listdir(os.path.join(app.static_folder, "plots")) - return render_template('index.html', title=title, plots=plots) + return title, plots, grade_files() -# @app.route('/', methods=['POST']) -# def my_form_post(): -# text = request.form['text'] -# processed_text = text.upper() -# return processed_text - -# def grades(): -# grades_list = pd.read_csv("*.csv") -# print(grades_list) +# Renders template. All below is constantly executed by Flask +@app.route('/', methods=['GET', 'POST']) +def root(): + title, plots, grade_files = params + if request.method == 'POST': + form = request.form + for filename in grade_files: + grade_files_unchecked = grade_files[filename].keys() - form.keys() + for column_name in grade_files_unchecked: + grade_files[filename][column_name] = "unchecked" + return render_template('index.html', title=title, plots=plots, grade_files=grade_files) if __name__ == '__main__': - app.run(debug=True, port=5002) \ No newline at end of file + params = initialize() + app.run(debug=True, port=5003) \ No newline at end of file diff --git a/static/plots/9e7c2c5f-1011-43fc-827d-3e0c4120a1b2.png b/static/plots/9e7c2c5f-1011-43fc-827d-3e0c4120a1b2.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/9e7c2c5f-1011-43fc-827d-3e0c4120a1b2.png differ diff --git a/static/plots/e159fb01-466c-4582-afe5-a9b7c963c1b9.png b/static/plots/e159fb01-466c-4582-afe5-a9b7c963c1b9.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/e159fb01-466c-4582-afe5-a9b7c963c1b9.png differ diff --git a/static/plots/f60d0f3e-9e8b-4672-b43c-07e3be7da97d.png b/static/plots/f60d0f3e-9e8b-4672-b43c-07e3be7da97d.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/f60d0f3e-9e8b-4672-b43c-07e3be7da97d.png differ diff --git a/templates/index.html b/templates/index.html index 6679b7a..37f0bcc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,17 +5,26 @@ -
- - -
-

{{ title }}

+ {% for grade_file in grade_files %} +

+ {{ grade_file }} +
+ {% for key, value in grade_files[grade_file].items() %} + + + + {% endfor %} + +
+

+ {% endfor %}
{% for image in plots %} -
- {{ image }} +
+ img/ +

{{ image }}

{% endfor %}