Merge branch 'feature/post-test-answers' of https://git.wmi.amu.edu.pl/s470629/SOITA into feature/post-test-answers

This commit is contained in:
Hubert Jankowski 2022-01-17 18:50:20 +01:00
commit e96e0476b9
6 changed files with 65 additions and 7 deletions

View File

@ -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):

View File

@ -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;

View File

@ -14,7 +14,7 @@
<div class="sidenav">
<a href="/home">Home</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>
<a href="/category/JezykPolski">Język polski</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 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('<int:test_id>/show', TestTemplateView.as_view()),
path('<int:test_id>/mark', TestValidateAPIView.as_view()),
path('<int:test_id>/result', TestResultView.as_view()),
path('<int:test_id>/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

View File

@ -43,6 +43,19 @@ def addQuestions(request, data_about_test):
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