-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from ooemperor/dev
Adding Gamification, hoverable tables, custom error pages and score view with more fixes
- Loading branch information
Showing
24 changed files
with
638 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# CodeGrader - https://github.com/ooemperor/CodeGrader | ||
# Copyright © 2023, 2024 Michael Kaiser <michael.kaiser@emplabs.ch> | ||
# | ||
# This file is part of CodeGrader. | ||
# | ||
# CodeGrader is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# CodeGrader is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with CodeGrader. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
""" | ||
Handler Classes for the Error Sites of the CodeGrader | ||
""" | ||
import flask | ||
import flask_login | ||
from flask import request, render_template, redirect | ||
from .Base import BaseHandler | ||
import datetime | ||
from codeGrader.frontend.config import config | ||
|
||
|
||
class ErrorHandler(BaseHandler): | ||
""" | ||
Handles Rendering of the Error Site | ||
""" | ||
|
||
def __init__(self, request: flask.Request): | ||
""" | ||
Constructor of the Error Handler | ||
@param request: The request from the app route of flask | ||
@type request: flask.request | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self, error: Exception, error_code: int) -> (str, int): | ||
""" | ||
Renders the template of the Error Site of the user frontend | ||
@param error: The Exception of the site | ||
@type error: Exception | ||
@param error_code: The Error Code of the site | ||
@type error_code: int | ||
@return: str | ||
""" | ||
request_data = dict() | ||
request_data["path"] = self.request.path | ||
request_data["method"] = self.request.method | ||
request_data["time"] = datetime.datetime.now() | ||
request_data["error"] = error | ||
|
||
if error_code == 404: | ||
request_data["title"] = "Page not found" | ||
request_data["error_text"] = "It looks like the page you are looking for does not exist" | ||
request_data["gif"] = config.gif_404 | ||
return render_template("error.html", **request_data), error_code | ||
|
||
elif error_code == 500: | ||
request_data["title"] = f"{config.userAppName} not found" | ||
request_data["error_text"] = "An Error occured on the server while processing your request. Please Try Again!" | ||
request_data["gif"] = config.gif_500 | ||
return render_template("error.html", **request_data), error_code | ||
|
||
else: | ||
request_data["title"] = f"{config.userAppName} Error" | ||
request_data["error_text"] = "Something went wrong. Please Try Again!" | ||
request_data["gif"] = config.gif_500 | ||
return render_template("error.html", **request_data), error_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!-- | ||
CodeGrader - https://github.com/ooemperor/CodeGrader | ||
Copyright © 2023, 2024 Michael Kaiser <michael.kaiser@emplabs.ch> | ||
This file is part of CodeGrader. | ||
CodeGrader is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
CodeGrader is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with CodeGrader. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<!DOCTYPE html> | ||
<html lang="en" data-bs-theme="dark"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}"> | ||
<script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script> | ||
<title>{{ appname}} Error</title> | ||
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='img/favicon.ico')}}"> | ||
</head> | ||
|
||
<body class="min-vw-100"> | ||
<div class="container-fluid min-vw-100" id="error"> | ||
<div class="row"> | ||
<div class="row justify-content-center p-2"> | ||
<h1 class="row justify-content-center"> | ||
{{ title }} | ||
</h1> | ||
</div> | ||
<div class="row justify-content-center p-2"> | ||
{{ error_text }} | ||
<br> | ||
If you think this should not happen, please contact your administrator and provide the Information below. | ||
</div> | ||
<div class="row justify-content-center p-2"> | ||
{{ gif|safe }} | ||
</div> | ||
<div class="row justify-content-center"> | ||
Path: {{path}} | ||
<br> | ||
Method: {{method}} | ||
<br> | ||
Time: {{time}} | ||
<br> | ||
Exception: {{error}} | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.