diff --git a/DjangoQuiz/__pycache__/__init__.cpython-310.pyc b/DjangoQuiz/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..3797ef2 Binary files /dev/null and b/DjangoQuiz/__pycache__/__init__.cpython-310.pyc differ diff --git a/DjangoQuiz/__pycache__/settings.cpython-310.pyc b/DjangoQuiz/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..1e7338a Binary files /dev/null and b/DjangoQuiz/__pycache__/settings.cpython-310.pyc differ diff --git a/DjangoQuiz/__pycache__/urls.cpython-310.pyc b/DjangoQuiz/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..62d26d7 Binary files /dev/null and b/DjangoQuiz/__pycache__/urls.cpython-310.pyc differ diff --git a/DjangoQuiz/__pycache__/wsgi.cpython-310.pyc b/DjangoQuiz/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..d1bd207 Binary files /dev/null and b/DjangoQuiz/__pycache__/wsgi.cpython-310.pyc differ diff --git a/DjangoQuiz/settings.py b/DjangoQuiz/settings.py index cf47e1b..2fe121d 100644 --- a/DjangoQuiz/settings.py +++ b/DjangoQuiz/settings.py @@ -10,7 +10,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ -from pathlib import Path +from pathlib import Path,os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -121,4 +121,5 @@ STATIC_ROOT = '' STATIC_URL = '/static/' -STATICFILES_DIRS=[BASE_DIR/'static'] \ No newline at end of file +# STATICFILES_DIRS=[BASE_DIR/'static'] +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),] \ No newline at end of file diff --git a/DjangoQuiz/urls.py b/DjangoQuiz/urls.py index 94bdc65..30322df 100644 --- a/DjangoQuiz/urls.py +++ b/DjangoQuiz/urls.py @@ -22,9 +22,11 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('', home,name='home'), + path('', home, name='home'), path('addQuestion/', addQuestion,name='addQuestion'), path('question/', question,name='question'), + path('makevisitor/', makevisitor, name='makevisitor'), + path('visitor/', visitor, name='visitor'), #path('login/', login,name="login"), #path('logout', logout, name='logout'), #path('signup/',signup, name="signup"), diff --git a/Quiz/__pycache__/__init__.cpython-310.pyc b/Quiz/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..57fab14 Binary files /dev/null and b/Quiz/__pycache__/__init__.cpython-310.pyc differ diff --git a/Quiz/__pycache__/admin.cpython-310.pyc b/Quiz/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..cb6a4c1 Binary files /dev/null and b/Quiz/__pycache__/admin.cpython-310.pyc differ diff --git a/Quiz/__pycache__/apps.cpython-310.pyc b/Quiz/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..21c3064 Binary files /dev/null and b/Quiz/__pycache__/apps.cpython-310.pyc differ diff --git a/Quiz/__pycache__/forms.cpython-310.pyc b/Quiz/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..b25a825 Binary files /dev/null and b/Quiz/__pycache__/forms.cpython-310.pyc differ diff --git a/Quiz/__pycache__/models.cpython-310.pyc b/Quiz/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..5a6f28b Binary files /dev/null and b/Quiz/__pycache__/models.cpython-310.pyc differ diff --git a/Quiz/__pycache__/views.cpython-310.pyc b/Quiz/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..2753bf8 Binary files /dev/null and b/Quiz/__pycache__/views.cpython-310.pyc differ diff --git a/Quiz/admin.py b/Quiz/admin.py index 7fa3496..322c102 100644 --- a/Quiz/admin.py +++ b/Quiz/admin.py @@ -3,3 +3,4 @@ # Register your models here. admin.site.register(QuesModel) +admin.site.register(Visitor) diff --git a/Quiz/migrations/0001_initial.py b/Quiz/migrations/0001_initial.py index 318b2e4..8101d68 100644 --- a/Quiz/migrations/0001_initial.py +++ b/Quiz/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.7 on 2023-02-24 23:02 +# Generated by Django 4.1.7 on 2023-02-25 08:26 from django.conf import settings from django.db import migrations, models @@ -11,9 +11,20 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('auth', '0012_alter_user_first_name_max_length'), ] operations = [ + migrations.CreateModel( + name='Visitor', + fields=[ + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), + ('name', models.CharField(max_length=200, null=True)), + ('gender', models.CharField(max_length=200, null=True)), + ('date', models.CharField(max_length=200, null=True)), + ('score', models.PositiveIntegerField(default=0, null=True)), + ], + ), migrations.CreateModel( name='QuesModel', fields=[ @@ -25,7 +36,6 @@ class Migration(migrations.Migration): ('question5', models.CharField(max_length=200, null=True)), ('question6', models.CharField(max_length=200, null=True)), ('question7', models.CharField(max_length=200, null=True)), - ('question8', models.CharField(max_length=200, null=True)), ('ans', models.CharField(max_length=200, null=True)), ('ans2', models.CharField(max_length=200, null=True)), ('ans3', models.CharField(max_length=200, null=True)), @@ -33,7 +43,6 @@ class Migration(migrations.Migration): ('ans5', models.CharField(max_length=200, null=True)), ('ans6', models.CharField(max_length=200, null=True)), ('ans7', models.CharField(max_length=200, null=True)), - ('ans8', models.CharField(max_length=200, null=True)), ('writer', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), diff --git a/Quiz/migrations/__pycache__/0001_initial.cpython-310.pyc b/Quiz/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..051e5d2 Binary files /dev/null and b/Quiz/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/Quiz/migrations/__pycache__/0001_initial.cpython-311.pyc b/Quiz/migrations/__pycache__/0001_initial.cpython-311.pyc deleted file mode 100644 index 852a927..0000000 Binary files a/Quiz/migrations/__pycache__/0001_initial.cpython-311.pyc and /dev/null differ diff --git a/Quiz/migrations/__pycache__/__init__.cpython-310.pyc b/Quiz/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..5c9307a Binary files /dev/null and b/Quiz/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/Quiz/models.py b/Quiz/models.py index b327022..ffe6b66 100644 --- a/Quiz/models.py +++ b/Quiz/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.auth.models import User +from django.conf import settings # Create your models here. class QuesModel(models.Model): @@ -26,4 +27,11 @@ class QuesModel(models.Model): ans7 = models.CharField(max_length=200,null=True) # ans8 = models.CharField(max_length=200,null=True) +class Visitor(models.Model): + user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, primary_key=True) + name = models.CharField(max_length=200,null=True) + gender = models.CharField(max_length=200,null=True) + date = models.CharField(max_length=200,null=True) + score = models.PositiveIntegerField(default=0, null=True) + diff --git a/Quiz/templates/Quiz/addVisitor.html b/Quiz/templates/Quiz/addVisitor.html new file mode 100644 index 0000000..db95aec --- /dev/null +++ b/Quiz/templates/Quiz/addVisitor.html @@ -0,0 +1,16 @@ +
+ +
+ {%csrf_token%} + + +

이름 :

+

성별 : + + +

+

우리가 처음 만난날은? :

+ +
+ +
\ No newline at end of file diff --git a/Quiz/templates/Quiz/createQuizSlider.html b/Quiz/templates/Quiz/createQuizSlider.html index 488bb84..f352aff 100644 --- a/Quiz/templates/Quiz/createQuizSlider.html +++ b/Quiz/templates/Quiz/createQuizSlider.html @@ -1,160 +1,164 @@ + {% load static %} createQuizSlider - +
-
+ + {% csrf_token %} + {% for q in questions %}

Q1

- +

{{q.question}}

- +
- +
- +

Q2

- +

{{q.question2}}

- +
- +
- - + +

Q3

- +

{{q.question3}}

- +
- +
- - + +

Q4

- +

{{q.question4}}

- +
- +
- - + +

Q5

- +

{{q.question5}}

- +
- +
- - + +

Q6

- +

{{q.question6}}

- +
- +
- - + +
-
+ {% comment %}

Q7

- +

{{q.question7}}

- +
- - + {% endcomment %} + {% comment %}
- - + +
-
+
{% endcomment %}
-

Q8

- +

Q7

+

{{q.question7}}

- +
- +
- +
+ {% endfor %}
diff --git a/Quiz/templates/Quiz/makequiz.html b/Quiz/templates/Quiz/makequiz.html new file mode 100644 index 0000000..23fab0b --- /dev/null +++ b/Quiz/templates/Quiz/makequiz.html @@ -0,0 +1,163 @@ + + + {% load static %} + + + + createQuizSlider + + + + +
+
+ {% csrf_token %} +
+
+

Q1

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q2

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q3

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q4

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q5

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q6

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q7

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Q8

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + \ No newline at end of file diff --git a/Quiz/templates/Quiz/result.html b/Quiz/templates/Quiz/result.html index 0d83104..7114de3 100644 --- a/Quiz/templates/Quiz/result.html +++ b/Quiz/templates/Quiz/result.html @@ -1,25 +1,37 @@ -{% extends 'Quiz/dependencies.html' %} + -{% block content %} - -
- -
-
- Card image cap -
-
Score: {{score}}
- -

Percentage: {{percent}}%

-

Time Taken: {{time}} seconds

-

Correct answers: {{correct}}

-

Incorrect answers: {{wrong}}

-

Total questions: {{total}}

-
All the best for next quiz!
+
+
+ +
+
+ Card image cap +
+ + + + {% for v in visitors %} +

+ +
+ {{v.name}} : {{v.score}}점
+ +

+ {% endfor %} + +

+
+
- -
- -{% endblock %} \ No newline at end of file + \ No newline at end of file diff --git a/Quiz/templates/Quiz/startquiz.html b/Quiz/templates/Quiz/startquiz.html index 51db122..a8696bb 100644 --- a/Quiz/templates/Quiz/startquiz.html +++ b/Quiz/templates/Quiz/startquiz.html @@ -11,7 +11,7 @@

Q0

-
+ diff --git a/Quiz/views.py b/Quiz/views.py index da7e1ce..5a16684 100644 --- a/Quiz/views.py +++ b/Quiz/views.py @@ -1,13 +1,13 @@ -from django.shortcuts import redirect,render +from django.shortcuts import get_object_or_404, redirect,render from django.contrib.auth import login,logout,authenticate from .forms import * from .models import * - +from django.contrib.auth.models import User from django.forms import formset_factory # Create your views here. def home(request): - request.user + if request.method == 'POST': print(request.POST) questions=QuesModel.objects.all() @@ -70,33 +70,79 @@ def home(request): wrong+=1 # 여기에 랭킹과 나무를 띄워야함 - percent = score/(total*10) *100 + #percent = score/(total*10) *100 context = { + #'user':user, 'score':score, - 'time': request.POST.get('timer'), + #'time': request.POST.get('timer'), 'correct':correct, - 'wrong':wrong, - 'percent':percent, + #'wrong':wrong, + #'percent':percent, 'total':total, } + current_visitor = request.user + print(current_visitor.id) + visitor = Visitor.objects.all() + current_visitor = get_object_or_404(User, pk=current_visitor.id) + for visit in visitor: + if visit.user == current_visitor: + visit.score = score + visit.save() + + context = { + 'score':score, + 'visitors':visitor + } + + + #current_visitor.score = score + + # # visitor = get_object_or_404(Visitor, pk=id) + # visitor = Visitor.objects.all() + # current_visitor = Visitor.objects.filter(pk=request.user) + # #user = User.objects.all() + # context = { + # 'score':score, + # 'correct':correct, + # #'users':user, + # 'visitors':visitor, + # } + # current_visitor.score = score + # current_visitor.save() return render(request,'Quiz/result.html',context) + else: questions=QuesModel.objects.all() context = { 'questions':questions } - return render(request,'Quiz/home.html',context) + return render(request,'Quiz/createQuizSlider.html',context) + + +def makevisitor(request) : + return render(request,'Quiz/addVisitor.html') + +# 이름, 성별, 관계, 점수 +def visitor(request) : + new_visitor = Visitor() + new_visitor.name = request.POST['name'] + new_visitor.gender = request.POST['gender'] + new_visitor.date = request.POST['date'] + #new_visitor.score = request.POST['score'] + + new_visitor.save() + + return redirect('home') - # # 문제만들기 def addQuestion(request) : - return render(request, 'Quiz/addQuestion.html') + return render(request, 'Quiz/makequiz.html') def question(request): new_question = QuesModel() - new_question.writer = request.user + # new_question.writer = request.user #new_question.op1 = request.POST['op1'] #new_question.op2 = request.POST['op2'] new_question.ans = request.POST['ans'] diff --git a/account/__pycache__/__init__.cpython-310.pyc b/account/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..014e25e Binary files /dev/null and b/account/__pycache__/__init__.cpython-310.pyc differ diff --git a/account/__pycache__/admin.cpython-310.pyc b/account/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..94ff5cb Binary files /dev/null and b/account/__pycache__/admin.cpython-310.pyc differ diff --git a/account/__pycache__/apps.cpython-310.pyc b/account/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..cd2c6a6 Binary files /dev/null and b/account/__pycache__/apps.cpython-310.pyc differ diff --git a/account/__pycache__/forms.cpython-310.pyc b/account/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..790e2b3 Binary files /dev/null and b/account/__pycache__/forms.cpython-310.pyc differ diff --git a/account/__pycache__/models.cpython-310.pyc b/account/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..f67c0f5 Binary files /dev/null and b/account/__pycache__/models.cpython-310.pyc differ diff --git a/account/__pycache__/urls.cpython-310.pyc b/account/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..96a434c Binary files /dev/null and b/account/__pycache__/urls.cpython-310.pyc differ diff --git a/account/__pycache__/views.cpython-310.pyc b/account/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..1709caf Binary files /dev/null and b/account/__pycache__/views.cpython-310.pyc differ diff --git a/account/migrations/__pycache__/__init__.cpython-310.pyc b/account/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..cdd9334 Binary files /dev/null and b/account/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/db.sqlite3 b/db.sqlite3 index 2bdb198..d6eb680 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/Quiz/css/style.css b/static/css/style.css similarity index 100% rename from Quiz/css/style.css rename to static/css/style.css diff --git a/Quiz/img/Vector.png b/static/img/Vector.png similarity index 100% rename from Quiz/img/Vector.png rename to static/img/Vector.png diff --git a/Quiz/img/back.png b/static/img/back.png similarity index 100% rename from Quiz/img/back.png rename to static/img/back.png diff --git a/Quiz/img/candy-cane.png b/static/img/candy-cane.png similarity index 100% rename from Quiz/img/candy-cane.png rename to static/img/candy-cane.png diff --git a/Quiz/img/candy.png b/static/img/candy.png similarity index 100% rename from Quiz/img/candy.png rename to static/img/candy.png diff --git a/Quiz/img/false.png b/static/img/false.png similarity index 100% rename from Quiz/img/false.png rename to static/img/false.png diff --git a/Quiz/img/next.png b/static/img/next.png similarity index 100% rename from Quiz/img/next.png rename to static/img/next.png diff --git a/Quiz/img/true.png b/static/img/true.png similarity index 100% rename from Quiz/img/true.png rename to static/img/true.png

이름