added questions to frontend, css and js for answer

This commit is contained in:
tkupek 2016-01-31 21:18:13 +01:00
parent b58189a223
commit eb02b99f22
10 changed files with 81 additions and 17 deletions

Binary file not shown.

View file

@ -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):

View file

@ -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;
}

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -0,0 +1,9 @@
function toggle_solution(id)
{
element = document.getElementById("explanation_" + id);
if (element.className == "show") {
element.className = "hide";
} else {
element.className = "show";
}
}

View file

@ -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 }}

View file

@ -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})
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})

View file

@ -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': [

View file

@ -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)
]