diff --git a/recopytex/dashboard/app.py b/recopytex/dashboard/app.py new file mode 100644 index 0000000..7c2254c --- /dev/null +++ b/recopytex/dashboard/app.py @@ -0,0 +1,5 @@ +import dash + +app = dash.Dash(__name__, suppress_callback_exceptions=True) +# app = dash.Dash(__name__) +server = app.server diff --git a/recopytex/dashboard/exam_analysis/__init__.py b/recopytex/dashboard/exam_analysis/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/recopytex/dashboard/exam.py b/recopytex/dashboard/exam_analysis/app.py similarity index 97% rename from recopytex/dashboard/exam.py rename to recopytex/dashboard/exam_analysis/app.py index 6268bc9..8fca1e2 100644 --- a/recopytex/dashboard/exam.py +++ b/recopytex/dashboard/exam_analysis/app.py @@ -14,9 +14,10 @@ import numpy as np import dash_bootstrap_components as dbc -from .. import flat_df_students, pp_q_scores -from ..config import NO_ST_COLUMNS -from ..scripts.getconfig import config, CONFIGPATH +from ... import flat_df_students, pp_q_scores +from ...config import NO_ST_COLUMNS +from ...scripts.getconfig import config, CONFIGPATH +from ..app import app COLORS = { ".": "black", @@ -26,11 +27,7 @@ COLORS = { 3: "#68D42F", } -# external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"] -# app = dash.Dash(__name__, external_stylesheets=external_stylesheets) -app = dash.Dash(__name__) - -app.layout = html.Div( +layout = html.Div( children=[ html.Header( children=[ diff --git a/recopytex/dashboard/index.py b/recopytex/dashboard/index.py new file mode 100644 index 0000000..c299937 --- /dev/null +++ b/recopytex/dashboard/index.py @@ -0,0 +1,23 @@ +import dash_core_components as dcc +import dash_html_components as html +from dash.dependencies import Input, Output + +from .app import app +from .exam_analysis import app as exam_analysis + + +app.layout = html.Div( + [dcc.Location(id="url", refresh=False), html.Div(id="page-content")] +) + + +@app.callback(Output("page-content", "children"), Input("url", "pathname")) +def display_page(pathname): + if pathname == "/": + return exam_analysis.layout + else: + return "404" + + +if __name__ == "__main__": + app.run_server(debug=True) diff --git a/recopytex/df_marks_manip.py b/recopytex/df_marks_manip.py index 96c7593..ed194fa 100644 --- a/recopytex/df_marks_manip.py +++ b/recopytex/df_marks_manip.py @@ -4,7 +4,7 @@ import pandas as pd import numpy as np from math import ceil, floor -from .config import COLUMNS, VALIDSCORE +from .config import COLUMNS """ Functions for manipulate score dataframes diff --git a/recopytex/scripts/recopytex.py b/recopytex/scripts/recopytex.py index 165f7dc..504c59a 100644 --- a/recopytex/scripts/recopytex.py +++ b/recopytex/scripts/recopytex.py @@ -13,7 +13,7 @@ from .getconfig import config, CONFIGPATH from .prompts import prompt_exam, prompt_exercise, prompt_validate from ..config import NO_ST_COLUMNS from .exam import Exam -from ..dashboard.exam import app as exam_app +from ..dashboard.index import app as dash @click.group() @@ -89,7 +89,7 @@ def new_exam(): @cli.command() @click.option("--debug", default=0, help="Debug mode for dash") def exam_analysis(debug): - exam_app.run_server(debug=bool(debug)) + dash.run_server(debug=bool(debug)) @cli.command()