From eb02b99f22aacfd0edb36d4c4e195ce1ee30f036 Mon Sep 17 00:00:00 2001 From: tkupek Date: Sun, 31 Jan 2016 21:18:13 +0100 Subject: [PATCH] added questions to frontend, css and js for answer --- db.sqlite3 | Bin 47104 -> 50176 bytes tkupek_elearning/elearning/models.py | 1 + .../elearning/static/css/style.css | 35 ++++++++++++++++++ .../{templates => static}/images/favicon.ico | Bin .../elearning/static/js/elearning.js | 9 +++++ .../elearning/templates/css/style.css | 0 .../elearning/templates/index.html | 34 ++++++++++++----- tkupek_elearning/elearning/views.py | 15 +++++--- tkupek_elearning/settings.py | 2 +- tkupek_elearning/urls.py | 2 +- 10 files changed, 81 insertions(+), 17 deletions(-) create mode 100644 tkupek_elearning/elearning/static/css/style.css rename tkupek_elearning/elearning/{templates => static}/images/favicon.ico (100%) create mode 100644 tkupek_elearning/elearning/static/js/elearning.js delete mode 100644 tkupek_elearning/elearning/templates/css/style.css diff --git a/db.sqlite3 b/db.sqlite3 index bd44820c6d2a1e3403d7e44ccc8be4fdd24bd347..713f141758864270830666a7315508568ad372d1 100644 GIT binary patch delta 790 zcma))O-NKx6vywq=e_yVQE6;M1z%R0Fdy%|nbG+`X#B_mOBcFmAv%sjN-`tks05K- zgK$yl>t-di(nZkj`L+oW=&aq;N-za8G0dQe%0<_p7H;am|8Nfc`E%}%JN21N&A?nm zNdO_FaGmEOTrHa0Ull-}9U}703>&;71%ARI>_Z+tz!q%iv>!-KfNepwz)w-$3^mli7}PKU8?cV0B4%1zMbq{S}h@_H+C33 zwItlOI7Cv8UD3ICbu`FE@u394S68C2?xwR=&q2y6&YA3}Y^MjFAU(M}_M z|0NMP+q_116D-dOLVfPsNQ4~SvFaiWf~tO0}WGbUD`5F7I&kc1lZZ|0B8Z(UY00QHznC!Ll*c zpL24+?!}t|SX9`Uncp)o|K7}3a+P`F1cAv9tXU?1E*IotX8y#${D=8F^CzHJpD=I! zR4v58#msb!fq5^p6VtJcjXRh&A8WH_ - - - VCP Bayern - eLearning + {% load staticfiles %} + + + + {{ settings.title }} @@ -15,16 +17,28 @@

{{ settings.title }}

{{ settings.message }}


-
+
- {% for question in questions %} -

{{ question.id }}: {{ question.title }}

-

{{ question.text }}

-

{{ question.options }} : {{ question.answer }}

-

{{ question.explanation}}

+ {% for question, options in questions_options.items %} +

{{ question.id }}: {{ question.title }}

+

{{ question.text }}

+ +
+ {% for option in options %} + + + {% endfor %} + +
+ +

{{ question.explanation }}

+
{% endfor %} -
+

{{ settings.footer }} diff --git a/tkupek_elearning/elearning/views.py b/tkupek_elearning/elearning/views.py index 802b8cc..708f045 100644 --- a/tkupek_elearning/elearning/views.py +++ b/tkupek_elearning/elearning/views.py @@ -1,14 +1,19 @@ from django.shortcuts import render_to_response -from tkupek_elearning.elearning.models import Setting, Question +from tkupek_elearning.elearning.models import Setting, Question, Option -#import pdb; pdb.set_trace() +#import pdb def home(request): - questions = Question.objects.all() settings = Setting.objects.filter(active=1) - if(settings) : + if settings: settings = settings[0] - return render_to_response('index.html', {'settings': settings, 'questions': questions}) \ No newline at end of file + questions_options = {} + questions = Question.objects.all() + for question in questions: + options = Option.objects.filter(question=question.id) + questions_options[question] = options + + return render_to_response('index.html', {'settings': settings, 'questions_options': questions_options}) diff --git a/tkupek_elearning/settings.py b/tkupek_elearning/settings.py index 931e928..a3cb137 100644 --- a/tkupek_elearning/settings.py +++ b/tkupek_elearning/settings.py @@ -56,7 +56,7 @@ ROOT_URLCONF = 'tkupek_elearning.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ["eLearning/templates"], + 'DIRS': ["elearning/templates"], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/tkupek_elearning/urls.py b/tkupek_elearning/urls.py index 253e5f8..ac08c56 100644 --- a/tkupek_elearning/urls.py +++ b/tkupek_elearning/urls.py @@ -20,5 +20,5 @@ import tkupek_elearning.elearning.views urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'', tkupek_elearning.elearning.views.home) + url(r'start', tkupek_elearning.elearning.views.home) ] \ No newline at end of file