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