mirror of
https://github.com/vale981/vale981_fahrschule
synced 2025-03-04 17:31:42 -05:00
init*
This commit is contained in:
parent
a7c5fb593b
commit
590b71eb92
13 changed files with 267 additions and 110 deletions
4
.idea/encodings.xml
generated
4
.idea/encodings.xml
generated
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
|
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -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)),
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
admin.site.register(Quiz)
|
||||
admin.site.register(Antwort)
|
2
fs_quiz/forms.py
Normal file
2
fs_quiz/forms.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
from django import forms
|
||||
from fs_quiz.models import *
|
|
@ -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)
|
|
@ -6,5 +6,6 @@ urlpatterns = patterns('',
|
|||
|
||||
url(r'^all/', 'fs_quiz.views.quizes', name='home'),
|
||||
url(r'^get/(?P<quiz_id>\d+)$', 'fs_quiz.views.quiz', name='home'),
|
||||
url(r'^check/', 'fs_quiz.views.check_view', name='check'),
|
||||
|
||||
)
|
||||
|
|
|
@ -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/')
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
6
templates/fehler.html
Normal file
6
templates/fehler.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends 'quizzes.html' %}
|
||||
{% block main %}
|
||||
|
||||
<p class="error">Fehler, bitte versuchen sie es nochmal! </p>
|
||||
|
||||
{% endblock %}
|
14
templates/login.html
Normal file
14
templates/login.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{% extends 'quizzes.html' %}
|
||||
{% block content %}
|
||||
{% if form.errors %}
|
||||
<p class="error">Benutzernahme oder Passwort falsch!</p>
|
||||
{% endif %}
|
||||
<form action="/auth/" method="post">{% csrf_token %}
|
||||
<label for="username">Benutzer:</label>
|
||||
<input type="text" name="username" value="" id="username">
|
||||
<label for="password">Passwort:</label>
|
||||
<input type="password" name="password" value="" id="password">
|
||||
<input type="submit" value="Login" />
|
||||
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -17,14 +17,38 @@
|
|||
{% block main %}
|
||||
{% if Frage.count == 0 %}
|
||||
<br>
|
||||
<h1 id="main_link" align="center">Keine Fragen vorhanden!</h1>
|
||||
<h1 id="main_link" style="text-align: center" align="center">Keine Fragen vorhanden!</h1>
|
||||
{% endif %}
|
||||
<br>
|
||||
<ol>
|
||||
{% for Frage in Frage %}
|
||||
{{Frage.content}}<br>
|
||||
<li><div id="frage">{{Frage.content}}</div></li>
|
||||
{% comment %}<form method="post" action="">
|
||||
{{ formset }}
|
||||
</form>{% endcomment %}
|
||||
{% for aw in aw %}
|
||||
{% if aw.frage.get == Frage %}
|
||||
<form action="/quiz/check/" method="post">{% csrf_token %}
|
||||
<label for="aw_check">{{ aw.content }}</label>
|
||||
<input type="checkbox" name="aw_check" id="aw_check">
|
||||
<input type="hidden" name="user_log" value="{{ user.get }}">
|
||||
<input type="hidden" name="frage" value="{{ Frage }}">
|
||||
<input type="hidden" name="antwort" value="{{ aw }}">
|
||||
<input type="hidden" name="quiz" value="{{ quiz }}">
|
||||
|
||||
{% if aw.richtig %}
|
||||
<input type="hidden" name="richtig" value=True>
|
||||
{% else %}
|
||||
<input type="hidden" name="richtig" value=False>
|
||||
{% endif %}
|
||||
<br><input type="submit" value="Abgeben" />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
</form></ol>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
</html>
|
||||
|
||||
|
|
|
@ -1,42 +1,63 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<!--Force IE6 into quirks mode with this comment tag-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>Fahrschule Examiner 0.1</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Fahrschul examiner...</title>
|
||||
<script type="text/javascript">
|
||||
WebFontConfig = {
|
||||
google: { families: [ 'Denk+One::latin', 'Tauri::latin', 'Vampiro+One::latin' ] }
|
||||
};
|
||||
(function() {
|
||||
var wf = document.createElement('script');
|
||||
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
|
||||
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
|
||||
wf.type = 'text/javascript';
|
||||
wf.async = 'true';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(wf, s);
|
||||
})(); </script>
|
||||
|
||||
|
||||
{% load staticfiles %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/quizz.css' %}"/>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div class="mainHead">
|
||||
{% block header %}
|
||||
Quiz Übersicht
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div id="framecontent">
|
||||
<div class="innertube_men">
|
||||
{% block menu %}
|
||||
<div id="menu" style="background-color:#0099FF;height:{{ hg_m }}px;width:16%;">
|
||||
<ul>
|
||||
<div id="men">
|
||||
<a href="/quiz/all">Übersicht</a>
|
||||
<div class="men_div" style="margin-top: 15px;">
|
||||
<a id="men" href="/quiz/all">Übersicht</a>
|
||||
</div>
|
||||
<div class="men_div">
|
||||
<a id="men" href="/admin">Admin</a>
|
||||
</div>
|
||||
{% if user.is_authenticated %}
|
||||
<div class="men_div">
|
||||
<a href="/logout/" id="men"> Logout</a>
|
||||
</div>
|
||||
<div id="men">
|
||||
<a href="/admin">Admin</a>
|
||||
{% else %}
|
||||
<div class="men_div">
|
||||
<a href="/login/" id="men"> Login</a>
|
||||
</div>
|
||||
<div id="men">
|
||||
|
||||
Login
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main" style="height:{{ hg }}px;float:left;">
|
||||
{% block main %}
|
||||
|
||||
<div id="maincontent">
|
||||
<div class="innertube">
|
||||
{% block content %}
|
||||
{% if user.is_authenticated %}
|
||||
{% block main %}
|
||||
<br>
|
||||
|
||||
<div id="main_content">
|
||||
{% if quizes.count == 0 %}
|
||||
<h1 id="main_link" align="center">Keine Fragebogen vorhanden!</h1>
|
||||
|
@ -49,15 +70,20 @@
|
|||
<a id="main_link" href="/quiz/get/{{ quiz.id }}">{{ quiz.title }}</a>
|
||||
<br>
|
||||
{{ quiz.description }}<br>
|
||||
</li>
|
||||
</li><br>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% else %}
|
||||
<h1 id="main_link" align="center">Sie sind nicht angemeldet! Bitte <a href="/login">einloggen!</a> </h1>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div id="footer" style="background-color:#0099FF;clear:both;text-align:center;">
|
||||
Copyright © Valentin Boettcher
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Reference in a new issue