Solved tests history upgrade
This commit is contained in:
parent
a0e0ff7e03
commit
696a573b08
@ -1,8 +1,11 @@
|
|||||||
Color palette:
|
Color palette:
|
||||||
#00916E - Illuminating Emerald
|
|
||||||
#FEEFE5 - Linen
|
#FEEFE5 - Linen
|
||||||
#FFCF00 - Cyber Yellow
|
#FFCF00 - Cyber Yellow
|
||||||
#EE6123 - Orange Panteon
|
#EE6123 - Orange Panteon
|
||||||
#FA003F - Red Munsell
|
#FA003F - Red Munsell
|
||||||
|
|
||||||
|
Buttons and links
|
||||||
|
#00916E - Illuminating Emerald
|
||||||
|
|
||||||
|
Main color:
|
||||||
#FF0B7E - Winter Sky
|
#FF0B7E - Winter Sky
|
@ -97,7 +97,15 @@
|
|||||||
border-radius: 25px;
|
border-radius: 25px;
|
||||||
border: 2px solid #FF0B7E;
|
border: 2px solid #FF0B7E;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: 300px;
|
width: 320px;
|
||||||
|
height: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.solvedTestContainerMini {
|
||||||
|
border-radius: 25px;
|
||||||
|
border: 2px solid #FF0B7E;
|
||||||
|
padding: 20px;
|
||||||
|
width: 320px;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,6 +461,7 @@ background-color:#FF0B7E
|
|||||||
.linkDefault a {
|
.linkDefault a {
|
||||||
color: #00916E;
|
color: #00916E;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.newContainer input[type=submit]{
|
.newContainer input[type=submit]{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<input type="submit" value="Zaktualizuj email"><br><br>
|
<input type="submit" value="Zaktualizuj email"><br><br>
|
||||||
</form>
|
</form>
|
||||||
<div class="linkDefault">
|
<div class="linkDefault">
|
||||||
<a href="{% url 'account' %}">Wróc</a>
|
<a href="{% url 'account' %}">Wróć</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -4,15 +4,20 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Historia rozwiązanych testów</h1>
|
<h1>Historia rozwiązanych testów</h1>
|
||||||
{% for test in tests %}
|
{% for test, results in tests_lists.items %}
|
||||||
<div class="solvedTestContainer">
|
<div class="solvedTestContainer">
|
||||||
<div class="mainTestName">
|
<div class="mainTestName">
|
||||||
{{test.name}}
|
{{results.0.name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="solvedTestText">Twój wynik: {{test.score}}</div>
|
<div class="solvedTestText">Twój wynik: {{results.0.score}}</div>
|
||||||
<div class="solvedTestText">Próg zaliczenia: {{test.passing_score}}</div>
|
<div class="solvedTestText">Próg zaliczenia: {{results.0.passing_score}}</div>
|
||||||
<div class="solvedTestText">Maksymalny wynik: {{test.max}}</div>
|
<div class="solvedTestText">Maksymalny wynik: {{results.0.max}}</div>
|
||||||
<div class="solvedTestText">Wynik procentowy: {{test.percentage}}%</div>
|
<div class="solvedTestText">Wynik procentowy: {{results.0.percentage}}%</div>
|
||||||
|
{% if results|length > 1 %}
|
||||||
|
<div class="linkDefault">
|
||||||
|
<a href="solved/{{results.0.id}}">Sprawdź poprzednie wyniki ({{results|length}})</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
16
templates/solvedTestsDetailed.html
Normal file
16
templates/solvedTestsDetailed.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Historia testu{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Historia testu: {{name}}</h1>
|
||||||
|
{% for test in tests %}
|
||||||
|
<div class="solvedTestContainerMini">
|
||||||
|
<div class="solvedTestText">Twój wynik: {{test.score}}</div>
|
||||||
|
<div class="solvedTestText">Próg zaliczenia: {{test.passing_score}}</div>
|
||||||
|
<div class="solvedTestText">Maksymalny wynik: {{test.max}}</div>
|
||||||
|
<div class="solvedTestText">Wynik procentowy: {{test.percentage}}%</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
@ -1,10 +1,7 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
from trials.views import TestModelViewSet
|
from trials.views import TestModelViewSet, TestTemplateView, TestValidateAPIView, TestResultView, addTest, addQuestions, myTests, solvedTests, solvedTestsDetailed, EditTestTemplateView, deleteTest, AddQuestionToExistingTest, RemoveQuestionFromExistingTest, EditQuestionTemplateView, editName, editVisible, editPassword, TestPasswordTemplateView
|
||||||
from trials.views import TestTemplateView
|
|
||||||
from trials.views import TestValidateAPIView
|
|
||||||
from trials.views import TestResultView, addTest, addQuestions, myTests, editTest, solvedTests, EditTestTemplateView, deleteTest, AddQuestionToExistingTest, RemoveQuestionFromExistingTest, EditQuestionTemplateView, editName, editVisible, editPassword, TestPasswordTemplateView
|
|
||||||
|
|
||||||
router = DefaultRouter(trailing_slash=False)
|
router = DefaultRouter(trailing_slash=False)
|
||||||
router.register("items", TestModelViewSet)
|
router.register("items", TestModelViewSet)
|
||||||
@ -22,11 +19,11 @@ urlpatterns = [
|
|||||||
path('<int:test_id>/editVisible', editVisible, name="editVisible"),
|
path('<int:test_id>/editVisible', editVisible, name="editVisible"),
|
||||||
path('<int:test_id>/editPassword', editPassword, name="editPassword"),
|
path('<int:test_id>/editPassword', editPassword, name="editPassword"),
|
||||||
path('<int:test_id>/remove', deleteTest, name="deleteTest"),
|
path('<int:test_id>/remove', deleteTest, name="deleteTest"),
|
||||||
# path('delete', deleteTest, name="deleteTest"),
|
|
||||||
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('my', myTests, name="myTests"),
|
path('my', myTests, name="myTests"),
|
||||||
path('solved', solvedTests, name="solvedTests")
|
path('solved', solvedTests, name="solvedTests"),
|
||||||
|
path('solved/<int:test_id>', solvedTestsDetailed, name="solvedTests")
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += router.urls
|
urlpatterns += router.urls
|
||||||
|
@ -156,31 +156,46 @@ def solvedTests(request):
|
|||||||
context = {}
|
context = {}
|
||||||
user_id = request.user.id
|
user_id = request.user.id
|
||||||
solved_tests = SolvedTest.objects.filter(user__id=user_id)
|
solved_tests = SolvedTest.objects.filter(user__id=user_id)
|
||||||
formatted_tests = list()
|
dict_with_lists_of_test_results = {}
|
||||||
for solved_test in solved_tests:
|
for solved_test in solved_tests:
|
||||||
formatted_tests.append({
|
if solved_test.test.name_and_passing_score()["name"] in dict_with_lists_of_test_results.keys():
|
||||||
|
dict_with_lists_of_test_results[solved_test.test.name_and_passing_score()["name"]].insert(0, {
|
||||||
"name": solved_test.test.name_and_passing_score()["name"],
|
"name": solved_test.test.name_and_passing_score()["name"],
|
||||||
"passing_score": solved_test.test.name_and_passing_score()["passing_score"],
|
"passing_score": solved_test.test.name_and_passing_score()["passing_score"],
|
||||||
"score": solved_test.score,
|
"score": solved_test.score,
|
||||||
"max": solved_test.max,
|
"max": solved_test.max,
|
||||||
"percentage": solved_test.percentage
|
"percentage": solved_test.percentage,
|
||||||
|
"id": solved_test.test.id
|
||||||
})
|
})
|
||||||
context['tests'] = formatted_tests
|
else:
|
||||||
|
dict_with_lists_of_test_results[solved_test.test.name_and_passing_score()["name"]] = []
|
||||||
|
dict_with_lists_of_test_results[solved_test.test.name_and_passing_score()["name"]].append({
|
||||||
|
"name": solved_test.test.name_and_passing_score()["name"],
|
||||||
|
"passing_score": solved_test.test.name_and_passing_score()["passing_score"],
|
||||||
|
"score": solved_test.score,
|
||||||
|
"max": solved_test.max,
|
||||||
|
"percentage": solved_test.percentage,
|
||||||
|
"id": solved_test.test.id
|
||||||
|
})
|
||||||
|
context['tests_lists'] = dict_with_lists_of_test_results
|
||||||
return render(request, 'solvedTests.html', context)
|
return render(request, 'solvedTests.html', context)
|
||||||
|
|
||||||
|
|
||||||
def editTest(request):
|
def solvedTestsDetailed(request, test_id):
|
||||||
if request.POST:
|
context = {}
|
||||||
# TODO here
|
solved_tests = SolvedTest.objects.filter(test__id=test_id)
|
||||||
# firstName = request.POST.get("firstName")
|
formatted_tests = list()
|
||||||
# lastName = request.POST.get("lastName")
|
for solved_test in solved_tests:
|
||||||
#
|
formatted_tests.append({
|
||||||
# u = request.user
|
"passing_score": solved_test.test.name_and_passing_score()["passing_score"],
|
||||||
# u.first_name = firstName
|
"score": solved_test.score,
|
||||||
# u.last_name = lastName
|
"max": solved_test.max,
|
||||||
# u.save()
|
"percentage": solved_test.percentage,
|
||||||
return redirect('myTests')
|
"id": solved_test.test.id
|
||||||
return render(request, 'editTest.html')
|
})
|
||||||
|
context['name'] = solved_tests[0].test.name_and_passing_score()["name"]
|
||||||
|
context['tests'] = formatted_tests
|
||||||
|
return render(request, 'solvedTestsDetailed.html', context)
|
||||||
|
|
||||||
|
|
||||||
class EditTestTemplateView(TemplateView):
|
class EditTestTemplateView(TemplateView):
|
||||||
|
Loading…
Reference in New Issue
Block a user