From 7ae5d8135da112295d69f2ca268c9f3976769143 Mon Sep 17 00:00:00 2001 From: Piotr Kopycki Date: Mon, 17 Jan 2022 17:38:53 +0100 Subject: [PATCH] Your tests page but html and css are the worst languages --- config/views.py | 7 +++---- static/style.css | 14 ++++++++++++++ templates/base.html | 2 +- templates/myTests.html | 30 ++++++++++++++++++++++++++++++ trials/urls.py | 6 ++++-- trials/views.py | 13 +++++++++++++ 6 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 templates/myTests.html diff --git a/config/views.py b/config/views.py index 9fdf12e..30925e4 100644 --- a/config/views.py +++ b/config/views.py @@ -7,11 +7,10 @@ from trials.models import Test @login_required def home(request): context = {} + # TODO replace + #context['tests'] = Test.objects.filter(owner=request.user) context['tests'] = Test.objects.all - # context = { - # 'latest_question_list': latest_question_list, - # } - return render(request, 'home.html', context) + return render(request, 'myTests.html', context) def welcome(request): diff --git a/static/style.css b/static/style.css index 4317c4c..6c44bfd 100644 --- a/static/style.css +++ b/static/style.css @@ -81,6 +81,20 @@ transform: translate(200%,0%); } + +.mainTestContainerDoubleButton button{ + height: 30px; + width: 150px; + color: #FFF; + font-size: 17px; + background: #00916E; + cursor: pointer; + border-radius: 25px; + border: none; + outline: none; + transform: translate(150%,0%); +} + .mainTestContainer a { color: inherit; text-decoration: inherit; diff --git a/templates/base.html b/templates/base.html index f509421..9638cdc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,7 @@
Home Create test - Your tests + Your tests

Categories

Język polski Język angielski diff --git a/templates/myTests.html b/templates/myTests.html new file mode 100644 index 0000000..92e9166 --- /dev/null +++ b/templates/myTests.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} + +{% block title %}My Tests{% endblock %} + +{% block content %} +

Check your tests

+ {% for test in tests %} +
+
+ {{test.name}} +
+
+ Category: {{test.category}} +
+
+ + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat scelerisque tortor, id sodales leo finibus id. Vivamus id viverra nunc, ac faucibus metus. Nulla a mauris imperdiet sapien lobortis dapibus. Quisque ornare posuere pulvinar. +
+
+ Passing score: {{test.passing_score}} / Questions: {{test.questions|length}} +
+
+ + +
+
+
+ {% endfor %} +{% endblock %} + diff --git a/trials/urls.py b/trials/urls.py index 44f50d6..074c09a 100644 --- a/trials/urls.py +++ b/trials/urls.py @@ -4,7 +4,7 @@ from rest_framework.routers import DefaultRouter from trials.views import TestModelViewSet from trials.views import TestTemplateView from trials.views import TestValidateAPIView -from trials.views import TestResultView, addTest, addQuestions +from trials.views import TestResultView, addTest, addQuestions, myTests, editTest router = DefaultRouter(trailing_slash=False) router.register("items", TestModelViewSet) @@ -13,8 +13,10 @@ urlpatterns = [ path('/show', TestTemplateView.as_view()), path('/mark', TestValidateAPIView.as_view()), path('/result', TestResultView.as_view()), + path('/edit', editTest), path('add/test', addTest, name="newTest"), - path('add/questions', addQuestions, name="addQuestions") + path('add/questions', addQuestions, name="addQuestions"), + path('mytests', myTests, name="myTests") ] urlpatterns += router.urls diff --git a/trials/views.py b/trials/views.py index 77edc95..f9250c3 100644 --- a/trials/views.py +++ b/trials/views.py @@ -58,6 +58,19 @@ def addQuestions(request): return render(request, 'addQuestions.html') +def myTests(request): + context = {} + # context['tests']=Test.objects.filter(category=request.user) + context['tests']=Test.objects.filter(category="Matematyka") + #context['tests'] = Test.objects.all + return render(request, 'myTests.html', context) + + +def editTest(request): + pass + # TODO + + class TestModelViewSet(viewsets.ModelViewSet): queryset = Test.objects.all() serializer_class = TestSerializer