Bug in keeping checked/unchecked in check.

This commit is contained in:
Jonathan Herrewijnen 2022-11-05 23:08:59 +01:00
parent 440a73f828
commit 7f17e72d61
7 changed files with 53 additions and 21 deletions

Binary file not shown.

Binary file not shown.

51
main.py
View File

@ -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)
params = initialize()
app.run(debug=True, port=5003)

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -5,17 +5,26 @@
<link rel="stylesheet" href="style.css">
<script>"jquery-3.6.0.min.js"</script>
</head>
<form method="POST">
<input name="text">
<input type="submit">
</form>
<body>
<h1>{{ title }}</h1>
{% for grade_file in grade_files %}
<h2>
{{ grade_file }}
<form method="post">
{% for key, value in grade_files[grade_file].items() %}
<!-- /*<input type="submit" name={{ index }} value={{ index }}>*/ -->
<input type="checkbox" name={{ key }} value={{ key }} {{ value }}>
<label for={{ key0 }}>{{ key }}</label>
{% endfor %}
<input type="submit">
</form>
</h2>
{% endfor %}
<section class="row">
{% for image in plots %}
<section class="col-md-4 col-sm-6" style="background-color: green;">
<a href="{{ url_for('static', filename='plots/' + image) }}">{{ image }}</a>
<section class="col-md-4 col-sm-6">
<img src="{{ url_for('static', filename='plots/' + image) }}" alt=img/>
<h3>{{ image }}</h3>
</section>
{% endfor %}
</section>