From: Tom Walker Date: Sun, 13 Jul 2014 20:09:07 +0000 (+0100) Subject: pep8 related clean ups, updated for new push to pypi X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=aaef7ff29e5863a2d41ddac04b86fda81c7c9718;p=django_quiz.git pep8 related clean ups, updated for new push to pypi --- diff --git a/README.rst b/README.rst index 8d60721..7744454 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,4 @@ +=============== Django quiz app =============== @@ -10,28 +11,26 @@ My websites have used twitter bootstrap for the front end and I have tried to strip out anything from the template files that are dependant on bootstrap. -.. figure:: http://i.imgur.com/VRYx3OV.png - :alt: Question picture hosted by Imgur +.. image:: http://i.imgur.com/VRYx3OV.png + - Questions Current features ---------------- -Features of each quiz: \* Question order randomisation \* Storing of -quiz results under each user \* Previous quiz scores can be viewed on -category page \* Correct answers can be shown after each question or all -at once at the end \* Logged in users can return to an incomplete quiz -to finish it and non-logged in users can complete a quiz if their -session persists \* The quiz can be limited to one attempt per user \* -Questions can be given a category \* Success rate for each category can -be monitored on a progress page \* Explanation for each question result -can be given \* Multiple choice question type \* True/False question -type - -.. figure:: http://i.imgur.com/UJtRZxo.png - :alt: Result picture hosted by Imgur - - Result page +* Question order randomisation +* Storing of quiz results under each user +* Previous quiz scores can be viewed on category page +* Correct answers can be shown after each question or all at once at the end +* Logged in users can return to an incomplete quiz to finish it and non-logged in users can complete a quiz if their session persists +* The quiz can be limited to one attempt per user +* Questions can be given a category +* Success rate for each category can be monitored on a progress page +* Explanation for each question result can be given +* Multiple choice question type +* True/False question type + +.. image:: http://i.imgur.com/UJtRZxo.png + Requirements ------------ @@ -43,33 +42,32 @@ Installation ------------ Clone the repo with -``git clone https://github.com/tomwalker/django_quiz.git``. + .. code-block:: bash + ``git clone https://github.com/tomwalker/django_quiz.git``. Run ``pip install -r requirements.txt``. Add ``'quiz', 'multichoice', 'true_false',`` to your ``INSTALLED_APPS`` setting. -:: - - INSTALLED_APPS = ( - ... - 'quiz', - 'multichoice', - 'true_false', - ... - ) + .. code-block:: python + INSTALLED_APPS = ( + ... + 'quiz', + 'multichoice', + 'true_false', + ... + ) Add the following to your projects ``urls.py`` file, substituting ``q`` for whatever you want the quiz base url to be. -:: - - urlpatterns = patterns('', - ... - url(r'^q/', include('quiz.urls')), - ... - ) + .. code-block:: python + urlpatterns = patterns('', + ... + url(r'^q/', include('quiz.urls')), + ... + ) This is my first open source project so please forgive any problems and/or dreadful code! diff --git a/quiz/admin.py b/quiz/admin.py index be1a4f6..2517bd9 100644 --- a/quiz/admin.py +++ b/quiz/admin.py @@ -6,6 +6,7 @@ from .models import Quiz, Category, Progress, Question from multichoice.models import MCQuestion, Answer from true_false.models import TF_Question + class QuestionInline(admin.TabularInline): model = Question.quiz.through filter_horizontal = ('content',) @@ -16,19 +17,22 @@ class AnswerInline(admin.TabularInline): """ below is from -http://stackoverflow.com/questions/11657682/django-admin-interface-using-horizontal-filter-with- +http://stackoverflow.com/questions/11657682/ +django-admin-interface-using-horizontal-filter-with- inline-manytomany-field """ + class QuizAdminForm(forms.ModelForm): class Meta: model = Quiz questions = forms.ModelMultipleChoiceField( - queryset = Question.objects.all().select_subclasses(), - required = False, - widget = FilteredSelectMultiple(verbose_name = ('Questions'), - is_stacked = False)) + queryset=Question.objects.all().select_subclasses(), + required=False, + widget=FilteredSelectMultiple( + verbose_name=('Questions'), + is_stacked=False)) def __init__(self, *args, **kwargs): super(QuizAdminForm, self).__init__(*args, **kwargs) @@ -56,15 +60,15 @@ class QuizAdmin(admin.ModelAdmin): class CategoryAdmin(admin.ModelAdmin): search_fields = ('category', ) + class MCQuestionAdmin(admin.ModelAdmin): list_display = ('content', 'category', ) list_filter = ('category',) - fields = ('content', 'category', 'quiz', 'explanation' ) + fields = ('content', 'category', 'quiz', 'explanation') search_fields = ('content', ) filter_horizontal = ('quiz',) - inlines = [AnswerInline] @@ -75,6 +79,7 @@ class ProgressAdmin(admin.ModelAdmin): """ search_fields = ('user', 'score', ) + class TFQuestionAdmin(admin.ModelAdmin): list_display = ('content', 'category', ) list_filter = ('category',) diff --git a/quiz/forms.py b/quiz/forms.py index 46328a0..9afb3cf 100644 --- a/quiz/forms.py +++ b/quiz/forms.py @@ -1,5 +1,2 @@ from django import forms from django.forms.models import inlineformset_factory - -from multichoice.models import Question, Answer - diff --git a/setup.py b/setup.py index afd0617..9c6072e 100644 --- a/setup.py +++ b/setup.py @@ -1,18 +1,15 @@ -import os from setuptools import setup -README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read() - -os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) +readme = open('README.rst').read() setup( name='django-quiz-app', - version='0.3.1', + version='0.4.0', packages=['quiz', 'multichoice', 'true_false'], include_package_data=True, license='MIT License', description='A configurable quiz app for Django.', - long_description=README, + long_description=readme, url='https://github.com/tomwalker/django_quiz', author='Tom Walker', author_email='tomwalker0472@gmail.com', @@ -29,7 +26,7 @@ setup( 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], install_requires=[ - 'django-model-utils == 2.0.3', - 'Django >= 1.5.1', + 'django-model-utils == 2.0.3', + 'Django >= 1.5.1', ], )