develop/soita-2.0 #36

Merged
s470631 merged 12 commits from develop/soita-2.0 into master 2022-05-24 21:02:17 +02:00
45 changed files with 1357 additions and 110 deletions

View File

@ -55,13 +55,16 @@ INSTALLED_APPS = [
"rest_framework_simplejwt", "rest_framework_simplejwt",
"django_extensions", "django_extensions",
"django_social_share", "django_social_share",
'fontawesomefree',
"jquery",
"users", "users",
"trials", "trials",
"answers", "answers",
"questions", "questions",
"categories", "categories",
"tools" "tools",
"questionnaire"
] ]
# AUTHENTICATION_BACKENDS = ['config.authh.SettingsBackend'] # AUTHENTICATION_BACKENDS = ['config.authh.SettingsBackend']
MIDDLEWARE = [ MIDDLEWARE = [

View File

@ -16,18 +16,21 @@ Including another URLconf
from django.contrib import admin from django.contrib import admin
from django.urls import include from django.urls import include
from django.urls import path from django.urls import path
from .views import home, welcome, help from .views import home, welcome, help, hard, popular
from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [ urlpatterns = [
path('', welcome, name='welcome'), path('', welcome, name='welcome'),
path('home', home, name='home'), path('home', home, name='home'),
path('popular', popular, name='popular'),
path('hard', hard, name='hard'),
path('help', help, name='help'), path('help', help, name='help'),
path('users/', include("users.urls")), path('users/', include("users.urls")),
path('questions/', include("questions.urls")), path('questions/', include("questions.urls")),
path('answers/', include("answers.urls")), path('answers/', include("answers.urls")),
path('tests/', include("trials.urls")), path('tests/', include("trials.urls")),
path('category/', include("categories.urls")), path('category/', include("categories.urls")),
path('questionnaire/', include("questionnaire.urls")),
] ]
urlpatterns += staticfiles_urlpatterns() urlpatterns += staticfiles_urlpatterns()

View File

@ -2,6 +2,7 @@ from django.shortcuts import render, redirect
from django.template import loader from django.template import loader
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from trials.models import Test from trials.models import Test
import operator
@login_required @login_required
@ -18,6 +19,19 @@ def home(request):
def help(request): def help(request):
return render(request, 'help.html', ) return render(request, 'help.html', )
@login_required
def popular(request):
context = {}
context['tests'] = Test.objects.filter(avg_rating__gt=0)
context['tests'] = sorted(context['tests'], key=operator.attrgetter('avg_rating'), reverse=True)
return render(request, 'popular.html', context)
@login_required
def hard(request):
context = {}
context['tests'] = Test.objects.filter(difficulty_label__gt=0)
context['tests'] = sorted(context['tests'], key=operator.attrgetter('difficulty_label'), reverse=True)
return render(request, 'hard.html', context)
def welcome(request): def welcome(request):
return render(request, 'welcome.html') return render(request, 'welcome.html')

View File

@ -1,8 +1,13 @@
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
#FF0B7E - Winter Sky Buttons and links
#00916E - Illuminating Emerald
Main color:
#FF0B7E - Winter Sky
#19647E - Blue Sapphire

View File

0
questionnaire/apps.py Normal file
View File

22
questionnaire/managers.py Normal file
View File

@ -0,0 +1,22 @@
from django.db.models import Manager
from django.apps import apps
from django.conf import settings
class QuestionnaireManager(Manager):
def create(
self,
**kwargs
):
instance = super().create(
overall=kwargs.get("overall"),
functionality=kwargs.get("functionality"),
look=kwargs.get("look"),
intuitive=kwargs.get("intuitive"),
bugs=kwargs.get("bugs"),
tech=kwargs.get("tech"),
potential=kwargs.get("potential"),
worst=kwargs.get("worst"),
desc=kwargs.get("desc"),
)
return instance

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.9 on 2022-05-15 21:29
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Questionnaire',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('overall', models.IntegerField(default=0)),
('functionality', models.IntegerField(default=0)),
('look', models.IntegerField(default=0)),
('intuitive', models.IntegerField(default=0)),
('bugs', models.IntegerField(default=0)),
('tech', models.IntegerField(default=0)),
('potential', models.IntegerField(default=0)),
('worst', models.IntegerField(default=0)),
('desc', models.CharField(default='', max_length=255)),
('fill_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaire', to=settings.AUTH_USER_MODEL)),
],
),
]

View File

22
questionnaire/models.py Normal file
View File

@ -0,0 +1,22 @@
from django.db import models
from .managers import QuestionnaireManager
class Questionnaire(models.Model):
overall = models.IntegerField(default=0)
functionality = models.IntegerField(default=0)
look = models.IntegerField(default=0)
intuitive = models.IntegerField(default=0)
bugs = models.IntegerField(default=0)
tech = models.IntegerField(default=0)
potential = models.IntegerField(default=0)
worst = models.IntegerField(default=0)
desc = models.CharField(max_length=255, default="")
fill_by = models.ForeignKey(
"users.User",
null=True,
related_name="questionnaire",
on_delete=models.CASCADE
)
objects = QuestionnaireManager()

View File

@ -0,0 +1,28 @@
from rest_framework import serializers
from questionnaire.models import Questionnaire
class QuestionnaireSerializer(serializers.ModelSerializer):
class Meta:
model = Questionnaire
fields = (
"id",
"overall",
"functionality",
"look",
"intuitive",
"bugs",
"tech",
"potential",
"worst",
"desc",
"fill_by"
)
def create(self, validated_data):
instance = Questionnaire.objects.create(
**validated_data
)
return instance

12
questionnaire/urls.py Normal file
View File

@ -0,0 +1,12 @@
from django.urls import path
from rest_framework.routers import DefaultRouter
from .views import questionnaire
router = DefaultRouter(trailing_slash=False)
urlpatterns = [
path('questionnaire', questionnaire, name='questionnaire')
]
urlpatterns += router.urls

22
questionnaire/views.py Normal file
View File

@ -0,0 +1,22 @@
from django.shortcuts import render, redirect
from django.template import loader
from django.contrib.auth.decorators import login_required
from questionnaire.models import Questionnaire
@login_required
def questionnaire(request):
if request.POST:
overall = request.GET.get("overall")
functionality = request.GET.get("functionality")
look = request.GET.get("look")
intuitive = request.GET.get("intuitive")
bugs = request.GET.get("bugs")
tech = request.GET.get("tech")
potential = request.GET.get("potential")
worst = request.GET.get("worst")
desc = request.GET.get("desc")
Questionnaire.objects.create(overall=overall, functionality=functionality, look=look, intuitive=intuitive,
bugs=bugs, tech=tech, potential=potential, worst=worst, desc=desc)
return redirect('home')
return render(request, 'questionnaire.html')

View File

@ -19,4 +19,9 @@ class Question(models.Model):
for answer in self.answers.all() for answer in self.answers.all()
] ]
tournament = models.ManyToManyField(
"trials.Tournament",
null=True
)
objects = QuestionManager() objects = QuestionManager()

View File

@ -109,3 +109,4 @@ wcwidth==0.2.5
webencodings==0.5.1 webencodings==0.5.1
widgetsnbextension==3.5.2 widgetsnbextension==3.5.2
zipp==3.6.0 zipp==3.6.0
fontawesomefree==6.1.1

21
static/script.js Normal file
View File

@ -0,0 +1,21 @@
//$(function() {
// $(".newQuestionSection" ).draggable().resizable();
//} );
var questionId = 1;
$('.addQuestionButton').click(function(){
console.log("REEEEEEEE")
// Clone extra box, and remove duplicate ids
let clone = $("#question-copy").clone().removeAttr("hidden");
clone.id = "question"- + ++questionId;
//clone.find("*").removeAttr("id");
clone.find("*").each(function() {
$(this).attr("id", "q" + questionId + "-" + $(this).attr("id"));
});
clone.find("input:radio").each(function() {
$(this).attr("name", questionId);
});
// append it to div
$('#canvas').append(clone);
});

View File

@ -1,6 +1,6 @@
.sidenav { .sidenav {
height: 100%; height: 100%;
width: 195px; width: 215px;
position: fixed; position: fixed;
z-index: 1; z-index: 1;
top: 0; top: 0;
@ -44,7 +44,7 @@
} }
.main { .main {
margin-left: 190px; margin-left: 215px;
padding: 0px 40px; padding: 0px 40px;
} }
@ -83,8 +83,8 @@
border-radius: 25px; border-radius: 25px;
border: 2px solid #FF0B7E; border: 2px solid #FF0B7E;
padding: 20px; padding: 20px;
width: 800px; width: 750px;
height: 150px; height: 200px;
} }
.mainTestName { .mainTestName {
@ -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;
} }
@ -107,12 +115,38 @@
} }
.mainTestMeta { .mainTestMeta {
font-size: 13px; padding-bottom: 30px;
padding-bottom: 40px;
color: #808080;
/*transform: translate(150%,0%);*/ /*transform: translate(150%,0%);*/
width:100%; width:100%;
text-align:center; }
.mainTestMetaLine {
padding-bottom: 10px;
display: flex;
justify-content: space-between;
}
.mainTestMetaInfoText {
width: 250px;
color: #808080;
font-size: 13px;
text-align: center;
}
.mainTestMetaLineLabels {
padding-bottom: 10px;
padding-top: 10px;
margin-left: 15%;
margin-right: 15%;
display: flex;
justify-content: space-between;
}
.mainTestMetaLabels {
font-weight: bold;
font-size: 16px;
color: #000000;
text-align: center;
} }
.left { .left {
@ -332,6 +366,15 @@ background-color:#FF0B7E
padding-bottom: 15px; padding-bottom: 15px;
} }
.resultContainer label {
font-weight: bold;
font-size: 20px;
}
.resultContainerSpace {
padding-bottom: 15px;
}
.resultImage{ .resultImage{
} }
@ -453,6 +496,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]{
@ -471,6 +515,23 @@ background-color:#FF0B7E
width: 500px; width: 500px;
} }
.newQuestionSection {
border-radius: 25px;
border: 2px solid #FF0B7E;
padding: 20px;
width: 750px;
height: 350px;
}
.questionSectionLabelText {
font-weight: bold;
font-size: 16px;
padding-bottom: 20px;
}
.addQuestionButton {
}
.editContainer { .editContainer {
overflow: scroll; overflow: scroll;
} }
@ -489,4 +550,16 @@ background-color:#FF0B7E
span { span {
margin-right: 10px; margin-right: 10px;
}
.starChecked {
color: gold;
}
.fireChecked {
color: red;
}
.locked {
color: #19647E;
} }

View File

@ -6,17 +6,27 @@
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
<title>SOITA | {% block title %}{% endblock %}</title> <title>SOITA | {% block title %}{% endblock %}</title>
<meta name="description" content="{% block description %}{% endblock %}"> <meta name="description" content="{% block description %}{% endblock %}">
<!-- reference your installed Font Awesome Free package's files here -->
<script src="{% static 'fontawesomefree/js/all.min.js' %}"></script>
<link href="{% static 'fontawesomefree/css/all.min.css' %}" rel="stylesheet" type="text/css">
{% block additional_head %} {% block additional_head %}
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
<div class="sidenav"> <div class="sidenav">
<a href="{% url 'home' %}">Strona główna</a> <a href="{% url 'home' %}"><i class="fa-solid fa-house"></i> Strona główna</a>
<a href="{% url 'newTest' %}">Stwórz test</a> <a href="{% url 'popular' %}"><i class="fa-solid fa-star"></i> Popularne </a>
<a href="{% url 'myTests' %}">Twoje testy</a> <a href="{% url 'hard' %}"><i class="fa-solid fa-fire-flame-curved"></i> Trudne </a>
<a href="{% url 'solvedTests' %}">Wyniki testów</a> {% if user.type == "admin" %}
<a href="{% url 'help' %}">Pomoc</a> <a href="{% url 'CreateTournament' %}"><i class="fa-solid fa-trophy"></i> Stwórz turniej </a>
{% endif %}
<a href="{% url 'tournaments' %}"><i class="fa-solid fa-trophy"></i> Turnieje </a>
<br>
<a href="{% url 'newTest' %}"><i class="fa-solid fa-circle-plus"></i> Stwórz test</a>
<a href="{% url 'myTests' %}"><i class="fa-solid fa-note-sticky"></i> Twoje testy</a>
<a href="{% url 'solvedTests' %}"><i class="fa-solid fa-square-poll-horizontal"></i> Wyniki testów</a>
<p>Kategorie</p> <p>Kategorie</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,13 +40,17 @@
<a href="/category/Historia">Historia</a> <a href="/category/Historia">Historia</a>
<a href="/category/Inne">Inne</a> <a href="/category/Inne">Inne</a>
<p>Konto</p> <p>Konto</p>
<a href="/users/account">Ustawienia</a> <a href="/users/account"><i class="fa-solid fa-gear"></i> Ustawienia</a>
<a href="/users/logout">Wyloguj</a> <a href="/questionnaire/questionnaire"><i class="fa-solid fa-file-pen"></i> Ankieta</a>
<a href="{% url 'help' %}"><i class="fa-solid fa-circle-question"></i> Pomoc</a>
<a href="/users/logout"><i class="fa-solid fa-right-from-bracket"></i> Wyloguj</a>
</div> </div>
<div id="content", name="content", class="main"> <div id="content", name="content", class="main">
{% block content %} <div class="mainContainer">
{% endblock %} {% block content %}
{% endblock %}
</div>
</div> </div>
</body> </body>

View File

@ -14,11 +14,104 @@
<div class="mainTestContainer"> <div class="mainTestContainer">
<div class="mainTestName"> <div class="mainTestName">
{{test.name}} {{test.name}}
{% if test.password != "" %}
<i class="fa-solid fa-lock locked" title="Test chroniony hasłem"></i>
{% endif %}
</div> </div>
<div class="mainTestMeta"> <div class="mainTestMeta">
<div class="left">Kategoria: {{test.category}}</div> <div class="mainTestMetaLine">
<div class="center">Próg zaliczenia: {{test.passing_score}}</div> <div class="mainTestMetaInfoText">Kategoria: {{test.category}}</div>
<div class="right">Liczba pytań: {{test.question_count}}</div> <div class="mainTestMetaInfoText">Autor: {{test.get_author_name}}</div>
<div class="mainTestMetaInfoText">Rozwiązania: {{test.completions}}</div>
</div>
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Próg zaliczenia: {{test.passing_score}}</div>
<div class="mainTestMetaInfoText">Maksymalna ilość punktów: {{test.get_maxscore}}</div>
<div class="mainTestMetaInfoText">Ilość pytań: {{test.question_count}}</div>
</div>
<div class="mainTestMetaLineLabels">
<div class="mainTestMetaLabels">
Trudność:
{% if test.difficulty_label == 0 %}
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
{% elif test.difficulty_label == 1 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
{% elif test.difficulty_label == 2 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
{% elif test.difficulty_label == 3 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
{% elif test.difficulty_label == 4 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
{% else %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
{% endif %}
</div>
<div class="mainTestMetaLabels">
Ocena:
{% if test.avg_rating == 0 %}
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
{% elif test.avg_rating == 1 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
{% elif test.avg_rating == 2 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
{% elif test.avg_rating == 3 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
{% elif test.avg_rating == 4 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star"></span>
{% else %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
{% endif %}
(Głosy: {{test.rates_amount}})
</div>
</div>
</div> </div>
<!-- <div class="mainTestDesc">--> <!-- <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.--> <!-- 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

@ -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 %}

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>

View File

@ -0,0 +1,28 @@
{% extends "base.html" %}
{% block title %}Stwórz turniej{% endblock %}
{% block content %}
<h1>Stwórz turniej</h1>
<form method="post" novalidate>
{% for question in questions %}
<div class="mainTestName">
<div class="question_title" style="padding-top:15px; padding-bottom:10px; padding-left:5px;">
<input class="form-check-input me-1" type="radio" value={{ question.id }}>
{{ question.description }}
</div>
<div class="list-group">
{% for answer in question.answers.all %}
<label class="list-group-item">
- {{ answer.description }}<br>
</label>
{% endfor %}
</div>
{% endfor %}
</div>
</form>
<div class="testContent">
<input type="submit" value="Wyślij odpowiedzi">
</div>
{% endblock %}

118
templates/hard.html Normal file
View File

@ -0,0 +1,118 @@
{% extends "base.html" %}
{% block title %}Najtrudniejsze{% endblock %}
{% block content %}
<h1>Najtrudniejsze testy:</h1>
{% for test in tests %}
<div class="mainTestContainer">
<div class="mainTestName">
{{test.name}}
{% if test.password != "" %}
<i class="fa-solid fa-lock locked" title="Test chroniony hasłem"></i>
{% endif %}
</div>
<div class="mainTestMeta">
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Kategoria: {{test.category}}</div>
<div class="mainTestMetaInfoText">Autor: {{test.get_author_name}}</div>
<div class="mainTestMetaInfoText">Rozwiązania: {{test.completions}}</div>
</div>
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Próg zaliczenia: {{test.passing_score}}</div>
<div class="mainTestMetaInfoText">Maksymalna ilość punktów: {{test.get_maxscore}}</div>
<div class="mainTestMetaInfoText">Ilość pytań: {{test.question_count}}</div>
</div>
<div class="mainTestMetaLineLabels">
<div class="mainTestMetaLabels">
Trudność:
{% if test.difficulty_label == 0 %}
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
{% elif test.difficulty_label == 1 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
{% elif test.difficulty_label == 2 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
{% elif test.difficulty_label == 3 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
{% elif test.difficulty_label == 4 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
{% else %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
{% endif %}
</div>
<div class="mainTestMetaLabels">
Ocena:
{% if test.avg_rating == 0 %}
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
{% elif test.avg_rating == 1 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
{% elif test.avg_rating == 2 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
{% elif test.avg_rating == 3 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
{% elif test.avg_rating == 4 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star"></span>
{% else %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
{% endif %}
(Głosy: {{test.rates_amount}})
</div>
</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.-->
<!-- </div>-->
<button><a href="/tests/{{test.id}}/password">Rozwiąż</a></button>
</div>
<br>
{% endfor %}
{% endblock %}

View File

@ -3,22 +3,113 @@
{% block title %}Główna{% endblock %} {% block title %}Główna{% endblock %}
{% block content %} {% block content %}
<h1>Rozwiąż jakiś test!</h1> <h1>Najnowsze testy:</h1>
{% for test in tests %} {% for test in tests %}
<div class="mainTestContainer"> <div class="mainTestContainer">
<div class="mainTestName"> <div class="mainTestName">
{{test.name}} {{test.name}}
<i class="fa-solid fa-lock"></i> {% if test.password != "" %}
<i class="fa-solid fa-lock locked" title="Test chroniony hasłem"></i>
{% endif %}
</div> </div>
<div class="mainTestMeta"> <div class="mainTestMeta">
<div class="left">Kategoria: {{test.category}}</div> <div class="mainTestMetaLine">
<div class="center">Próg zaliczenia: {{test.passing_score}}</div> <div class="mainTestMetaInfoText">Kategoria: {{test.category}}</div>
<div class="right">Liczba pytań: {{test.question_count}}</div> <div class="mainTestMetaInfoText">Autor: {{test.get_author_name}}</div>
<div class="mainTestMetaInfoText">Rozwiązania: {{test.completions}}</div>
</div>
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Próg zaliczenia: {{test.passing_score}}</div>
<div class="mainTestMetaInfoText">Maksymalna ilość punktów: {{test.get_maxscore}}</div>
<div class="mainTestMetaInfoText">Ilość pytań: {{test.question_count}}</div>
</div>
<div class="mainTestMetaLineLabels">
<div class="mainTestMetaLabels">
Trudność:
{% if test.difficulty_label == 0 %}
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
{% elif test.difficulty_label == 1 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
{% elif test.difficulty_label == 2 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
{% elif test.difficulty_label == 3 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
{% elif test.difficulty_label == 4 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
{% else %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
{% endif %}
</div>
<div class="mainTestMetaLabels">
Ocena:
{% if test.avg_rating == 0 %}
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
{% elif test.avg_rating == 1 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
{% elif test.avg_rating == 2 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
{% elif test.avg_rating == 3 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
{% elif test.avg_rating == 4 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star"></span>
{% else %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
{% endif %}
(Głosy: {{test.rates_amount}})
</div>
</div>
</div> </div>
<!-- <div class="mainTestDesc">--> <!-- <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.--> <!-- 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>-->
{# <button><a href="/tests/{{test.id}}/show">Rozwiąż</a></button>#}
<button><a href="/tests/{{test.id}}/password">Rozwiąż</a></button> <button><a href="/tests/{{test.id}}/password">Rozwiąż</a></button>
</div> </div>
<br> <br>

View File

@ -8,11 +8,104 @@
<div class="mainTestContainer"> <div class="mainTestContainer">
<div class="mainTestName"> <div class="mainTestName">
{{test.name}} {{test.name}}
{% if test.password != "" %}
<i class="fa-solid fa-lock locked" title="Test chroniony hasłem"></i>
{% endif %}
</div> </div>
<div class="mainTestMeta"> <div class="mainTestMeta">
<div class="left">Kategoria: {{test.category}}</div> <div class="mainTestMetaLine">
<div class="center">Próg zaliczenia: {{test.passing_score}}</div> <div class="mainTestMetaInfoText">Kategoria: {{test.category}}</div>
<div class="right">Liczba pytań: {{test.question_count}}</div> <div class="mainTestMetaInfoText">Autor: {{test.get_author_name}}</div>
<div class="mainTestMetaInfoText">Rozwiązania: {{test.completions}}</div>
</div>
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Próg zaliczenia: {{test.passing_score}}</div>
<div class="mainTestMetaInfoText">Maksymalna ilość punktów: {{test.get_maxscore}}</div>
<div class="mainTestMetaInfoText">Ilość pytań: {{test.question_count}}</div>
</div>
<div class="mainTestMetaLineLabels">
<div class="mainTestMetaLabels">
Trudność:
{% if test.avg_difficulty == 0.0 %}
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
{% elif test.avg_difficulty < 20.0 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
{% elif test.avg_difficulty < 40.0 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
{% elif test.avg_difficulty < 60.0 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
{% elif test.avg_difficulty < 80.0 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
{% else %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
{% endif %}
</div>
<div class="mainTestMetaLabels">
Ocena:
{% if test.avg_rating == 0 %}
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
{% elif test.avg_rating == 1 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
{% elif test.avg_rating == 2 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
{% elif test.avg_rating == 3 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
{% elif test.avg_rating == 4 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star"></span>
{% else %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
{% endif %}
(Głosy: {{test.rates_amount}})
</div>
</div>
</div> </div>
<!-- <div class="mainTestDesc">--> <!-- <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.--> <!-- 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.-->

118
templates/popular.html Normal file
View File

@ -0,0 +1,118 @@
{% extends "base.html" %}
{% block title %}Najpopularniejsze{% endblock %}
{% block content %}
<h1>Najpopularniejsze testy:</h1>
{% for test in tests %}
<div class="mainTestContainer">
<div class="mainTestName">
{{test.name}}
{% if test.password != "" %}
<i class="fa-solid fa-lock locked" title="Test chroniony hasłem"></i>
{% endif %}
</div>
<div class="mainTestMeta">
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Kategoria: {{test.category}}</div>
<div class="mainTestMetaInfoText">Autor: {{test.get_author_name}}</div>
<div class="mainTestMetaInfoText">Rozwiązania: {{test.completions}}</div>
</div>
<div class="mainTestMetaLine">
<div class="mainTestMetaInfoText">Próg zaliczenia: {{test.passing_score}}</div>
<div class="mainTestMetaInfoText">Maksymalna ilość punktów: {{test.get_maxscore}}</div>
<div class="mainTestMetaInfoText">Ilość pytań: {{test.question_count}}</div>
</div>
<div class="mainTestMetaLineLabels">
<div class="mainTestMetaLabels">
Trudność:
{% if test.difficulty_label == 0 %}
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
<span class="fa-solid fa-fire-flame-curved" title="Brak - za mało osób rozwiązało ten test"></span>
{% elif test.difficulty_label == 1 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
<span class="fa-solid fa-fire-flame-curved" title="Bardzo trudny test, średni wynik użytkowników poniżej 20%">></span>
{% elif test.difficulty_label == 2 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Trudny test, średni wynik użytkowników nie przekracza 40%"></span>
{% elif test.difficulty_label == 3 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Przeciętny test, średni wynik użytkowników nie przekracza 60%"></span>
{% elif test.difficulty_label == 4 %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
<span class="fa-solid fa-fire-flame-curved" title="Łatwy test, średni wynik użytkowników nie przekracza 80%"></span>
{% else %}
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
<span class="fa-solid fa-fire-flame-curved fireChecked" title="Banalny test, średni wynik użytkowników powyżej 80%"></span>
{% endif %}
</div>
<div class="mainTestMetaLabels">
Ocena:
{% if test.avg_rating == 0 %}
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
<span class="fa fa-star" title="Użytkownicy jeszcze nie ocenili tego testu, bądź pierwszy"></span>
{% elif test.avg_rating == 1 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako tragiczny"></span>
{% elif test.avg_rating == 2 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako słaby"></span>
{% elif test.avg_rating == 3 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
<span class="fa fa-star" title="Użytkownicy ocenili ten test jako przeciętny"></span>
{% elif test.avg_rating == 4 %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako dobry"></span>
<span class="fa fa-star"></span>
{% else %}
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
<span class="fa fa-star starChecked" title="Użytkownicy ocenili ten test jako genialny"></span>
{% endif %}
(Głosy: {{test.rates_amount}})
</div>
</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.-->
<!-- </div>-->
<button><a href="/tests/{{test.id}}/password">Rozwiąż</a></button>
</div>
<br>
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,96 @@
{% extends "base.html" %}
{% block title %}Ankieta{% endblock %}
{% block content %}
<div class="accountInfoContainer ">
<h2>Ankieta oceniająca działanie aplikacji:</h2>
<form method="post">
<label for="overall">1. Jak ogólnie oceniasz aplikację?</label>
<select name="overall" id="overall">
<option value="1">Bardzo dobrze</option>
<option value="2">Dobrze</option>
<option value="3">Przeciętnie</option>
<option value="4">Słabo</option>
<option value="5">Bardzo słabo</option>
</select>
<br>
<br>
<label for="functionality">2. Jak oceniasz ilość dostępnych funkcjonalności?</label>
<select name="functionality" id="functionality">
<option value="1">Bardzo dużo</option>
<option value="2">Sporo</option>
<option value="3">Wystarczająco</option>
<option value="4">Za mało</option>
<option value="5">O wiele za mało</option>
</select>
<br>
<br>
<label for="look">3. Jak oceniasz wygląd aplikacji?</label>
<select name="look" id="look">
<option value="1">Bardzo ładny</option>
<option value="2">Ładny</option>
<option value="3">Przeciętny</option>
<option value="4">Brzydki</option>
<option value="5">Bardzo brzydki</option>
</select>
<br>
<br>
<label for="intuitive">4. Jak często było coś dla ciebie nieintuicyjne?</label>
<select name="intuitive" id="intuitive">
<option value="1">Nigdy</option>
<option value="2">Bardzo rzadko</option>
<option value="3">Rzadko</option>
<option value="4">Często</option>
<option value="5">Bardzo często</option>
</select>
<br>
<br>
<label for="bugs">5. Jak często napotkałeś jakiekolwiek błędy?</label>
<select name="bugs" id="bugs">
<option value="1">Nigdy</option>
<option value="2">Bardzo rzadko</option>
<option value="3">Rzadko</option>
<option value="4">Często</option>
<option value="5">Bardzo często</option>
</select>
<br>
<br>
<label for="tech">6. Jak cogólnie oceniasz stonę techniczną aplikacji?</label>
<select name="tech" id="tech">
<option value="1">Bardzo dobrze</option>
<option value="2">Dobrze</option>
<option value="3">Przeciętnie</option>
<option value="4">Słsbo</option>
<option value="5">Bardzo słabo</option>
</select>
<br>
<br>
<label for="potential">7. Jak duży potencjał widzisz?</label>
<select name="potential" id="potential">
<option value="1">Bardzo duży</option>
<option value="2">Duży</option>
<option value="3">Mały</option>
<option value="4">Bardzo mały</option>
<option value="5">Nie widzę żadnego</option>
</select>
<br>
<br>
<label for="worst">8. Który element według ciebie wypada najgorzej?</label>
<select name="worst" id="worst">
<option value="1">Wygląd</option>
<option value="2">Przydatność</option>
<option value="3">Intuicyjność</option>
<option value="4">Strona techniczna</option>
<option value="5">Żaden</option>
</select>
<br>
<br>
<label for="desc">9. Dodatkowe uwagi: </label>
<input id="desc" type="text" name="desc">
<br>
<br>
<input type="submit" value="Wyślij ankietę"><br><br>
</form>
</div>
{% endblock %}

View File

@ -9,30 +9,46 @@
<div class="resultBody"> <div class="resultBody">
<h5 class="resultMsg"> <h5 class="resultMsg">
<!-- Quite good! All the best for next quiz!--> <!-- Quite good! All the best for next quiz!-->
{% if percentage == 100 %} {% if request.session.percentage == 100 %}
Idealnie, widzę że ten temat nie ma dla ciebie tajemnic! Idealnie, widzę że ten temat nie ma dla ciebie tajemnic!
{% elif percentage >= 75 %} {% elif request.session.percentage >= 75 %}
Bardzo dobrze, ale są jeszcze pewne braki ;) Bardzo dobrze, ale są jeszcze pewne braki ;)
{% elif percentage >= 50 %} {% elif request.session.percentage >= 50 %}
Nie jest źle, wiedziałeś więcej niż mniej Nie jest źle, wiedziałeś więcej niż mniej
{% elif percentage >= 25 %} {% elif request.session.percentage >= 25 %}
Masz spore braki, powinieneś trochę więcej się pouczyć Masz spore braki, powinieneś trochę więcej się pouczyć
{% else %} {% else %}
Słabiutko, ale następnym razem będzie lepiej Słabiutko, ale następnym razem będzie lepiej
{% endif %} {% endif %}
</h5> </h5>
<h5 class="resultScore">Rezultat: {{ status }}</h5> <h5 class="resultScore">Rezultat: {{ request.session.status }}</h5>
<h5 class="resultText">Twój wynik: {{ points }}</h5> <h5 class="resultText">Twój wynik: {{ request.session.points }}</h5>
<h5 class="resultText">Próg zaliczenia: {{ passing }}</h5> <h5 class="resultText">Próg zaliczenia: {{ request.session.passing }}</h5>
<h5 class="resultText">Maksymalny wynik: {{ max }}</h5> <h5 class="resultText">Maksymalny wynik: {{ request.session.max }}</h5>
<h5 class="resultText">Wynik procentowy: {{ percentage }}%</h5> <h5 class="resultText">Wynik procentowy: {{ request.session.percentage }}%</h5>
<button class="defaultButton"><a href="{% url 'home' %}">Strona główna</a></button>
{% if password == "" %} <div class="resultContainerSapce"><br></div>
<br> <span><label for="rate"><h5>Jak oceniasz test:</h5></label></span>
<select name="rate" id="rate">
<option value="1">Tragiczny</option>
<option value="2">Słaby</option>
<option value="3">Przeciętny</option>
<option value="4">Dobry</option>
<option value="5">Genialny</option>
</select>
<span><button class="defaultButton">
<a href='' onclick="this.href='rateTest?rate='+document.getElementById('rate').value">Oceń</a>
</button></span>
<div class="resultContainerSapce"><br></div>
{% if request.session.password == "" %}
<h5>Udostępnij:</h5> <h5>Udostępnij:</h5>
{% post_to_facebook object_or_url %} {% post_to_facebook object_or_url %}
{% post_to_linkedin object_or_url %} {% post_to_linkedin object_or_url %}
{% endif %} {% endif %}
<div class="resultContainerSapce"><br></div>
<button class="defaultButton"><a href="{% url 'home' %}">Strona główna</a></button>
</div> </div>
</div> </div>

View File

@ -4,16 +4,21 @@
{% 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 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>
<div class="solvedTestText">Twój wynik: {{test.score}}</div> <br>
<div class="solvedTestText">Próg zaliczenia: {{test.passing_score}}</div> {% endfor %}
<div class="solvedTestText">Maksymalny wynik: {{test.max}}</div>
<div class="solvedTestText">Wynik procentowy: {{test.percentage}}%</div>
</div>
<br>
{% endfor %}
{% endblock %} {% endblock %}

View 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 %}

View File

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}Turnieje{% endblock %}
{% block content %}
<h1>Twoje testy</h1>
{% for test in tests %}
<div class="mainTestContainer">
<div class="mainTestName">
{{tournament.name}}
<!-- {% if test.password != "" %}-->
<!-- <i class="fa-solid fa-lock locked" title="Test chroniony hasłem"></i>-->
<!-- {% endif %}-->
</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.-->
<!-- </div>-->
<button><a href="/tests/{{tournament.id}}/show">Rozwiąż</a></button>
</div>
<br>
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-04-16 12:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trials', '0015_test_password'),
]
operations = [
migrations.AddField(
model_name='test',
name='completions',
field=models.IntegerField(default=0),
),
]

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.9 on 2022-04-16 12:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trials', '0016_test_completions'),
]
operations = [
migrations.AddField(
model_name='test',
name='difficulty_label',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='test',
name='rating_label',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='test',
name='total_percentage_scored_by_users',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='test',
name='total_rating',
field=models.IntegerField(default=0),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-04-16 13:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trials', '0017_auto_20220416_1431'),
]
operations = [
migrations.AddField(
model_name='test',
name='rates_Amount',
field=models.IntegerField(default=0),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-04-16 13:23
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('trials', '0018_test_rates_amount'),
]
operations = [
migrations.RenameField(
model_name='test',
old_name='rates_Amount',
new_name='rates_amount',
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.9 on 2022-04-16 14:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trials', '0019_rename_rates_amount_test_rates_amount'),
]
operations = [
migrations.RenameField(
model_name='test',
old_name='rating_label',
new_name='avg_rating',
),
migrations.AddField(
model_name='test',
name='avg_difficulty',
field=models.FloatField(default=0.0),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.9 on 2022-04-16 14:36
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('trials', '0020_auto_20220416_1634'),
]
operations = [
migrations.RemoveField(
model_name='test',
name='difficulty_label',
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-05-15 21:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trials', '0021_remove_test_difficulty_label'),
]
operations = [
migrations.AddField(
model_name='test',
name='difficulty_label',
field=models.IntegerField(default=0),
),
]

View File

@ -1,6 +1,7 @@
from django.db import models from django.db import models
from questions.models import Question from questions.models import Question
from users.models import User
from .managers import TestManager from .managers import TestManager
@ -22,7 +23,13 @@ class Test(models.Model):
on_delete=models.CASCADE on_delete=models.CASCADE
) )
password = models.CharField(max_length=100, default="") password = models.CharField(max_length=100, default="")
completions = models.IntegerField(default=0)
total_percentage_scored_by_users = models.IntegerField(default=0)
total_rating = models.IntegerField(default=0)
avg_rating = models.IntegerField(default=0)
rates_amount = models.IntegerField(default=0)
difficulty_label = models.IntegerField(default=0)
avg_difficulty = models.FloatField(default=0.0)
objects = TestManager() objects = TestManager()
def get_score(self, answers): def get_score(self, answers):
@ -45,7 +52,7 @@ class Test(models.Model):
points += question.points points += question.points
return points return points
def get_maxscore(self, answers): def get_maxscore(self):
""" """
[ [
{ {
@ -59,9 +66,6 @@ class Test(models.Model):
] ]
""" """
points = 0 points = 0
# for answer in answers:
# question = self.questions.get(id=answer["question"])
# points += question.points
for question in self.questions.all(): for question in self.questions.all():
points += question.points points += question.points
return points return points
@ -69,6 +73,14 @@ class Test(models.Model):
def question_count(self): def question_count(self):
return Question.objects.filter(test_id=self.id).count() return Question.objects.filter(test_id=self.id).count()
def get_author_name(self):
if self.created_by:
user = User.objects.get(email=self.created_by)
user_fullname = user.first_name + " " + user.last_name
else:
user_fullname = "SOITA"
return user_fullname
def name_and_passing_score(self): def name_and_passing_score(self):
return { return {
"name": self.name, "name": self.name,
@ -91,4 +103,15 @@ class SolvedTest(models.Model):
null=True, null=True,
related_name="answers", related_name="answers",
on_delete=models.CASCADE on_delete=models.CASCADE
) )
class Tournament(models.Model):
name = models.CharField(max_length=100)
created_by = models.ForeignKey(
"users.User",
null=True,
related_name="tournaments",
on_delete=models.CASCADE
)
password = models.CharField(max_length=100)

View File

@ -19,6 +19,14 @@ class TestSerializer(serializers.ModelSerializer):
"questions", "questions",
"visible", "visible",
"category", "category",
"created_by",
"completions",
"total_percentage_scored_by_users",
"total_rating",
"avg_rating",
"rates_amount",
"difficulty_label",
"avg_difficulty"
) )
def create(self, validated_data): def create(self, validated_data):

View File

@ -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, rateTest, addTest, addQuestions, myTests, solvedTests, solvedTestsDetailed, EditTestTemplateView, deleteTest, AddQuestionToExistingTest, RemoveQuestionFromExistingTest, EditQuestionTemplateView, editName, editVisible, editPassword, TestPasswordTemplateView, TournamentView, CreateTournamentView
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)
@ -14,6 +11,7 @@ urlpatterns = [
path('<int:test_id>/password', TestPasswordTemplateView), path('<int:test_id>/password', TestPasswordTemplateView),
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>/rateTest', rateTest, name="rateTest"),
path('<int:test_id>/edit', EditTestTemplateView.as_view()), path('<int:test_id>/edit', EditTestTemplateView.as_view()),
path('<int:test_id>/add-question', AddQuestionToExistingTest.as_view()), path('<int:test_id>/add-question', AddQuestionToExistingTest.as_view()),
path('<int:test_id>/remove-question', RemoveQuestionFromExistingTest.as_view()), path('<int:test_id>/remove-question', RemoveQuestionFromExistingTest.as_view()),
@ -22,11 +20,13 @@ 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"),
path('tournamets', TournamentView, name="tournaments"),
path('add/tournament', CreateTournamentView, name="CreateTournament")
] ]
urlpatterns += router.urls urlpatterns += router.urls

View File

@ -8,7 +8,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
from questions.models import Question from questions.models import Question
from trials.models import Test, SolvedTest from trials.models import Test, SolvedTest, Tournament
from trials.serializers import TestSerializer from trials.serializers import TestSerializer
from django.conf import settings from django.conf import settings
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
@ -18,12 +18,12 @@ from django.template import loader
from django.template.loader import render_to_string, get_template from django.template.loader import render_to_string, get_template
from django.http import HttpRequest from django.http import HttpRequest
import requests import requests
from django.contrib.auth.decorators import login_required
@login_required
def addTest(request): def addTest(request):
return render(request, 'createTest.html') return render(request, 'createTest.html')
def is_visible(visible): def is_visible(visible):
if visible =="public": if visible =="public":
return True return True
@ -83,6 +83,15 @@ def addQuestions(request, **kwargs):
return redirect('home') return redirect('home')
return render(request, 'addQuestions.html') return render(request, 'addQuestions.html')
def TournamentView(request):
context = {}
context['tournament'] = Tournament.objects.all()
return render(request, 'tournaments.html', context)
def CreateTournamentView(request):
context = {}
context['questions'] = Question.objects.all()
return render(request, 'createTournament.html', context)
class AddQuestionToExistingTest(TemplateView): class AddQuestionToExistingTest(TemplateView):
template_name = settings.BASE_DIR + f"/templates/addQuestionToExistingTest.html" template_name = settings.BASE_DIR + f"/templates/addQuestionToExistingTest.html"
@ -144,43 +153,58 @@ class RemoveQuestionFromExistingTest(TemplateView):
Question.objects.get(id=request.POST["id"]).delete() Question.objects.get(id=request.POST["id"]).delete()
return redirect(f'/tests/{kwargs["test_id"]}/edit') return redirect(f'/tests/{kwargs["test_id"]}/edit')
@login_required
def myTests(request): def myTests(request):
context = {} context = {}
user = request.user.id user = request.user.id
context['tests'] = Test.objects.filter(created_by=user) context['tests'] = Test.objects.filter(created_by=user)
return render(request, 'myTests.html', context) return render(request, 'myTests.html', context)
@login_required
def solvedTests(request): 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)
dict_with_lists_of_test_results = {}
for solved_test in solved_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)
@login_required
def solvedTestsDetailed(request, test_id):
context = {}
solved_tests = SolvedTest.objects.filter(test__id=test_id)
formatted_tests = list() formatted_tests = list()
for solved_test in solved_tests: for solved_test in solved_tests:
formatted_tests.append({ formatted_tests.append({
"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['name'] = solved_tests[0].test.name_and_passing_score()["name"]
context['tests'] = formatted_tests context['tests'] = formatted_tests
return render(request, 'solvedTests.html', context) return render(request, 'solvedTestsDetailed.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')
class EditTestTemplateView(TemplateView): class EditTestTemplateView(TemplateView):
@ -253,12 +277,12 @@ class EditQuestionTemplateView(TemplateView):
Question.objects.EditQuestion(question_id=question_id, name=description, answers=answers) Question.objects.EditQuestion(question_id=question_id, name=description, answers=answers)
return redirect(f'/tests/{test}/edit') return redirect(f'/tests/{test}/edit')
@login_required
def deleteTest(request, test_id): def deleteTest(request, test_id):
Test.objects.filter(id=test_id).delete() Test.objects.filter(id=test_id).delete()
return redirect('myTests') return redirect('myTests')
@login_required
def editVisible(request, test_id): def editVisible(request, test_id):
new_visible = request.GET["visible"] new_visible = request.GET["visible"]
if new_visible == "public": if new_visible == "public":
@ -270,6 +294,7 @@ def editVisible(request, test_id):
test.save() test.save()
return redirect(f'/tests/{test_id}/edit') return redirect(f'/tests/{test_id}/edit')
@login_required
def editName(request, test_id): def editName(request, test_id):
new_name = request.GET["name"] new_name = request.GET["name"]
test = Test.objects.get(id=test_id) test = Test.objects.get(id=test_id)
@ -277,7 +302,7 @@ def editName(request, test_id):
test.save() test.save()
return redirect(f'/tests/{test_id}/edit') return redirect(f'/tests/{test_id}/edit')
@login_required
def editPassword(request, test_id): def editPassword(request, test_id):
new_password = request.GET["password"] new_password = request.GET["password"]
test = Test.objects.get(id=test_id) test = Test.objects.get(id=test_id)
@ -285,6 +310,17 @@ def editPassword(request, test_id):
test.save() test.save()
return redirect(f'/tests/{test_id}/edit') return redirect(f'/tests/{test_id}/edit')
@login_required
def rateTest(request, test_id):
test = Test.objects.get(id=test_id)
rate = request.GET["rate"]
test.rates_amount += 1
test.total_rating += int(rate)
avg_rating = test.total_rating / test.rates_amount
test.avg_rating = int(avg_rating)
test.save()
return redirect(f'/tests/{test_id}/result')
class TestModelViewSet(viewsets.ModelViewSet): class TestModelViewSet(viewsets.ModelViewSet):
queryset = Test.objects.all() queryset = Test.objects.all()
@ -317,8 +353,8 @@ class TestTemplateView(TemplateView):
def get_score(self, test: Test, answers): def get_score(self, test: Test, answers):
return test.get_score(answers) return test.get_score(answers)
def get_maxscore(self, test: Test, answers): def get_maxscore(self, test: Test):
return test.get_maxscore(answers) return test.get_maxscore()
def formatted_responses(self, unformatted_json): def formatted_responses(self, unformatted_json):
formatted_response = list() formatted_response = list()
@ -334,16 +370,22 @@ class TestTemplateView(TemplateView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
test = Test.objects.get(id=kwargs.get("test_id")) test = Test.objects.get(id=kwargs.get("test_id"))
score = self.get_score(test, self.formatted_responses(request.POST)) score = self.get_score(test, self.formatted_responses(request.POST))
max = self.get_maxscore(test, self.formatted_responses(request.POST)) max = self.get_maxscore(test)
status = score >= test.passing_score status = score >= test.passing_score
context = { # context = {
"status": self.PASSED.get(status, self.UNKNOWN), # "status": self.PASSED.get(status, self.UNKNOWN),
"points": score, # "points": score,
"max": max, # "max": max,
"passing": test.passing_score, # "passing": test.passing_score,
"percentage": int(score / max * 100), # "percentage": int(score / max * 100),
"password": test.password # "password": test.password
} # }
request.session["status"] = self.PASSED.get(status, self.UNKNOWN)
request.session["points"] = score
request.session["max"] = max
request.session["passing"] = test.passing_score
request.session["percentage"] = int(score / max * 100)
request.session["password"] = test.password
SolvedTest.objects.create( SolvedTest.objects.create(
score=score, score=score,
max=max, max=max,
@ -351,11 +393,25 @@ class TestTemplateView(TemplateView):
user=request.user, user=request.user,
test=test test=test
) )
template_name = "result.html" test.completions += 1
template = get_template(template_name) test.total_percentage_scored_by_users += int(score / max * 100)
return HttpResponse(template.render(context, request)) if test.completions >= 5:
test.avg_difficulty = float(test.total_percentage_scored_by_users) / float(test.completions)
if test.avg_difficulty > 90.0:
test.difficulty_label = 1
elif test.avg_difficulty > 75.0:
test.difficulty_label = 2
elif test.avg_difficulty > 50.0:
test.difficulty_label = 3
elif test.avg_difficulty > 25.0:
test.difficulty_label = 4
else:
test.difficulty_label = 5
test.save()
return HttpResponseRedirect(f'result')
@login_required
def TestPasswordTemplateView(request, test_id): def TestPasswordTemplateView(request, test_id):
test = Test.objects.get(id=test_id) test = Test.objects.get(id=test_id)
if test.password == "": if test.password == "":
@ -366,6 +422,7 @@ def TestPasswordTemplateView(request, test_id):
return render(request, 'testPassword.html') return render(request, 'testPassword.html')
@login_required
def testView(request): def testView(request):
permission_classes = [] permission_classes = []
template_name = settings.BASE_DIR + f"/templates/generic_test.html" template_name = settings.BASE_DIR + f"/templates/generic_test.html"

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-05-15 21:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0004_alter_user_is_active'),
]
operations = [
migrations.AddField(
model_name='user',
name='type',
field=models.CharField(choices=[('admin', 'admin'), ('standard', 'standard')], default='standard', max_length=100),
),
]

View File

@ -5,6 +5,15 @@ from .managers import UserManager
class User(AbstractBaseUser): class User(AbstractBaseUser):
ADMIN = "admin"
STANDARD = "standard"
USER_TYPES = (
("admin", ADMIN),
("standard", STANDARD),
)
first_name = models.CharField(max_length=100) first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100)
@ -14,6 +23,7 @@ class User(AbstractBaseUser):
confirmation_number = models.CharField(max_length=100) confirmation_number = models.CharField(max_length=100)
reset_code = models.IntegerField(null=True) reset_code = models.IntegerField(null=True)
avatar = models.ImageField(upload_to="avatars/", null=True) avatar = models.ImageField(upload_to="avatars/", null=True)
type = models.CharField(choices=USER_TYPES, default=STANDARD, max_length=100)
USERNAME_FIELD = "email" USERNAME_FIELD = "email"

View File

@ -90,7 +90,8 @@ def register(request):
email=form.cleaned_data["email"], email=form.cleaned_data["email"],
first_name=form.cleaned_data["first_name"], first_name=form.cleaned_data["first_name"],
last_name=form.cleaned_data["last_name"], last_name=form.cleaned_data["last_name"],
password=form.cleaned_data["password1"] password=form.cleaned_data["password1"],
type="standard"
) )
return redirect('register_success') return redirect('register_success')
else: else: