/plan.txt
/dist*
*.egg-info*
-build*
\ No newline at end of file
+build*
+/.coverage
+/.coveragerc
+/coverage_html_report/
+/htmlcov/
-#from django.shortcuts import render
+# from django.shortcuts import render
from true_false.models import TF_Question
from essay.models import Essay_Question
+
class AnswerInline(admin.TabularInline):
model = Answer
-"""
-below is from
-http://stackoverflow.com/questions/11657682/
-django-admin-interface-using-horizontal-filter-with-
-inline-manytomany-field
-"""
-
class QuizAdminForm(forms.ModelForm):
+ """
+ below is from
+ http://stackoverflow.com/questions/11657682/
+ django-admin-interface-using-horizontal-filter-with-
+ inline-manytomany-field
+ """
+
class Meta:
model = Quiz
search_fields = ('content', 'explanation')
filter_horizontal = ('quiz',)
+
class EssayQuestionAdmin(admin.ModelAdmin):
list_display = ('content', 'category', )
list_filter = ('category',)
-import re, json
+import re
+import json
+
from django.db import models
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator
def anon_q_list(self):
return str(self.id) + "_q_list"
-"""
-Progress is used to track an individual signed in users score on different
-quiz's and categories
-"""
-
class ProgressManager(models.Manager):
class Progress(models.Model):
"""
- Currently stores the score for each category, max possible they could
- have got, and previous exam paper scores.
+ Progress is used to track an individual signed in users score on different
+ quiz's and categories
Data stored in csv using the format:
category, score, possible, category, score, possible, ...
output[cat.category] = [0, 0]
if len(self.score) > len(score_before):
- """
- If a new category has been added, save changes. Otherwise nothing
- will be saved.
- """
+ # If a new category has been added, save changes.
self.save()
return output
self.save()
else:
- """
- if not present but existing category, add with the points passed in
- """
+ # if not present but existing, add with the points passed in
self.score += (str(category) + "," +
str(score_to_add) + "," +
str(possible_to_add) + ",")
"""
if len(self.incorrect_questions) > 0:
self.incorrect_questions += ','
- self.incorrect_questions += str(question.id) + ","
+ self.incorrect_questions += str(question.id) + ","
if self.complete:
self.add_to_score(-1)
self.save()
self.assertEqual(self.sitting.current_score, 1)
-'''
-Tests relating to views
-'''
-
-
class TestNonQuestionViews(TestCase):
'''
Starting on views not directly involved with questions.
self.assertContains(response, 'only one sitting is permitted.')
self.assertTemplateUsed('single_complete.html')
+ def test_essay_question(self):
+ quiz3 = Quiz.objects.create(id=3,
+ title='test quiz 3',
+ description='d3',
+ url='tq3',
+ category=self.c1,
+ answers_at_end=True,
+ exam_paper=True)
+ essay = Essay_Question.objects.create(id=4, content='tell all')
+ essay.quiz.add(quiz3)
+ self.client.login(username='jacob', password='top_secret')
+
+ response = self.client.post('/tq3/take/')
+ self.assertContains(response, '<textarea')
+
+ response = self.client.post('/tq3/take/',
+ {'answers': 'The meaning of life is...',
+ 'question_id': 4})
+ self.assertContains(response, 'result')
+
class TestTemplateTags(TestCase):
template_name = 'view_quiz_category.html'
def dispatch(self, request, *args, **kwargs):
- self.category = get_object_or_404(Category,
- category=
- self.kwargs['category_name'])
+ self.category = get_object_or_404(
+ Category,
+ category=self.kwargs['category_name']
+ )
return super(ViewQuizListByCategory, self).\
dispatch(request, *args, **kwargs)
verbose_name = "True/False Question"
verbose_name_plural = "True/False Questions"
ordering = ['category']
-
- def __unicode__(self):
- return unicode(self.content)