From eb02b99f22aacfd0edb36d4c4e195ce1ee30f036 Mon Sep 17 00:00:00 2001 From: tkupek <mail@tkupek.eu> 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>!-KfNepw<UkZb4xYdO zoFVVX19F*|@EbgdRdj@Mh-$RwQj0@GRjsk)a5A1r4W(|#vaI%wCbL;S_x6uvv*}dt zXnJ@oJCshTvQqDn6^~z$lyF2<BmSUQ355bm(8vi*P%;f}xDGF10h+-Hd$6a|AA~vW z9xSpZyT7pb_}=4!SEz!m+fQQ$Td>z)w-$3^mli7}PKU8?cV0B4%1zMbq{S}h@_<n6 z5MdkfXMTij_zDL`N##1Q&8T28iy~lb7TCc=DL3sRID&8R1wO$pH@yX`09Gs>H+C33 zwItlOI7Cv8U<I1U8W|zwI<=6=F42mL!nhGzW6F49MCy;<N@h}$NBRqeG!Mp8H<AO= z2_Rnc2_*iA8um7*N<a>D3ICbu`FE@u394S68C2?xwR=&q2y6&YA3}Y^MjFAU(M}_M z|0NMP+q_1<i<l2ij^F^aPVrHtPyl!p;Z^b)+MrFRH!;4d(JRKxe3UFclWc|Dj-eGn zt4^a}ry*=XVVdl)*0P?CrNYs{^n~>16D-dOLV<wu2<M5P=&+*G9c+pQO|FhQHd$WA z-aoBkxyN^G)7A#F%jd&)W9;l~E%vdghh;1=``qo8s!wpNmd4|m#9%ygL6PM;=~{Pt SdtEGKa&`NDCno04VfhzorQ7EK delta 435 zcmZqZU~c%pG(lR>fPsNQ4~SvFaiWf~tO0}WGbUD`5F7I&kc1lZZ|0B8Z<xO^KWBcl zSx_dEdGb?cc{yH&;|$ElnWr(QFe@@$XX<70U}9rD#8}U0#PEmV_{7Ggn~$?NG4o$! z)?tohUd}v|*_rtjv&hEAKTMNFxOEwsCp&Q)tEj_l2Gh)Y7{pKnz?{i5xz%(<F~mig znDrS`vJ&&s^W$?f(~A;IGV}9_c^Mc)cs9S`7IB!Q!^RTKz#P1>(UY00QHznC!Ll*c zpL24+?!}t|SX9`Uncp)o|K7}3a+P`F1cAv9tXU?1E*IotX8y#${D=8F^CzHJpD=I! zR4v58#msb!fq5^p6VtJcjXRh&A8WH_<p(;5g(07TA)iT-$%k2TVq^T~gq~GQT#YFP z?Be?Rj7{Z}cOOz`6q#JuCo%c=p*f72oA$7<2(STzjnS2{gQ=OBi}^4ppf*o7K2*o# jXgGQQVFyOl%}1wNGqG8lvWfd^P8I-a6*(loXodm+Nvm=a diff --git a/tkupek_elearning/elearning/models.py b/tkupek_elearning/elearning/models.py index 5f50107..facd379 100644 --- a/tkupek_elearning/elearning/models.py +++ b/tkupek_elearning/elearning/models.py @@ -7,6 +7,7 @@ class Setting(models.Model): title = models.CharField(max_length=100, null=True) message = models.TextField(null=True) footer = models.TextField(null=True) + button_solution = models.CharField(max_length=100, null=True) active = models.BooleanField(unique=True, default=False) def __str__(self): diff --git a/tkupek_elearning/elearning/static/css/style.css b/tkupek_elearning/elearning/static/css/style.css new file mode 100644 index 0000000..63dd52f --- /dev/null +++ b/tkupek_elearning/elearning/static/css/style.css @@ -0,0 +1,35 @@ +body { + +} + +p { +text-align: justify; +} + +#showSolution { + display: block; +} + +p[id^="explanation_"] { + +} + +.show { + display: block; +} + +.hide { + display: none; +} + +.margin10 { + margin-top: 10px; +} + +.margin25 { + margin-top: 25px; +} + +.margin50 { + margin-top: 50px; +} diff --git a/tkupek_elearning/elearning/templates/images/favicon.ico b/tkupek_elearning/elearning/static/images/favicon.ico similarity index 100% rename from tkupek_elearning/elearning/templates/images/favicon.ico rename to tkupek_elearning/elearning/static/images/favicon.ico diff --git a/tkupek_elearning/elearning/static/js/elearning.js b/tkupek_elearning/elearning/static/js/elearning.js new file mode 100644 index 0000000..17e6d0b --- /dev/null +++ b/tkupek_elearning/elearning/static/js/elearning.js @@ -0,0 +1,9 @@ +function toggle_solution(id) +{ + element = document.getElementById("explanation_" + id); + if (element.className == "show") { + element.className = "hide"; + } else { + element.className = "show"; + } +} \ No newline at end of file diff --git a/tkupek_elearning/elearning/templates/css/style.css b/tkupek_elearning/elearning/templates/css/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/tkupek_elearning/elearning/templates/index.html b/tkupek_elearning/elearning/templates/index.html index d2f8414..cef3ba5 100644 --- a/tkupek_elearning/elearning/templates/index.html +++ b/tkupek_elearning/elearning/templates/index.html @@ -4,9 +4,11 @@ <head> <meta charset="utf-8" /> - <link rel="stylesheet" href="css/style.css"> - <link href="images/favicon.ico" rel="shortcut icon"> - <title>VCP Bayern - eLearning</title> + {% load staticfiles %} + <link rel="stylesheet" href="{% static 'css/style.css' %}"> + <link href="{% static 'images/favicon.ico' %}" rel="shortcut icon"> + <script type="text/javascript" src="{% static 'js/elearning.js' %}"></script> + <title>{{ settings.title }}</title> </head> <body> @@ -15,16 +17,28 @@ <h1>{{ settings.title }}</h1> <p>{{ settings.message }}</p> <hr/> - <br/> + <div class="margin50" /> - {% 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> + {% for question, options in questions_options.items %} + <h2>{{ question.id }}: {{ question.title }}</h2> + <p>{{ question.text }}</p> + + <form action="#"> + {% for option in options %} + + <label> + <input type="checkbox" name="option" value="{{ option.id }}"> + {{ option.text }} + </label> + {% endfor %} + <button class="margin10" type="button" id="showSolution" onmouseup="toggle_solution({{ question.id }})">{{ settings.button_solution }}</button> + </form> + + <p id="explanation_{{ question.id }}" class="hide">{{ question.explanation }}</p> + <div class="margin25" /> {% endfor %} - <br/> + <div class="margin50" /> <hr/> {{ 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