Merge pull request 'Add questions count' (#28) from feature/question-count into master

Reviewed-on: #28
This commit is contained in:
s470631 2022-01-30 15:21:27 +01:00
commit 36970110a9
4 changed files with 8 additions and 3 deletions

View File

@ -12,7 +12,7 @@
<div class="mainTestMeta">
<div class="left">Kategoria: {{test.category}}</div>
<div class="center">Próg zaliczenia: {{test.passing_score}}</div>
<div class="right">Ilość pytań: {{test.questions|length}}</div>
<div class="right">Ilość pytań: {{test.question_count}}</div>
</div>
<!-- <div class="mainTestDesc">-->
<!-- 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.-->

View File

@ -12,7 +12,7 @@
<div class="mainTestMeta">
<div class="left">Kategoria: {{test.category}}</div>
<div class="center">Próg zaliczenia: {{test.passing_score}}</div>
<div class="right">Ilość pytań: {{test.questions|length}}</div>
<div class="right">Ilość pytań: {{test.question_count}}</div>
</div>
<!-- <div class="mainTestDesc">-->
<!-- 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.-->

View File

@ -12,7 +12,7 @@
<div class="mainTestMeta">
<div class="left">Kategoria: {{test.category}}</div>
<div class="center">Próg zaliczenia: {{test.passing_score}}</div>
<div class="right">Ilość pytań: {{test.questions|length}}</div>
<div class="right">Ilość pytań: {{test.question_count}}</div>
</div>
<!-- <div class="mainTestDesc">-->
<!-- 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.-->

View File

@ -1,4 +1,6 @@
from django.db import models
from questions.models import Question
from .managers import TestManager
@ -62,6 +64,9 @@ class Test(models.Model):
points += question.points
return points
def question_count(self):
return Question.objects.filter(test_id=self.id).count()
def name_and_passing_score(self):
return {
"name": self.name,