feature/post-test-answers #23

Merged
s470631 merged 11 commits from feature/post-test-answers into master 2022-01-22 14:19:05 +01:00
6 changed files with 65 additions and 7 deletions
Showing only changes of commit 7ae5d8135d - Show all commits

View File

@ -7,11 +7,10 @@ from trials.models import Test
@login_required @login_required
def home(request): def home(request):
context = {} context = {}
# TODO replace
#context['tests'] = Test.objects.filter(owner=request.user)
context['tests'] = Test.objects.all context['tests'] = Test.objects.all
# context = { return render(request, 'myTests.html', context)
# 'latest_question_list': latest_question_list,
# }
return render(request, 'home.html', context)
def welcome(request): def welcome(request):

View File

@ -81,6 +81,20 @@
transform: translate(200%,0%); 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 { .mainTestContainer a {
color: inherit; color: inherit;
text-decoration: inherit; text-decoration: inherit;

View File

@ -14,7 +14,7 @@
<div class="sidenav"> <div class="sidenav">
<a href="/home">Home</a> <a href="/home">Home</a>
<a href="{% url 'newTest' %}">Create test</a> <a href="{% url 'newTest' %}">Create test</a>
<a href="/users/tests">Your tests</a> <a href="{% url 'myTests' %}">Your tests</a>
<p>Categories</p> <p>Categories</p>
<a href="/category/JezykPolski">Język polski</a> <a href="/category/JezykPolski">Język polski</a>
<a href="/category/JezykAngielski">Język angielski</a> <a href="/category/JezykAngielski">Język angielski</a>

30
templates/myTests.html Normal file
View File

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block title %}My Tests{% endblock %}
{% block content %}
<h1>Check your tests</h1>
{% for test in tests %}
<div class="mainTestContainer">
<div class="mainTestName">
{{test.name}}
</div>
<div class="mainTestMeta">
Category: {{test.category}}
</div>
<div class="mainTestDesc">
<!-- TODO 250 words limit-->
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.
</div>
<div class="mainTestMeta">
Passing score: {{test.passing_score}} / Questions: {{test.questions|length}}
</div>
<div class="mainTestContainerDoubleButton">
<button><a href="/tests/{{test.id}}/show">Start</a></button>
<button><a href="/tests/{{test.id}}/edit">Edit</a></button>
</div>
</div>
<br>
{% endfor %}
{% endblock %}

View File

@ -4,7 +4,7 @@ from rest_framework.routers import DefaultRouter
from trials.views import TestModelViewSet from trials.views import TestModelViewSet
from trials.views import TestTemplateView from trials.views import TestTemplateView
from trials.views import TestValidateAPIView 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 = DefaultRouter(trailing_slash=False)
router.register("items", TestModelViewSet) router.register("items", TestModelViewSet)
@ -13,8 +13,10 @@ urlpatterns = [
path('<int:test_id>/show', TestTemplateView.as_view()), path('<int:test_id>/show', TestTemplateView.as_view()),
path('<int:test_id>/mark', TestValidateAPIView.as_view()), path('<int:test_id>/mark', TestValidateAPIView.as_view()),
path('<int:test_id>/result', TestResultView.as_view()), path('<int:test_id>/result', TestResultView.as_view()),
path('<int:test_id>/edit', editTest),
path('add/test', addTest, name="newTest"), 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 urlpatterns += router.urls

View File

@ -58,6 +58,19 @@ def addQuestions(request):
return render(request, 'addQuestions.html') 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): class TestModelViewSet(viewsets.ModelViewSet):
queryset = Test.objects.all() queryset = Test.objects.all()
serializer_class = TestSerializer serializer_class = TestSerializer