diff options
author | prathamesh | 2015-02-19 12:36:02 +0530 |
---|---|---|
committer | prathamesh | 2015-02-19 12:36:02 +0530 |
commit | e7e82959bb819e60ef5ab21f1950404d20e661a8 (patch) | |
tree | 1fd64709e32dcb1a21332ebb3045c8723ea8c4be /testapp/exam | |
parent | 962cee1705509bb595cda51d104ef1ef7cf0b4fd (diff) | |
parent | 663e9945eddeda6bfe37b5d64c1a08a85d222f3e (diff) | |
download | online_test-e7e82959bb819e60ef5ab21f1950404d20e661a8.tar.gz online_test-e7e82959bb819e60ef5ab21f1950404d20e661a8.tar.bz2 online_test-e7e82959bb819e60ef5ab21f1950404d20e661a8.zip |
Merge branch 'app_package' into redirect_result_view
Diffstat (limited to 'testapp/exam')
-rw-r--r-- | testapp/exam/admin.py | 2 | ||||
-rw-r--r-- | testapp/exam/fixtures/initial_fixture.json | 91 | ||||
-rw-r--r-- | testapp/exam/forms.py | 2 | ||||
-rw-r--r-- | testapp/exam/management/commands/add_group.py | 33 | ||||
-rw-r--r-- | testapp/exam/management/commands/dump_user_data.py | 4 | ||||
-rw-r--r-- | testapp/exam/management/commands/load_exam.py | 2 | ||||
-rw-r--r-- | testapp/exam/management/commands/load_questions_xml.py | 2 | ||||
-rw-r--r-- | testapp/exam/management/commands/results2csv.py | 2 | ||||
-rw-r--r-- | testapp/exam/urls.py | 2 | ||||
-rw-r--r-- | testapp/exam/views.py | 8 |
10 files changed, 45 insertions, 103 deletions
diff --git a/testapp/exam/admin.py b/testapp/exam/admin.py index 8482ef9..060859a 100644 --- a/testapp/exam/admin.py +++ b/testapp/exam/admin.py @@ -1,4 +1,4 @@ -from exam.models import Question, Quiz +from testapp.exam.models import Question, Quiz from django.contrib import admin admin.site.register(Question) diff --git a/testapp/exam/fixtures/initial_fixture.json b/testapp/exam/fixtures/initial_fixture.json deleted file mode 100644 index da3cf18..0000000 --- a/testapp/exam/fixtures/initial_fixture.json +++ /dev/null @@ -1,91 +0,0 @@ -[ - { - "fields": { - "active": true, - "description": "\nWrite a function called <code>fact</code> which takes a single integer argument\n(say <code>n</code>) and returns the factorial of the number. \nFor example:<br/>\n<code>fact(3) -> 6</code>\n", - "options": "", - "points": 2.0, - "summary": "Factorial", - "test": "\nassert fact(0) == 1\nassert fact(5) == 120\n", - "type": "python" - }, - "model": "exam.question", - "pk": 1 - }, - { - "fields": { - "active": true, - "description": "Create a simple function called <code>sqr</code> which takes a single \nargument and returns the square of the argument. For example: <br/>\n<code>sqr(3) -> 9</code>.", - "options": "", - "points": 1.0, - "summary": "Simple function", - "test": "\nimport math\nassert sqr(3) == 9\nassert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 \n ", - "type": "python" - }, - "model": "exam.question", - "pk": 2 - }, - { - "fields": { - "active": true, - "description": "Write a shell script which takes two arguments on the\ncommand line and prints the sum of the two on the output.", - "options": "", - "points": 2.0, - "summary": "Bash addition", - "test": "docs/sample.sh\ndocs/sample.args\n", - "type": "bash" - }, - "model": "exam.question", - "pk": 3 - }, - { - "fields": { - "active": true, - "description": "What is the largest integer value that can be represented\nin Python?", - "options": "No Limit\n2**32\n2**32 - 1\nNone of the above\n", - "points": 0.5, - "summary": "Size of integer in Python", - "test": "No Limit", - "type": "mcq" - }, - "model": "exam.question", - "pk": 4 - }, - { - "fields": { - "active": true, - "description": "Basic Python Quiz 1", - "duration": 10, - "start_date": "2012-03-29" - }, - "model": "exam.quiz", - "pk": 1 - }, - { - "fields": { - "name": "moderator", - "permissions": [ - 31, - 37, - 43, - 32, - 38, - 44, - 33, - 39, - 45, - 34, - 40, - 46, - 35, - 41, - 47, - 36, - 42, - 48 - ] - }, - "model": "auth.group", - "pk": 1 - } -] diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 9bfedbe..f04fdb3 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -1,5 +1,5 @@ from django import forms -from exam.models import Profile, Quiz, Question +from testapp.exam.models import Profile, Quiz, Question from django.contrib.auth import authenticate from django.contrib.auth.models import User diff --git a/testapp/exam/management/commands/add_group.py b/testapp/exam/management/commands/add_group.py new file mode 100644 index 0000000..76cc655 --- /dev/null +++ b/testapp/exam/management/commands/add_group.py @@ -0,0 +1,33 @@ +''' + This command adds moderator group with permissions to add, change and delete + the objects in the exam app. + We can modify this command to add more groups by providing arguments. + Arguments like group-name, app-name can be passed. +''' + +# django imports +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import Group, Permission +from django.contrib.contenttypes.models import ContentType +from django.db.utils import IntegrityError + +class Command(BaseCommand): + help = 'Adds the moderator group' + + def handle(self, *args, **options): + app = 'exam' + group = Group(name='moderator') + try: + group.save() + except IntegrityError: + raise CommandError("The group already exits") + else: + # Get the models for the given app + content_types = ContentType.objects.filter(app_label=app) + # Get list of permissions for the models + permission_list = Permission.objects.filter(content_type=content_types) + for permission in permission_list: + group.permissions.add(permission) + group.save() + + self.stdout.write('Moderator group added successfully') diff --git a/testapp/exam/management/commands/dump_user_data.py b/testapp/exam/management/commands/dump_user_data.py index ec016bb..c5537e5 100644 --- a/testapp/exam/management/commands/dump_user_data.py +++ b/testapp/exam/management/commands/dump_user_data.py @@ -5,8 +5,8 @@ from django.core.management.base import BaseCommand from django.template import Template, Context # Local imports. -from exam.views import get_user_data -from exam.models import User +from testapp.exam.views import get_user_data +from testapp.exam.models import User data_template = Template('''\ =============================================================================== diff --git a/testapp/exam/management/commands/load_exam.py b/testapp/exam/management/commands/load_exam.py index e3f72da..c4a34a3 100644 --- a/testapp/exam/management/commands/load_exam.py +++ b/testapp/exam/management/commands/load_exam.py @@ -5,7 +5,7 @@ from os.path import basename from django.core.management.base import BaseCommand # Local imports. -from exam.models import Question, Quiz +from testapp.exam.models import Question, Quiz def clear_exam(): """Deactivate all questions from the database.""" diff --git a/testapp/exam/management/commands/load_questions_xml.py b/testapp/exam/management/commands/load_questions_xml.py index 8bc2701..3e13ae1 100644 --- a/testapp/exam/management/commands/load_questions_xml.py +++ b/testapp/exam/management/commands/load_questions_xml.py @@ -8,7 +8,7 @@ import re from django.core.management.base import BaseCommand # Local imports. -from exam.models import Question +from testapp.exam.models import Question def decode_html(html_str): """Un-escape or decode HTML strings to more usable Python strings. diff --git a/testapp/exam/management/commands/results2csv.py b/testapp/exam/management/commands/results2csv.py index 2993745..1cdf8e3 100644 --- a/testapp/exam/management/commands/results2csv.py +++ b/testapp/exam/management/commands/results2csv.py @@ -7,7 +7,7 @@ from django.core.management.base import BaseCommand from django.template import Template, Context # Local imports. -from exam.models import Quiz, QuestionPaper +from testapp.exam.models import Quiz, QuestionPaper result_template = Template('''\ "name","username","rollno","email","answered","total","attempts","position",\ diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index 37a031d..f8a6cb8 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import patterns, include, url -urlpatterns = patterns('exam.views', +urlpatterns = patterns('testapp.exam.views', url(r'^$', 'index'), url(r'^login/$', 'user_login'), url(r'^quizzes/$','quizlist_user'), diff --git a/testapp/exam/views.py b/testapp/exam/views.py index aeb93ca..c6e3024 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -15,11 +15,11 @@ from django.views.decorators.csrf import csrf_exempt from taggit.models import Tag from itertools import chain # Local imports. -from exam.models import Quiz, Question, QuestionPaper, QuestionSet -from exam.models import Profile, Answer, AnswerPaper, User -from exam.forms import UserRegisterForm, UserLoginForm, QuizForm,\ +from testapp.exam.models import Quiz, Question, QuestionPaper, QuestionSet +from testapp.exam.models import Profile, Answer, AnswerPaper, User +from testapp.exam.forms import UserRegisterForm, UserLoginForm, QuizForm,\ QuestionForm, RandomQuestionForm -from exam.xmlrpc_clients import code_server +from testapp.exam.xmlrpc_clients import code_server from settings import URL_ROOT |