From 590b71eb927a0c04b2b76538d60142701b5bf2b6 Mon Sep 17 00:00:00 2001 From: vale981 Date: Sun, 13 Apr 2014 10:33:29 +0200 Subject: [PATCH] init* --- .idea/encodings.xml | 4 +- db.sqlite3 | Bin 40960 -> 50176 bytes fahrschule_vale981/urls.py | 5 +- fs_quiz/admin.py | 3 +- fs_quiz/forms.py | 2 + fs_quiz/models.py | 49 ++++++++++++-- fs_quiz/urls.py | 1 + fs_quiz/views.py | 42 ++++++++++-- static/css/quizz.css | 131 +++++++++++++++++++------------------ templates/fehler.html | 6 ++ templates/login.html | 14 ++++ templates/quiz.html | 30 ++++++++- templates/quizzes.html | 90 ++++++++++++++++--------- 13 files changed, 267 insertions(+), 110 deletions(-) create mode 100644 fs_quiz/forms.py create mode 100644 templates/fehler.html create mode 100644 templates/login.html diff --git a/.idea/encodings.xml b/.idea/encodings.xml index e206d70..0218f4c 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,5 +1,7 @@ - + + + diff --git a/db.sqlite3 b/db.sqlite3 index e33b79f68959fa4a107421474b0e1259b56bd1e7..de1dab1990a306283a0345d16f84e0673b418b6c 100644 GIT binary patch delta 3917 zcmb_eYj6|S72dl?va~XWIADw|z(O_{gAuzcX?G=(5Lvdd0o&Nf$kLP;NxQNhYpp8@ z%XT|;L^9KcBu&ib51q8-2Q&OEuG3~xnh7(sooPF1rkTt%$<)a-nV}CTkG4tEz;t?7 zYq@?kok$*bg(-+~vd)h`hQ!Qfx{**eqeYoJ%u7)*vLj8*6q0Y8Ts=maDA zI{6}bigc3{nn$moXVIzI;$vvKrHUea6xvWjRk1YV+DE(gF|3Vcye#Xb1&7_6a(EcV?PMsntFO88e-Rn4n{jZwOArK#=}PXgOzX_rl_pu* z%eWob9>ennwoA$8@_VSYxHRu|xx7x7gX372M=(1R5m{DR%sO}Jsu*om45qUV#w9Qu zZDw;5(-RSgN#`~!@j>Uhy)^Ie2%Lvz%uFznvyDiJ{K35yI=^le-|2PJ4&K8H0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?;Tt_w(0a7AcE}%m#@};TnHrP3#&VItXZ^l#a4PWhcDL`779=+> z^PDVe(R6a+fwaf#k=>%&CCIYL62l!t4WaUW`_Is1hX%(6%DkWzoj}wsG6m)$e7Iov z%5Qd`2J&&x-)N@o;6ktlpTqlb9

6kAQ30r~%^gukN=)0>MrA60X9hZ~+ofgx8mi z=YS*z&(oKvM^L|PRKctf$JRjUMc=rPoqRbv*)^7((DMaV(^M@dMs;4#C#86CDjzP6 zc!qlWW+J^q<6+@wGF%)GBf;?WP&zC`Qjv5d6_^eO2a1tYUokS;uSfjDsX*_fJfN$I zXlOVS^1M)tgpQupMxRd}Pxa-t;%AQ!xhA;#Pe>)P*?0Pc0>>$mviU|Uw9&M2UxU&D z0mq}bZb%gA2I$MLwg^d^~CSI$qJZOH+z!?NfaE6{y zgxNO6f;y!j9qye%jqXsOIrwh6hOh<2{g2eO6>}eOBqXdg#{egYC4PQz;q0N!(pOr$c3oA zhb8<86Jq{^SIm;T7P*pCa1%MQSVu0TD#@*+y?i+J6()D*zQfIAz0^o<8Y%LP!IJKh zoy?V5&*~ORXBE*OCd!3wJJ$(EtDd diff --git a/fahrschule_vale981/urls.py b/fahrschule_vale981/urls.py index d73d277..aab4292 100644 --- a/fahrschule_vale981/urls.py +++ b/fahrschule_vale981/urls.py @@ -7,7 +7,10 @@ urlpatterns = patterns('', # Examples: (r'^quiz/', include('fs_quiz.urls')), # url(r'^blog/', include('blog.urls')), - + (r'^login/', 'fahrschule_vale981.views.login'), + (r'^logout/', 'fahrschule_vale981.views.logout_view'), + (r'^auth/', 'fahrschule_vale981.views.auth_view'), + (r'^fehler/', 'fahrschule_vale981.views.error'), url(r'^admin/', include(admin.site.urls)), ) diff --git a/fs_quiz/admin.py b/fs_quiz/admin.py index 25105a1..327ee73 100644 --- a/fs_quiz/admin.py +++ b/fs_quiz/admin.py @@ -3,4 +3,5 @@ from django.contrib import admin # Register your models here. from fs_quiz.models import * admin.site.register(Frage) -admin.site.register(Quiz) \ No newline at end of file +admin.site.register(Quiz) +admin.site.register(Antwort) \ No newline at end of file diff --git a/fs_quiz/forms.py b/fs_quiz/forms.py new file mode 100644 index 0000000..fa3738b --- /dev/null +++ b/fs_quiz/forms.py @@ -0,0 +1,2 @@ +from django import forms +from fs_quiz.models import * diff --git a/fs_quiz/models.py b/fs_quiz/models.py index ed621b5..9a4f131 100644 --- a/fs_quiz/models.py +++ b/fs_quiz/models.py @@ -1,19 +1,23 @@ from django.db import models +from django.contrib.auth.models import User -# Create your models here. class Quiz(models.Model) : title = models.CharField(max_length=60, blank=False, + verbose_name="Titel" ) description = models.TextField(blank=True, - help_text="a description of the quiz", + help_text="Die Beschreibung des Quiz", + verbose_name="Beschreibung" ) class Admin: pass def __unicode__(self): return self.title + def __str__(self): # __unicode__ on Python 2 + return self.title class Frage(models.Model): @@ -21,14 +25,51 @@ class Frage(models.Model): content = models.CharField(max_length=1000, blank=False, - help_text="Enter the question text that you want displayed", - verbose_name='Question', + verbose_name='Frage Text', ) + + + class Admin: pass def __unicode__(self): return self.content + def __str__(self): # __unicode__ on Python 2 + return self.content +class Antwort(models.Model): + frage = models.ManyToManyField(Frage, blank=False, ) + + content = models.CharField(max_length=1000, + blank=False, + help_text="Text der Antwort", + verbose_name='Antwort Text', + ) + + richtig = models.BooleanField(blank=True) + + def __unicode__(self): + return self.content + def __str__(self): # __unicode__ on Python 2 + return self.content + + def get_related_to(self, status): + return self.related_to.filter( + from_people__status=status, + from_people__to_person=self) + + class Admin: + pass + + + + +class Results: + quiz=models.ManyToManyField(Quiz, blank=True, ) + frage=models.ManyToManyField(User, blank=True, ) + user=models.ManyToManyField(User, blank=True, ) + richtig = models.BooleanField(blank=True) + choice = models.ManyToManyField(Antwort) \ No newline at end of file diff --git a/fs_quiz/urls.py b/fs_quiz/urls.py index 9254f06..0a2a79d 100644 --- a/fs_quiz/urls.py +++ b/fs_quiz/urls.py @@ -6,5 +6,6 @@ urlpatterns = patterns('', url(r'^all/', 'fs_quiz.views.quizes', name='home'), url(r'^get/(?P\d+)$', 'fs_quiz.views.quiz', name='home'), + url(r'^check/', 'fs_quiz.views.check_view', name='check'), ) diff --git a/fs_quiz/views.py b/fs_quiz/views.py index 6678ff3..d02c6a3 100644 --- a/fs_quiz/views.py +++ b/fs_quiz/views.py @@ -1,9 +1,14 @@ from django.shortcuts import render_to_response -#from django.http import HttpResponse +from django.http import HttpResponseRedirect #from django.template.loader import get_template #from django.template import Context #from django.views.generic.base import TemplateView +from django.core.context_processors import csrf from fs_quiz.models import * +from fs_quiz.forms import * +from fs_quiz.forms import Results +from django.forms.models import modelformset_factory +from django.contrib import auth def quizes(request): @@ -15,9 +20,21 @@ def quizes(request): return render_to_response('quizzes.html', {'quizes': Quiz.objects.all(), 'hg': height, - 'hg_m': height_menu}) + 'hg_m': height_menu, + 'user': request.user}) def quiz(request, quiz_id=1): + cs = {} + cs.update(csrf(request)) + + # AuthorFormSet = modelformset_factory(Results, form=ResultForm) + # if request.method == 'POST': + # formset = AuthorFormSet(request.POST, request.FILES) + # if formset.is_valid(): + # formset.save() + # # do something. + # else: + # formset = AuthorFormSet(queryset=Frage.objects.filter(quiz=quiz_id)) height=75*Frage.objects.count() height_menu = height + 10 @@ -26,11 +43,24 @@ def quiz(request, quiz_id=1): height_menu = height len_quiz = len(Quiz.objects.get(id=quiz_id).title) - - return render_to_response('quiz.html', - {'quiz': Quiz.objects.get(id=quiz_id), + cs.update({'quiz': Quiz.objects.get(id=quiz_id), 'Frage': Frage.objects.filter(quiz=quiz_id), 'len': len_quiz, 'hg': height, - 'hg_m': height_menu}) + 'hg_m': height_menu, + 'user': request.user, + 'aw': Antwort.objects.all()}) + return render_to_response('quiz.html', cs) + +def check_view(request): + check = request.POST.get('aw_check', '') + user = request.POST.get('user_log', '') + frage = request.POST.get('frage', '') + antwort = request.POST.get('antwort', '') + richtig = request.POST.get('richtig', '') + quiz_get = request.POST.get('quiz', '') + res = Results(quiz=quiz_get, frage=frage, user=user, richtig=richtig, choice=check) + res.save() + return HttpResponseRedirect('/quiz/all/') + diff --git a/static/css/quizz.css b/static/css/quizz.css index 3cade20..ff01465 100644 --- a/static/css/quizz.css +++ b/static/css/quizz.css @@ -1,68 +1,75 @@ +body{ +margin: 0; +padding: 0; +border: 0; +overflow: hidden; +height: 100%; +max-height: 100%; +} -#main{ - position: relative; - float:right; - left: 100px; +#framecontent{ +position: absolute; +top: 0; +bottom: 0; +left: 0; +width: 150px; /*Width of frame div*/ +height: 100%; +overflow: hidden; /*Disable scrollbars. Set to "scroll" to enable*/ +background: navy; +color: white; +} + +#maincontent{ +position: fixed; +top: 0; +left: 150px; /*Set left value to WidthOfFrameDiv*/ +right: 0; +bottom: 0; +overflow: auto; +background: #fff; +} + +.innertube{ +margin: 15px; /*Margins for inner DIV inside each DIV (to provide padding)*/ + +} + +.men_div:hover{ + + background-color: dodgerblue; +} + +* html body{ /*IE6 hack*/ +padding: 0 0 0 200px; /*Set value to (0 0 0 WidthOfFrameDiv)*/ +} + +* html #maincontent{ /*IE6 hack*/ +height: 100%; +width: 100%; +} + +#men{ + font-family: 'Denk One', sans-serif; + font-size: 24px; + color: lightgrey; + margin-left: 15px; +} +#men:link {color:white; text-decoration:none;} /* unvisited link */ +#men:visited {color: #ffffff;} /* visited link */ +#men:hover {color:white;} /* mouse over link */ +#main_link{ + font-family: "Denk One"; + color: dodgerblue; + text-decoration: none; + font-size: 20px; } #main_content{ - margin-top: -10px; - position: relative; - left:10px; - top: -10px; - width:96%; + margin-top: -3.4%; } - -#main_link{ - line-height:150%; - font-family: Calibri; - font-size: 15px; - text-decoration: none; - color: #0066CC; - font-family: Futura, "Trebuchet MS", Arial, sans-serif; - widht: 81.9%; -} -#main_link:hover{ +#frage{ + font-family: "Tauri"; + color: dodgerblue; text-decoration: underline; - color: #0099FF; -} + font-size: 20px; -.mainHead{ - - text-align: center; - background-color: #0099FF; - width:100%; - font-size:30px; - margin-top:0px; - - font-family: Futura, "Trebuchet MS", Arial, sans-serif; - -} - -#menu{ - position: absolute; - float:right; - - -} - -#men:hover{ - background-color: #0066CC; - text-decoration: none; -} -#men{ - margin-left:-40px; - width: 100px; - text-align: center; -} - - -body{ - width: 60%; - position: absolute; - left: 21.6%; - box-shadow: 0px 0px 10px black; - background-color: hsla(30,40%,90%,0.5); -} - #title_20{ - font-size: 10px; - } \ No newline at end of file +} \ No newline at end of file diff --git a/templates/fehler.html b/templates/fehler.html new file mode 100644 index 0000000..9c2a779 --- /dev/null +++ b/templates/fehler.html @@ -0,0 +1,6 @@ +{% extends 'quizzes.html' %} +{% block main %} + +

Fehler, bitte versuchen sie es nochmal!

+ +{% endblock %} \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..9519bed --- /dev/null +++ b/templates/login.html @@ -0,0 +1,14 @@ +{% extends 'quizzes.html' %} +{% block content %} + {% if form.errors %} +

Benutzernahme oder Passwort falsch!

+ {% endif %} +
{% csrf_token %} + + + + + + +
+{% endblock %} \ No newline at end of file diff --git a/templates/quiz.html b/templates/quiz.html index 321c6d0..43c10c3 100644 --- a/templates/quiz.html +++ b/templates/quiz.html @@ -17,14 +17,38 @@ {% block main %} {% if Frage.count == 0 %}
-

Keine Fragen vorhanden!

+

Keine Fragen vorhanden!

{% endif %} -
+
    {% for Frage in Frage %} - {{Frage.content}}
    +
  1. {{Frage.content}}
  2. + {% comment %}
    + {{ formset }} +
    {% endcomment %} + {% for aw in aw %} + {% if aw.frage.get == Frage %} +
    {% csrf_token %} + + + + + + + + {% if aw.richtig %} + + {% else %} + + {% endif %} +
    + {% endif %} {% endfor %} + {% endfor %} + +
{% endblock %} + diff --git a/templates/quizzes.html b/templates/quizzes.html index 5b4b3d8..cc4c149 100644 --- a/templates/quizzes.html +++ b/templates/quizzes.html @@ -1,42 +1,63 @@ - - + + + + - Fahrschule Examiner 0.1 - + +Fahrschul examiner... + + + {% load staticfiles %} + -
- -
- {% block header %} - Quiz Übersicht - {% endblock %} -
+
+
{% block menu %} - + {% endif %} {% endblock %} +
+
-
- {% block main %} + +
+
+{% block content %} + {% if user.is_authenticated %} + {% block main %}
+
{% if quizes.count == 0 %}

Keine Fragebogen vorhanden!

@@ -49,15 +70,20 @@ {{ quiz.title }}
{{ quiz.description }}
- +
{% endfor %}
+ {% endblock %} -
+ {% else %} +

Sie sind nicht angemeldet! Bitte einloggen!

+ {% endif %} +{% endblock %}
- +
+ + + - \ No newline at end of file +