refactor project, added database

This commit is contained in:
tkupek 2016-01-31 16:17:37 +01:00
parent ef86dbc0f7
commit a0810b6c8d
23 changed files with 203 additions and 69 deletions

View file

@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/vcpby-elearning.iml" filepath="$PROJECT_DIR$/vcpby-elearning.iml" /> <module fileurl="file://$PROJECT_DIR$/tkupek-elearning.iml" filepath="$PROJECT_DIR$/tkupek-elearning.iml" />
</modules> </modules>
</component> </component>
</project> </project>

124
.idea/uiDesigner.xml Normal file
View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-20 22:54
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='questions',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('questionId', models.IntegerField()),
('questionTitle', models.CharField(max_length=100)),
('questionText', models.TextField()),
('questionAnswer', models.TextField()),
],
),
]

View file

@ -1,14 +0,0 @@
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class questions(models.Model):
questionId = models.IntegerField()
questionTitle = models.CharField(max_length=100)
questionText = models.TextField()
questionAnswer = models.TextField()

View file

@ -1,13 +0,0 @@
from django.shortcuts import render_to_response
# Create your views here.
def home(request):
content = {
'questionId': 1,
'questionTitle': 'titleOne',
'questionText': 'Lorem ipsum dolor sit amet'
}
return render_to_response('index.html', content)

Binary file not shown.

View file

@ -3,7 +3,7 @@ import os
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VCPBayern_eLearning.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tkupek_elearning.settings")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line

View file

@ -0,0 +1,5 @@
from django.contrib import admin
from tkupek_elearning.elearning.models import question
admin.site.register(question)

View file

@ -4,4 +4,4 @@ from django.apps import AppConfig
class ElearningConfig(AppConfig): class ElearningConfig(AppConfig):
name = 'eLearning' name = 'elearning'

View file

@ -0,0 +1,3 @@
INSERT INTO elearning_question (id, title, text, options, answer, explanation) VALUES (0, 'Bananen', 'Warum ist die Banane krumm?', 'eins zwei oder drei', 1, 'darum');
INSERT INTO elearning_question (id, title, text, options, answer, explanation) VALUES (1, 'Einstein', 'Wie lautet die Relativitätstheorie?', 'oben unten rechts links', 2, 'ich nehm die drei');
INSERT INTO elearning_question (id, title, text, options, answer, explanation) VALUES (2, 'Wetter', 'Wie wird das Wetter?', 'gut schlecht dramatisch', 3, 'darum');

View file

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-31 15:12
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='question',
fields=[
('id', models.IntegerField(primary_key=True, serialize=False)),
('title', models.CharField(max_length=100)),
('text', models.TextField()),
('options', models.TextField()),
('answer', models.IntegerField()),
('explanation', models.TextField()),
],
),
]

View file

@ -0,0 +1,12 @@
from __future__ import unicode_literals
from django.db import models
class question(models.Model):
id = models.IntegerField(primary_key=True)
title = models.CharField(max_length=100)
text = models.TextField()
options = models.TextField()
answer = models.IntegerField()
explanation = models.TextField()

View file

@ -13,8 +13,14 @@
<div class="container"> <div class="container">
<h1>VCP Bayern - eLearning</h1> <h1>VCP Bayern - eLearning</h1>
<h2>{{ questionTitle }}</h2>
<p>{{ questionText }}</p> {% for question in questions %}
<h2>{{ question.id }}: {{ question.title }}</h2>
<p>{{ question.text }}</p>
<p style="font-style:italic">{{ question.options }} : {{ question.answer }}</p>
<p>{{ question.explanation}}</p>
{% endfor %}
</div> </div>
</body> </body>

View file

@ -0,0 +1,3 @@
#from django.test import TestCase
# Create your tests here.

View file

@ -0,0 +1,9 @@
from django.shortcuts import render_to_response
from tkupek_elearning.elearning.models import question
def home(request):
questions = question.objects.all()
return render_to_response('index.html', {'questions': questions})

View file

@ -1,5 +1,5 @@
""" """
Django settings for VCPBayern_eLearning project. Django settings for tkupek_elearning project.
Generated by 'django-admin startproject' using Django 1.9.1. Generated by 'django-admin startproject' using Django 1.9.1.
@ -37,7 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'VCPBayern_eLearning.eLearning' 'tkupek_elearning.elearning'
] ]
MIDDLEWARE_CLASSES = [ MIDDLEWARE_CLASSES = [
@ -51,7 +51,7 @@ MIDDLEWARE_CLASSES = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
ROOT_URLCONF = 'VCPBayern_eLearning.urls' ROOT_URLCONF = 'tkupek_elearning.urls'
TEMPLATES = [ TEMPLATES = [
{ {
@ -69,7 +69,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = 'VCPBayern_eLearning.wsgi.application' WSGI_APPLICATION = 'tkupek_elearning.wsgi.application'
# Database # Database

View file

@ -1,4 +1,4 @@
"""VCPBayern_eLearning URL Configuration """tkupek_elearning URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.9/topics/http/urls/ https://docs.djangoproject.com/en/1.9/topics/http/urls/
@ -16,8 +16,9 @@ Including another URLconf
from django.conf.urls import url from django.conf.urls import url
from django.contrib import admin from django.contrib import admin
import tkupek_elearning.elearning.views
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'', 'VCPBayern_eLearning.eLearning.views.home', name='home') url(r'', tkupek_elearning.elearning.views.home)
] ]

View file

@ -1,5 +1,5 @@
""" """
WSGI config for VCPBayern_eLearning project. WSGI config for tkupek_elearning project.
It exposes the WSGI callable as a module-level variable named ``application``. It exposes the WSGI callable as a module-level variable named ``application``.
@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VCPBayern_eLearning.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tkupek_elearning.settings")
application = get_wsgi_application() application = get_wsgi_application()