summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testapp/exam/forms.py1
-rw-r--r--testapp/exam/models.py3
-rw-r--r--testapp/exam/views.py4
-rw-r--r--testapp/settings.py2
-rw-r--r--testapp/templates/exam/add_question.html1
-rw-r--r--testapp/templates/exam/edit_question.html1
-rw-r--r--testapp/templates/exam/question.html2
7 files changed, 12 insertions, 2 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py
index f48a674..9bcd04f 100644
--- a/testapp/exam/forms.py
+++ b/testapp/exam/forms.py
@@ -133,6 +133,7 @@ class QuestionForm(forms.Form):
type = forms.CharField(max_length=8, widget=forms.Select(choices=QUESTION_TYPE_CHOICES))
active = forms.BooleanField(required=False)
tags = TagField(widget=TagAutocomplete(),required=False)
+ snippet = forms.CharField(widget = forms.Textarea(attrs={'cols': 40, 'rows': 1}),required=False)
def save(self):
summary = self.cleaned_data["summary"]
diff --git a/testapp/exam/models.py b/testapp/exam/models.py
index 04789da..708c7af 100644
--- a/testapp/exam/models.py
+++ b/testapp/exam/models.py
@@ -44,6 +44,9 @@ class Question(models.Model):
# Is this question active or not. If it is inactive it will not be used
# when creating a QuestionPaper.
active = models.BooleanField(default=True)
+
+ #Code Snippet
+ snippet = models.CharField(max_length=256)
#Tags for the Question.
tags = TaggableManager()
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 49f7bb9..a1e8ece 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -169,6 +169,7 @@ def edit_question(request):
options = request.POST.getlist('options')
type = request.POST.getlist('type')
active = request.POST.getlist('active')
+ snippet = request.POST.getlist('snippet')
tags = request.POST.getlist('tags')
j = 0
for id_list in questions:
@@ -181,6 +182,7 @@ def edit_question(request):
question.type = type[j]
edit_tags=tags[j]
question.active = active[j]
+ question.snippet = snippet[j]
question.save()
for tag in question.tags.all():
question.tags.remove(tag)
@@ -219,6 +221,7 @@ def add_question(request,question_id=None):
d.options = form['options'].data
d.type = form['type'].data
d.active = form['active'].data
+ d.snippet = form['snippet'].data
d.save()
question = Question.objects.get(id=question_id)
for tag in question.tags.all():
@@ -250,6 +253,7 @@ def add_question(request,question_id=None):
form.initial['options'] = d.options
form.initial['type'] = d.type
form.initial['active'] = d.active
+ form.initial['snippet'] = d.snippet
form_tags = d.tags.all()
form_tags_split = form_tags.values('name')
initial_tags = ""
diff --git a/testapp/settings.py b/testapp/settings.py
index cb3defc..10d0919 100644
--- a/testapp/settings.py
+++ b/testapp/settings.py
@@ -21,7 +21,7 @@ SERVER_TIMEOUT = 2
# are not hosted as host.org/exam/ but as host.org/foo/exam/ for whatever
# reason set this to the root you have to serve at. In the above example
# host.org/foo/exam set URL_ROOT='/foo'
-URL_ROOT = '/online_test'
+URL_ROOT = ''
ADMINS = (
diff --git a/testapp/templates/exam/add_question.html b/testapp/templates/exam/add_question.html
index 9651600..e3ba17a 100644
--- a/testapp/templates/exam/add_question.html
+++ b/testapp/templates/exam/add_question.html
@@ -26,6 +26,7 @@
<tr><td><strong>Rendered: </strong><td><p id='my'></p>
<tr><td>Description: <td>{{ form.description}} {{form.description.errors}}
<tr><td>Test: <td>{{ form.test }}{{form.test.errors}}
+ <tr><td>Snippet: <td>{{ form.snippet }}{{ form.snippet.errors }}</td></tD></td></tr>
<tr><td>Tags: <td>{{ form.tags }}
<tr><td id='label_option'>Options: <td>{{ form.options }} {{form.options.errors}}
diff --git a/testapp/templates/exam/edit_question.html b/testapp/templates/exam/edit_question.html
index 0a41326..96502f1 100644
--- a/testapp/templates/exam/edit_question.html
+++ b/testapp/templates/exam/edit_question.html
@@ -36,6 +36,7 @@
<tr><td><strong>Rendered: </strong><td><p id='my{{forloop.counter}}'></p>
<tr><td><b>Description: <td>{{ form.description }} {{form.description.errors}}
<tr><td><b>Test: <td>{{ form.test }}{{form.test.errors}}
+ <tr><td><b>Snippet: <td>{{ form.snippet }}{{ form.snippet.errors }}</td></b></td></tr>
<tr><td>Tags: <td>{{ form.tags }}
<tr><td id='label_option{{forloop.counter}}'><b>Options: <td>{{ form.options }} {{form.options.errors}} {{form.options.helptext}}
</table></center>
diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html
index b2f5816..aaf7270 100644
--- a/testapp/templates/exam/question.html
+++ b/testapp/templates/exam/question.html
@@ -208,7 +208,7 @@ function catchTab(item,e){
{% endfor %}
{% else %}
- <textarea tabindex=1 rows="15" style="width:750px;margin-bottom:10px;" name="answer" id="answer" wrap="off" onkeydown="return catchTab(this,event)">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %} #!/bin/bash{% else %}# Enter your answer here.{% endif %}{% endif %}</textarea>
+ <textarea tabindex=1 rows="15" style="width:750px;margin-bottom:10px;" name="answer" id="answer" wrap="off" onkeydown="return catchTab(this,event)">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %} #!/bin/bash{% else %}{{ question.snippet }}{% endif %}{% endif %}</textarea>
<br>
<script type="text/javascript">