From 3025e83b66d46cec2ad542c83e3dfed0b6a1bbc9 Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Mon, 20 Jun 2022 12:22:29 +0100 Subject: [PATCH] Editor styling --- ref-test/app/__init__.py | 4 +- ref-test/app/editor/static/css/editor.css | 46 +++ ref-test/app/editor/static/js/editor.js | 68 +++++ .../app/editor/templates/editor/index.html | 266 +++++++++--------- 4 files changed, 246 insertions(+), 138 deletions(-) create mode 100644 ref-test/app/editor/static/css/editor.css diff --git a/ref-test/app/__init__.py b/ref-test/app/__init__.py index 60c082d..a2cb575 100644 --- a/ref-test/app/__init__.py +++ b/ref-test/app/__init__.py @@ -31,7 +31,7 @@ def create_app(): def _check_cookie_consent(): if request.cookies.get('cookie_consent'): return - if any([ request.path.startswith(x) for x in [ '/admin/static/', '/root/', '/quiz/static', '/cookies/' ] ]): + if any([ request.path.startswith(x) for x in [ '/admin/static/', '/root/', '/quiz/static', '/cookies/', '/admin/editor/static' ] ]): return flash(f'Cookie Consent: This web site only stores minimal, functional cookies. It does not store any tracking information. By using this site, you consent to this use of cookies. For more information, see our privacy policy.', 'cookie_alert') @@ -46,11 +46,13 @@ def create_app(): from .api.views import api from .quiz.views import quiz from .views import views + from .editor.views import editor app.register_blueprint(admin, url_prefix='/admin') app.register_blueprint(api, url_prefix='/api') app.register_blueprint(views) app.register_blueprint(quiz) + app.register_blueprint(editor, url_prefix='/admin/editor') install_app(app) diff --git a/ref-test/app/editor/static/css/editor.css b/ref-test/app/editor/static/css/editor.css new file mode 100644 index 0000000..eee5d22 --- /dev/null +++ b/ref-test/app/editor/static/css/editor.css @@ -0,0 +1,46 @@ +.accordion-button { + color: inherit; + background-color: inherit; + display: block; + border: 1px solid rgb(0 0 0 / .3); + height: 60px; +} + +.editor-controls { + width: fit-content; + display: block; + margin: 10px auto; +} + +.editor-controls a { + margin: 0 10px; + z-index: 10; +} + +.accordion-button div { + margin: 0; + position: absolute; + top: 50%; + transform: translate(0, -50%); +} + +.accordion-button a { + transform: translate(-50%, -50%); + top: 50%; + right: 0%; + position: absolute; +} + +.accordion-button::after { + content: none; +} + +.accordion-error { + background-color: #bb2d3b; + color: white; +} + +.accordion-error:not(.collapsed) { + background-color: #bb2d3b; + color: white; +} \ No newline at end of file diff --git a/ref-test/app/editor/static/js/editor.js b/ref-test/app/editor/static/js/editor.js index e69de29..ef21641 100644 --- a/ref-test/app/editor/static/js/editor.js +++ b/ref-test/app/editor/static/js/editor.js @@ -0,0 +1,68 @@ +const root = $('#editor-root') + +var data = [ + { + "type": "question", + "q_no": 3, + "text": "The ball is gathered by the defensive division and a player throws it forward, hitting the korf in the other division.", + "options": [ + "Play on", + "Opposite team restart under their defensive post", + "Opposite team restart where the ball was thrown from" + ], + "correct": 0, + "q_type": "Multiple Choice", + "tags": [ + "scoring from the defence zone" + ] + }, + { + "type": "question", + "q_no": 4, + "text": "At the end of the game, after the final whistle, a coach loudly confronts the referee. What can the referee do?", + "options": [ + "Ignore the coach as the match has ended", + "Ignore the coach or inform the coach they will be reported", + "Ignore the coach, inform the coach they will be reported and/or show the coach a card" + ], + "correct": 2, + "q_type": "List", + "tags": [ + "discipline" + ] + }, +] + +for (var i = 0; i < data.length; i++) { + if (data[i]['type'] == 'question') { + var obj = ` +
+

+ +

+
+
+
+ ${data[i]['text']} +
+
    +
  • + ${data[i]['options'].join("
  • ")} +
  • +
+
+
+
+ ` + root.append(obj) + } +} + +$('.panel-control').click(function(event) { + console.log($(this).data('id')) + var id = $(this).data('id') + $(`#i${id}`).remove() +}) \ No newline at end of file diff --git a/ref-test/app/editor/templates/editor/index.html b/ref-test/app/editor/templates/editor/index.html index cf55228..8fed972 100644 --- a/ref-test/app/editor/templates/editor/index.html +++ b/ref-test/app/editor/templates/editor/index.html @@ -1,148 +1,140 @@ {% extends "editor/components/base.html" %} +{% block style %} + +{% endblock %} + {% block content %} -

Dashboard

-
-
-
-
-
-
Current Exams
- {% if current_tests %} -
- - - - - - - - - {% for test in current_tests %} - - - - - {% endfor %} - -
- Exam Code - - Expiry Date -
- {{ test.get_code() }} - - {{ test.end_date.strftime('%d %b %Y') }} -
-
- View Exams - {% else %} -
- There are currently no active exams. -
- Create Exam - {% endif %} +

Editor

+
+
+
+

+ -

+ +
+
+
+
+ Question 1 + +
+
+ Question Type + +
+ +
    +
    + 0 + +
    +
    + 1 + +
    +
+
+ Cancel + Done +
+
+ Correct + +
+
+ Tags + +
+
+
+
-
-
-
-
Recent Results
- {% if recent_results %} -
- - - - - - - - - - {% for result in recent_results %} - - - - - - {% endfor %} - -
- Name - - Date Submitted - - Result -
- {{ result.get_surname() }}, {{ result.get_first_name() }} - - {{ result.end_time.strftime('%d %b %Y %H:%M') }} - - {{ (100*result.result['score']/result.result['max'])|round|int }}% ({{ result.result.grade }}) -
-
- View Results - {% else %} -
- There are currently no exam results to preview. -
- {% endif %} +
+

+ -

+ +
+
+
+
+

+ +

+
+
+
+
+ Question 1 + +
+
+ Question Type + +
+ +
    +
    + 0 + +
    +
    + 1 + +
    +
+
+ Cancel + Done +
+
+ Correct + +
+
+ Tags + +
+
+
+
+
+
+
+
-
-
-
-
-
Upcoming Exams
- {% if upcoming_tests %} -
- - - - - - - - - {% for test in upcoming_tests %} - - - - - {% endfor %} - -
- Exam Code - - Expiry Date -
- {{ test.get_code() }} - - {{ test.end_date.strftime('%d %b %Y') }} -
-
- View Exams - {% else %} -
- There are currently no upcoming exams. -
- Create Exam - {% endif %} -
-
-
-
-
-
-
Help
-

This web app was developed by Vivek Santayana. If there are any issues with the app, any bugs you need to report, or any features you would like to request, please feel free to open an issue at the Git Repository.

- Open an Issue -
-
-
+ {% include "editor/components/client-alerts.html" %} +
+ Cancel + Done
+{% endblock %} + +{% block script %} + {% endblock %} \ No newline at end of file