diff --git a/db.sqlite3 b/db.sqlite3 index 67f9cb1..bd44820 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/tkupek_elearning/elearning/admin.py b/tkupek_elearning/elearning/admin.py index 0258562..2aae186 100644 --- a/tkupek_elearning/elearning/admin.py +++ b/tkupek_elearning/elearning/admin.py @@ -1,5 +1,16 @@ 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) \ No newline at end of file + +class OptionInline(admin.TabularInline): + model = Option + + +class QuestionAdmin(admin.ModelAdmin): + inlines = [ + OptionInline, + ] + +admin.site.register(Question, QuestionAdmin) +admin.site.register(Setting) \ No newline at end of file diff --git a/tkupek_elearning/elearning/exampledata.sql b/tkupek_elearning/elearning/exampledata.sql index 62e16e7..e5c988e 100644 --- a/tkupek_elearning/elearning/exampledata.sql +++ b/tkupek_elearning/elearning/exampledata.sql @@ -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 (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'); \ No newline at end of file diff --git a/tkupek_elearning/elearning/migrations/0001_initial.py b/tkupek_elearning/elearning/migrations/0001_initial.py new file mode 100644 index 0000000..f6e79dd --- /dev/null +++ b/tkupek_elearning/elearning/migrations/0001_initial.py @@ -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'), + ), + ] diff --git a/tkupek_elearning/elearning/migrations/__init__.py b/tkupek_elearning/elearning/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tkupek_elearning/elearning/models.py b/tkupek_elearning/elearning/models.py index 283ebf1..5f50107 100644 --- a/tkupek_elearning/elearning/models.py +++ b/tkupek_elearning/elearning/models.py @@ -2,11 +2,31 @@ 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() \ No newline at end of file +class Setting(models.Model): + title = models.CharField(max_length=100, null=True) + message = models.TextField(null=True) + footer = models.TextField(null=True) + active = models.BooleanField(unique=True, default=False) + + 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 \ No newline at end of file diff --git a/tkupek_elearning/elearning/templates/css/style.css b/tkupek_elearning/elearning/templates/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/tkupek_elearning/elearning/templates/images/favicon.ico b/tkupek_elearning/elearning/templates/images/favicon.ico new file mode 100644 index 0000000..dbf52c7 Binary files /dev/null and b/tkupek_elearning/elearning/templates/images/favicon.ico differ diff --git a/tkupek_elearning/elearning/templates/index.html b/tkupek_elearning/elearning/templates/index.html index 470ea2f..d2f8414 100644 --- a/tkupek_elearning/elearning/templates/index.html +++ b/tkupek_elearning/elearning/templates/index.html @@ -12,7 +12,10 @@
{{ settings.message }}
+{{ question.explanation}}
{% endfor %} +