created data model
This commit is contained in:
parent
bd0630bff6
commit
a6ec2d93d4
11 changed files with 110 additions and 14 deletions
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -1,5 +1,16 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from tkupek_elearning.elearning.models import question
|
from tkupek_elearning.elearning.models import Option, Setting, Question
|
||||||
|
|
||||||
admin.site.register(question)
|
|
||||||
|
class OptionInline(admin.TabularInline):
|
||||||
|
model = Option
|
||||||
|
|
||||||
|
|
||||||
|
class QuestionAdmin(admin.ModelAdmin):
|
||||||
|
inlines = [
|
||||||
|
OptionInline,
|
||||||
|
]
|
||||||
|
|
||||||
|
admin.site.register(Question, QuestionAdmin)
|
||||||
|
admin.site.register(Setting)
|
|
@ -1,3 +1,7 @@
|
||||||
|
#Settings
|
||||||
|
INSERT INTO elearning_setting (title, message, active) VALUES ('vcp bayern - elearning', 'servus beim elearning des vcp land bayern!', 1);
|
||||||
|
|
||||||
|
#Questions
|
||||||
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 (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 (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');
|
INSERT INTO elearning_question (id, title, text, options, answer, explanation) VALUES (2, 'Wetter', 'Wie wird das Wetter?', 'gut schlecht dramatisch', 3, 'darum');
|
49
tkupek_elearning/elearning/migrations/0001_initial.py
Normal file
49
tkupek_elearning/elearning/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.1 on 2016-01-31 17:13
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Option',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('text', models.CharField(max_length=100, null=True)),
|
||||||
|
('correct', models.BooleanField(default=False)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Question',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||||
|
('title', models.CharField(max_length=100, null=True)),
|
||||||
|
('text', models.TextField(null=True)),
|
||||||
|
('explanation', models.TextField(null=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Setting',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=100, null=True)),
|
||||||
|
('message', models.TextField(null=True)),
|
||||||
|
('footer', models.TextField(null=True)),
|
||||||
|
('active', models.BooleanField(default=False, unique=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='option',
|
||||||
|
name='question',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='elearning.Question'),
|
||||||
|
),
|
||||||
|
]
|
0
tkupek_elearning/elearning/migrations/__init__.py
Normal file
0
tkupek_elearning/elearning/migrations/__init__.py
Normal file
|
@ -2,11 +2,31 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
class question(models.Model):
|
|
||||||
|
|
||||||
id = models.IntegerField(primary_key=True)
|
class Setting(models.Model):
|
||||||
title = models.CharField(max_length=100)
|
title = models.CharField(max_length=100, null=True)
|
||||||
text = models.TextField()
|
message = models.TextField(null=True)
|
||||||
options = models.TextField()
|
footer = models.TextField(null=True)
|
||||||
answer = models.IntegerField()
|
active = models.BooleanField(unique=True, default=False)
|
||||||
explanation = models.TextField()
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
class Question(models.Model):
|
||||||
|
id = models.AutoField(primary_key=True)
|
||||||
|
title = models.CharField(max_length=100, null=True)
|
||||||
|
text = models.TextField(null=True)
|
||||||
|
explanation = models.TextField(null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
|
class Option(models.Model):
|
||||||
|
text = models.CharField(max_length=100, null=True)
|
||||||
|
correct = models.BooleanField(null=False, default=False)
|
||||||
|
question = models.ForeignKey(Question, on_delete=models.CASCADE, null=False)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.text
|
0
tkupek_elearning/elearning/templates/css/style.css
Normal file
0
tkupek_elearning/elearning/templates/css/style.css
Normal file
BIN
tkupek_elearning/elearning/templates/images/favicon.ico
Normal file
BIN
tkupek_elearning/elearning/templates/images/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
|
@ -12,7 +12,10 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>VCP Bayern - eLearning</h1>
|
<h1>{{ settings.title }}</h1>
|
||||||
|
<p>{{ settings.message }}</p>
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
{% for question in questions %}
|
{% for question in questions %}
|
||||||
<h2>{{ question.id }}: {{ question.title }}</h2>
|
<h2>{{ question.id }}: {{ question.title }}</h2>
|
||||||
|
@ -21,6 +24,10 @@
|
||||||
<p>{{ question.explanation}}</p>
|
<p>{{ question.explanation}}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<hr/>
|
||||||
|
{{ settings.footer }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
|
||||||
from tkupek_elearning.elearning.models import question
|
from tkupek_elearning.elearning.models import Setting, Question
|
||||||
|
|
||||||
|
#import pdb; pdb.set_trace()
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
|
|
||||||
questions = question.objects.all()
|
questions = Question.objects.all()
|
||||||
|
settings = Setting.objects.filter(active=1)
|
||||||
|
if(settings) :
|
||||||
|
settings = settings[0]
|
||||||
|
|
||||||
return render_to_response('index.html', {'questions': questions})
|
return render_to_response('index.html', {'settings': settings, 'questions': questions})
|
Loading…
Reference in a new issue