diff options
author | ankitjavalkar | 2015-06-15 18:23:29 +0530 |
---|---|---|
committer | ankitjavalkar | 2015-08-03 15:22:07 +0530 |
commit | 516284689fa9daa9b4487e4c5683997111df6049 (patch) | |
tree | b4a6a87fc356fa5f6c08d1712174bc05773cc5a0 | |
parent | 0225aad1492600ed53504b0986fd13da24c28ae9 (diff) | |
download | online_test-516284689fa9daa9b4487e4c5683997111df6049.tar.gz online_test-516284689fa9daa9b4487e4c5683997111df6049.tar.bz2 online_test-516284689fa9daa9b4487e4c5683997111df6049.zip |
Modify installer script and cleanup;
- Add __init__.py
- Add templates dir to MANIFEST
- Add persistent store for project details
- Modify initial_data.json
- Fix imports
Conflicts:
testapp/templates/demo_settings.py
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rw-r--r-- | initial_fixtures.json | 1 | ||||
-rw-r--r-- | setup.py | 1 | ||||
-rw-r--r-- | testapp/exam/fixtures/initial_data.json | 1 | ||||
-rw-r--r-- | testapp/exam/language_registry.py | 2 | ||||
-rw-r--r-- | testapp/scripts/__init__.py | 0 | ||||
-rw-r--r-- | testapp/scripts/project_detail.py | 2 | ||||
-rw-r--r-- | testapp/scripts/vimarsh.py | 127 | ||||
-rw-r--r-- | testapp/templates/demo_settings.py | 87 |
9 files changed, 220 insertions, 2 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 6775565..c1ba7a7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -11,3 +11,4 @@ recursive-include testapp/exam/templates * recursive-include testapp/exam/management * recursive-include testapp/exam/output * recursive-include testapp/exam/fixtures * +recursive-include testapp/templates * diff --git a/initial_fixtures.json b/initial_fixtures.json deleted file mode 100644 index f7cbceb..0000000 --- a/initial_fixtures.json +++ /dev/null @@ -1 +0,0 @@ -[{"pk": 8, "model": "contenttypes.contenttype", "fields": {"model": "tag", "name": "Tag", "app_label": "taggit"}}, {"pk": 9, "model": "contenttypes.contenttype", "fields": {"model": "taggeditem", "name": "Tagged Item", "app_label": "taggit"}}, {"pk": 13, "model": "contenttypes.contenttype", "fields": {"model": "answer", "name": "answer", "app_label": "exam"}}, {"pk": 16, "model": "contenttypes.contenttype", "fields": {"model": "answerpaper", "name": "answer paper", "app_label": "exam"}}, {"pk": 4, "model": "contenttypes.contenttype", "fields": {"model": "contenttype", "name": "content type", "app_label": "contenttypes"}}, {"pk": 2, "model": "contenttypes.contenttype", "fields": {"model": "group", "name": "group", "app_label": "auth"}}, {"pk": 7, "model": "contenttypes.contenttype", "fields": {"model": "logentry", "name": "log entry", "app_label": "admin"}}, {"pk": 10, "model": "contenttypes.contenttype", "fields": {"model": "migrationhistory", "name": "migration history", "app_label": "south"}}, {"pk": 1, "model": "contenttypes.contenttype", "fields": {"model": "permission", "name": "permission", "app_label": "auth"}}, {"pk": 11, "model": "contenttypes.contenttype", "fields": {"model": "profile", "name": "profile", "app_label": "exam"}}, {"pk": 12, "model": "contenttypes.contenttype", "fields": {"model": "question", "name": "question", "app_label": "exam"}}, {"pk": 15, "model": "contenttypes.contenttype", "fields": {"model": "questionpaper", "name": "question paper", "app_label": "exam"}}, {"pk": 14, "model": "contenttypes.contenttype", "fields": {"model": "quiz", "name": "quiz", "app_label": "exam"}}, {"pk": 5, "model": "contenttypes.contenttype", "fields": {"model": "session", "name": "session", "app_label": "sessions"}}, {"pk": 6, "model": "contenttypes.contenttype", "fields": {"model": "site", "name": "site", "app_label": "sites"}}, {"pk": 3, "model": "contenttypes.contenttype", "fields": {"model": "user", "name": "user", "app_label": "auth"}}, {"pk": "b2f8681f9f910450d835f101d7bea258", "model": "sessions.session", "fields": {"expire_date": "2012-04-12T14:24:49.649", "session_data": "NDc2OTM3MDBkZDkwMDAyMGQ1NTZhNjAwZTJhMThmMzIyZGJmYjA5NzqAAn1xAS4=\n"}}, {"pk": 1, "model": "sites.site", "fields": {"domain": "example.com", "name": "example.com"}}, {"pk": 1, "model": "exam.question", "fields": {"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", "summary": "Factorial", "active": true, "points": 2.0, "test": "\nassert fact(0) == 1\nassert fact(5) == 120\n", "type": "python", "options": ""}}, {"pk": 2, "model": "exam.question", "fields": {"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>.", "summary": "Simple function", "active": true, "points": 1.0, "test": "\nimport math\nassert sqr(3) == 9\nassert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 \n ", "type": "python", "options": ""}}, {"pk": 3, "model": "exam.question", "fields": {"description": "Write a shell script which takes two arguments on the\n command line and prints the sum of the two on the output.", "summary": "Bash addition", "active": true, "points": 2.0, "test": "docs/sample.sh\ndocs/sample.args\n", "type": "bash", "options": ""}}, {"pk": 4, "model": "exam.question", "fields": {"description": "What is the largest integer value that can be represented\nin Python?", "summary": "Size of integer in Python", "active": true, "points": 0.5, "test": "No Limit", "type": "mcq", "options": "No Limit\n2**32\n2**32 - 1\nNone of the above\n"}}, {"pk": 1, "model": "exam.quiz", "fields": {"duration": 10, "active": true, "start_date": "2012-03-29", "description": "Basic Python Quiz 1"}}, {"pk": 19, "model": "auth.permission", "fields": {"codename": "add_logentry", "name": "Can add log entry", "content_type": 7}}, {"pk": 20, "model": "auth.permission", "fields": {"codename": "change_logentry", "name": "Can change log entry", "content_type": 7}}, {"pk": 21, "model": "auth.permission", "fields": {"codename": "delete_logentry", "name": "Can delete log entry", "content_type": 7}}, {"pk": 1, "model": "auth.permission", "fields": {"codename": "add_group", "name": "Can add group", "content_type": 2}}, {"pk": 4, "model": "auth.permission", "fields": {"codename": "change_group", "name": "Can change group", "content_type": 2}}, {"pk": 7, "model": "auth.permission", "fields": {"codename": "delete_group", "name": "Can delete group", "content_type": 2}}, {"pk": 2, "model": "auth.permission", "fields": {"codename": "add_permission", "name": "Can add permission", "content_type": 1}}, {"pk": 5, "model": "auth.permission", "fields": {"codename": "change_permission", "name": "Can change permission", "content_type": 1}}, {"pk": 8, "model": "auth.permission", "fields": {"codename": "delete_permission", "name": "Can delete permission", "content_type": 1}}, {"pk": 3, "model": "auth.permission", "fields": {"codename": "add_user", "name": "Can add user", "content_type": 3}}, {"pk": 6, "model": "auth.permission", "fields": {"codename": "change_user", "name": "Can change user", "content_type": 3}}, {"pk": 9, "model": "auth.permission", "fields": {"codename": "delete_user", "name": "Can delete user", "content_type": 3}}, {"pk": 10, "model": "auth.permission", "fields": {"codename": "add_contenttype", "name": "Can add content type", "content_type": 4}}, {"pk": 11, "model": "auth.permission", "fields": {"codename": "change_contenttype", "name": "Can change content type", "content_type": 4}}, {"pk": 12, "model": "auth.permission", "fields": {"codename": "delete_contenttype", "name": "Can delete content type", "content_type": 4}}, {"pk": 31, "model": "auth.permission", "fields": {"codename": "add_answer", "name": "Can add answer", "content_type": 13}}, {"pk": 37, "model": "auth.permission", "fields": {"codename": "change_answer", "name": "Can change answer", "content_type": 13}}, {"pk": 43, "model": "auth.permission", "fields": {"codename": "delete_answer", "name": "Can delete answer", "content_type": 13}}, {"pk": 32, "model": "auth.permission", "fields": {"codename": "add_answerpaper", "name": "Can add answer paper", "content_type": 16}}, {"pk": 38, "model": "auth.permission", "fields": {"codename": "change_answerpaper", "name": "Can change answer paper", "content_type": 16}}, {"pk": 44, "model": "auth.permission", "fields": {"codename": "delete_answerpaper", "name": "Can delete answer paper", "content_type": 16}}, {"pk": 33, "model": "auth.permission", "fields": {"codename": "add_profile", "name": "Can add profile", "content_type": 11}}, {"pk": 39, "model": "auth.permission", "fields": {"codename": "change_profile", "name": "Can change profile", "content_type": 11}}, {"pk": 45, "model": "auth.permission", "fields": {"codename": "delete_profile", "name": "Can delete profile", "content_type": 11}}, {"pk": 34, "model": "auth.permission", "fields": {"codename": "add_question", "name": "Can add question", "content_type": 12}}, {"pk": 40, "model": "auth.permission", "fields": {"codename": "change_question", "name": "Can change question", "content_type": 12}}, {"pk": 46, "model": "auth.permission", "fields": {"codename": "delete_question", "name": "Can delete question", "content_type": 12}}, {"pk": 35, "model": "auth.permission", "fields": {"codename": "add_questionpaper", "name": "Can add question paper", "content_type": 15}}, {"pk": 41, "model": "auth.permission", "fields": {"codename": "change_questionpaper", "name": "Can change question paper", "content_type": 15}}, {"pk": 47, "model": "auth.permission", "fields": {"codename": "delete_questionpaper", "name": "Can delete question paper", "content_type": 15}}, {"pk": 36, "model": "auth.permission", "fields": {"codename": "add_quiz", "name": "Can add quiz", "content_type": 14}}, {"pk": 42, "model": "auth.permission", "fields": {"codename": "change_quiz", "name": "Can change quiz", "content_type": 14}}, {"pk": 48, "model": "auth.permission", "fields": {"codename": "delete_quiz", "name": "Can delete quiz", "content_type": 14}}, {"pk": 13, "model": "auth.permission", "fields": {"codename": "add_session", "name": "Can add session", "content_type": 5}}, {"pk": 14, "model": "auth.permission", "fields": {"codename": "change_session", "name": "Can change session", "content_type": 5}}, {"pk": 15, "model": "auth.permission", "fields": {"codename": "delete_session", "name": "Can delete session", "content_type": 5}}, {"pk": 16, "model": "auth.permission", "fields": {"codename": "add_site", "name": "Can add site", "content_type": 6}}, {"pk": 17, "model": "auth.permission", "fields": {"codename": "change_site", "name": "Can change site", "content_type": 6}}, {"pk": 18, "model": "auth.permission", "fields": {"codename": "delete_site", "name": "Can delete site", "content_type": 6}}, {"pk": 28, "model": "auth.permission", "fields": {"codename": "add_migrationhistory", "name": "Can add migration history", "content_type": 10}}, {"pk": 29, "model": "auth.permission", "fields": {"codename": "change_migrationhistory", "name": "Can change migration history", "content_type": 10}}, {"pk": 30, "model": "auth.permission", "fields": {"codename": "delete_migrationhistory", "name": "Can delete migration history", "content_type": 10}}, {"pk": 22, "model": "auth.permission", "fields": {"codename": "add_tag", "name": "Can add Tag", "content_type": 8}}, {"pk": 24, "model": "auth.permission", "fields": {"codename": "change_tag", "name": "Can change Tag", "content_type": 8}}, {"pk": 26, "model": "auth.permission", "fields": {"codename": "delete_tag", "name": "Can delete Tag", "content_type": 8}}, {"pk": 23, "model": "auth.permission", "fields": {"codename": "add_taggeditem", "name": "Can add Tagged Item", "content_type": 9}}, {"pk": 25, "model": "auth.permission", "fields": {"codename": "change_taggeditem", "name": "Can change Tagged Item", "content_type": 9}}, {"pk": 27, "model": "auth.permission", "fields": {"codename": "delete_taggeditem", "name": "Can delete Tagged Item", "content_type": 9}}, {"pk": 1, "model": "auth.group", "fields": {"name": "moderator", "permissions": [31, 37, 43, 32, 38, 44, 33, 39, 45, 34, 40, 46, 35, 41, 47, 36, 42, 48]}}, {"pk": 1, "model": "auth.user", "fields": {"username": "hardik", "first_name": "", "last_name": "", "is_active": true, "is_superuser": true, "is_staff": true, "last_login": "2012-03-29T14:24:20.574", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$10000$lO6jpTBhhIwc$MxX0yI3Swtyzu33IWbxgRL64+pkuXN8F2Xf6kSzbTAI=", "email": "hardik@fossee.in", "date_joined": "2012-03-29T14:23:03.243"}}, {"pk": 2, "model": "auth.user", "fields": {"username": "hardy", "first_name": "", "last_name": "", "is_active": true, "is_superuser": false, "is_staff": false, "last_login": "2012-03-29T14:24:06", "groups": [1], "user_permissions": [], "password": "pbkdf2_sha256$10000$nrVGBlzheCeE$FHnLmLuY4ZoSwrW4y20d6ArwkLwmPteDbEr0fJhUmNs=", "email": "", "date_joined": "2012-03-29T14:24:06"}}, {"pk": 3, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2012-03-29T14:24:45.862", "object_repr": "hardy", "object_id": "2", "change_message": "Changed password and groups.", "user": 1, "content_type": 3}}, {"pk": 2, "model": "admin.logentry", "fields": {"action_flag": 1, "action_time": "2012-03-29T14:24:43.450", "object_repr": "moderator", "object_id": "1", "change_message": "", "user": 1, "content_type": 2}}, {"pk": 1, "model": "admin.logentry", "fields": {"action_flag": 1, "action_time": "2012-03-29T14:24:06.815", "object_repr": "hardy", "object_id": "2", "change_message": "", "user": 1, "content_type": 3}}]
\ No newline at end of file @@ -20,6 +20,7 @@ setup( entry_points = { 'console_scripts': [ 'code_server = testapp.exam.code_server:main', + 'vimarsh = testapp.scripts.vimarsh:main', ], }, description='A django app to conduct online tests.', diff --git a/testapp/exam/fixtures/initial_data.json b/testapp/exam/fixtures/initial_data.json new file mode 100644 index 0000000..31c6496 --- /dev/null +++ b/testapp/exam/fixtures/initial_data.json @@ -0,0 +1 @@ +[{"pk": 1, "model": "contenttypes.contenttype", "fields": {"model": "logentry", "name": "log entry", "app_label": "admin"}}, {"pk": 2, "model": "contenttypes.contenttype", "fields": {"model": "permission", "name": "permission", "app_label": "auth"}}, {"pk": 3, "model": "contenttypes.contenttype", "fields": {"model": "group", "name": "group", "app_label": "auth"}}, {"pk": 4, "model": "contenttypes.contenttype", "fields": {"model": "user", "name": "user", "app_label": "auth"}}, {"pk": 5, "model": "contenttypes.contenttype", "fields": {"model": "contenttype", "name": "content type", "app_label": "contenttypes"}}, {"pk": 6, "model": "contenttypes.contenttype", "fields": {"model": "session", "name": "session", "app_label": "sessions"}}, {"pk": 7, "model": "contenttypes.contenttype", "fields": {"model": "profile", "name": "profile", "app_label": "exam"}}, {"pk": 8, "model": "contenttypes.contenttype", "fields": {"model": "question", "name": "question", "app_label": "exam"}}, {"pk": 9, "model": "contenttypes.contenttype", "fields": {"model": "answer", "name": "answer", "app_label": "exam"}}, {"pk": 10, "model": "contenttypes.contenttype", "fields": {"model": "quiz", "name": "quiz", "app_label": "exam"}}, {"pk": 11, "model": "contenttypes.contenttype", "fields": {"model": "questionpaper", "name": "question paper", "app_label": "exam"}}, {"pk": 12, "model": "contenttypes.contenttype", "fields": {"model": "questionset", "name": "question set", "app_label": "exam"}}, {"pk": 13, "model": "contenttypes.contenttype", "fields": {"model": "answerpaper", "name": "answer paper", "app_label": "exam"}}, {"pk": 14, "model": "contenttypes.contenttype", "fields": {"model": "assignmentupload", "name": "assignment upload", "app_label": "exam"}}, {"pk": 15, "model": "contenttypes.contenttype", "fields": {"model": "testcase", "name": "test case", "app_label": "exam"}}, {"pk": 16, "model": "contenttypes.contenttype", "fields": {"model": "tag", "name": "Tag", "app_label": "taggit"}}, {"pk": 17, "model": "contenttypes.contenttype", "fields": {"model": "taggeditem", "name": "Tagged Item", "app_label": "taggit"}}, {"pk": "k3vvnuppdw1u5tq26jzoysow086ua5sk", "model": "sessions.session", "fields": {"expire_date": "2015-07-01T06:16:14.520", "session_data": "YjY4Mjg0Yjg4ZGI3OTIxYjc5NTY5NmNkMTgyMTQ4MGRmOTViNDRmOTp7fQ=="}}, {"pk": 1, "model": "exam.question", "fields": {"ref_code_path": "", "description": "\r\nWrite a function called <code>fact</code> which takes a single integer argument\r\n(say <code>n</code>) and returns the factorial of the number. \r\nFor example:<br/>\r\n<code>fact(3) -> 6</code>\r\n", "language": "python", "summary": "Factorial", "snippet": "def fact(num):", "active": true, "points": 2.0, "test": "assert fact(0) == 1\r\nassert fact(5) == 120\r\n", "type": "code", "options": ""}}, {"pk": 2, "model": "exam.question", "fields": {"ref_code_path": "", "description": "Create a simple function called <code>sqr</code> which takes a single \r\nargument and returns the square of the argument. For example: <br/>\r\n<code>sqr(3) -> 9</code>.", "language": "python", "summary": "Simple function", "snippet": "def sqr(num):", "active": true, "points": 1.0, "test": "import math\r\nassert sqr(3) == 9\r\nassert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 \r\n ", "type": "code", "options": ""}}, {"pk": 3, "model": "exam.question", "fields": {"ref_code_path": "docs/sample.sh, docs/sample.args", "description": "Write a shell script which takes two arguments on the\r\n command line and prints the sum of the two on the output.", "language": "bash", "summary": "Bash addition", "snippet": "#!/bin/bash", "active": true, "points": 2.0, "test": "\r\n", "type": "code", "options": ""}}, {"pk": 4, "model": "exam.question", "fields": {"ref_code_path": "", "description": "What is the largest integer value that can be represented\r\nin Python?", "language": "python", "summary": "Size of integer in Python", "snippet": "", "active": true, "points": 0.5, "test": "No Limit", "type": "mcq", "options": "No Limit\r\n2**32\r\n2**32 - 1\r\nNone of the above\r\n"}}, {"pk": 1, "model": "exam.quiz", "fields": {"description": "Demo Quiz", "language": "python", "time_between_attempts": 0, "pass_criteria": 5.0, "active": true, "attempts_allowed": -1, "duration": 45, "start_date": "2015-06-17", "prerequisite": null}}, {"pk": 1, "model": "exam.questionpaper", "fields": {"shuffle_questions": false, "total_marks": 5.5, "fixed_questions": [1, 2, 3, 4], "random_questions": [], "quiz": 1}}, {"pk": 1, "model": "taggit.tag", "fields": {"name": "Python", "slug": "python"}}, {"pk": 2, "model": "taggit.tag", "fields": {"name": "function", "slug": "function"}}, {"pk": 3, "model": "taggit.tag", "fields": {"name": "factorial", "slug": "factorial"}}, {"pk": 4, "model": "taggit.tag", "fields": {"name": "", "slug": ""}}, {"pk": 5, "model": "taggit.tag", "fields": {"name": "mcq", "slug": "mcq"}}, {"pk": 8, "model": "taggit.taggeditem", "fields": {"tag": 1, "content_type": 8, "object_id": 1}}, {"pk": 9, "model": "taggit.taggeditem", "fields": {"tag": 2, "content_type": 8, "object_id": 1}}, {"pk": 10, "model": "taggit.taggeditem", "fields": {"tag": 3, "content_type": 8, "object_id": 1}}, {"pk": 11, "model": "taggit.taggeditem", "fields": {"tag": 1, "content_type": 8, "object_id": 2}}, {"pk": 12, "model": "taggit.taggeditem", "fields": {"tag": 2, "content_type": 8, "object_id": 2}}, {"pk": 13, "model": "taggit.taggeditem", "fields": {"tag": 5, "content_type": 8, "object_id": 4}}, {"pk": 1, "model": "auth.permission", "fields": {"codename": "add_logentry", "name": "Can add log entry", "content_type": 1}}, {"pk": 2, "model": "auth.permission", "fields": {"codename": "change_logentry", "name": "Can change log entry", "content_type": 1}}, {"pk": 3, "model": "auth.permission", "fields": {"codename": "delete_logentry", "name": "Can delete log entry", "content_type": 1}}, {"pk": 4, "model": "auth.permission", "fields": {"codename": "add_permission", "name": "Can add permission", "content_type": 2}}, {"pk": 5, "model": "auth.permission", "fields": {"codename": "change_permission", "name": "Can change permission", "content_type": 2}}, {"pk": 6, "model": "auth.permission", "fields": {"codename": "delete_permission", "name": "Can delete permission", "content_type": 2}}, {"pk": 7, "model": "auth.permission", "fields": {"codename": "add_group", "name": "Can add group", "content_type": 3}}, {"pk": 8, "model": "auth.permission", "fields": {"codename": "change_group", "name": "Can change group", "content_type": 3}}, {"pk": 9, "model": "auth.permission", "fields": {"codename": "delete_group", "name": "Can delete group", "content_type": 3}}, {"pk": 10, "model": "auth.permission", "fields": {"codename": "add_user", "name": "Can add user", "content_type": 4}}, {"pk": 11, "model": "auth.permission", "fields": {"codename": "change_user", "name": "Can change user", "content_type": 4}}, {"pk": 12, "model": "auth.permission", "fields": {"codename": "delete_user", "name": "Can delete user", "content_type": 4}}, {"pk": 13, "model": "auth.permission", "fields": {"codename": "add_contenttype", "name": "Can add content type", "content_type": 5}}, {"pk": 14, "model": "auth.permission", "fields": {"codename": "change_contenttype", "name": "Can change content type", "content_type": 5}}, {"pk": 15, "model": "auth.permission", "fields": {"codename": "delete_contenttype", "name": "Can delete content type", "content_type": 5}}, {"pk": 16, "model": "auth.permission", "fields": {"codename": "add_session", "name": "Can add session", "content_type": 6}}, {"pk": 17, "model": "auth.permission", "fields": {"codename": "change_session", "name": "Can change session", "content_type": 6}}, {"pk": 18, "model": "auth.permission", "fields": {"codename": "delete_session", "name": "Can delete session", "content_type": 6}}, {"pk": 19, "model": "auth.permission", "fields": {"codename": "add_profile", "name": "Can add profile", "content_type": 7}}, {"pk": 20, "model": "auth.permission", "fields": {"codename": "change_profile", "name": "Can change profile", "content_type": 7}}, {"pk": 21, "model": "auth.permission", "fields": {"codename": "delete_profile", "name": "Can delete profile", "content_type": 7}}, {"pk": 22, "model": "auth.permission", "fields": {"codename": "add_question", "name": "Can add question", "content_type": 8}}, {"pk": 23, "model": "auth.permission", "fields": {"codename": "change_question", "name": "Can change question", "content_type": 8}}, {"pk": 24, "model": "auth.permission", "fields": {"codename": "delete_question", "name": "Can delete question", "content_type": 8}}, {"pk": 25, "model": "auth.permission", "fields": {"codename": "add_answer", "name": "Can add answer", "content_type": 9}}, {"pk": 26, "model": "auth.permission", "fields": {"codename": "change_answer", "name": "Can change answer", "content_type": 9}}, {"pk": 27, "model": "auth.permission", "fields": {"codename": "delete_answer", "name": "Can delete answer", "content_type": 9}}, {"pk": 28, "model": "auth.permission", "fields": {"codename": "add_quiz", "name": "Can add quiz", "content_type": 10}}, {"pk": 29, "model": "auth.permission", "fields": {"codename": "change_quiz", "name": "Can change quiz", "content_type": 10}}, {"pk": 30, "model": "auth.permission", "fields": {"codename": "delete_quiz", "name": "Can delete quiz", "content_type": 10}}, {"pk": 31, "model": "auth.permission", "fields": {"codename": "add_questionpaper", "name": "Can add question paper", "content_type": 11}}, {"pk": 32, "model": "auth.permission", "fields": {"codename": "change_questionpaper", "name": "Can change question paper", "content_type": 11}}, {"pk": 33, "model": "auth.permission", "fields": {"codename": "delete_questionpaper", "name": "Can delete question paper", "content_type": 11}}, {"pk": 34, "model": "auth.permission", "fields": {"codename": "add_questionset", "name": "Can add question set", "content_type": 12}}, {"pk": 35, "model": "auth.permission", "fields": {"codename": "change_questionset", "name": "Can change question set", "content_type": 12}}, {"pk": 36, "model": "auth.permission", "fields": {"codename": "delete_questionset", "name": "Can delete question set", "content_type": 12}}, {"pk": 37, "model": "auth.permission", "fields": {"codename": "add_answerpaper", "name": "Can add answer paper", "content_type": 13}}, {"pk": 38, "model": "auth.permission", "fields": {"codename": "change_answerpaper", "name": "Can change answer paper", "content_type": 13}}, {"pk": 39, "model": "auth.permission", "fields": {"codename": "delete_answerpaper", "name": "Can delete answer paper", "content_type": 13}}, {"pk": 40, "model": "auth.permission", "fields": {"codename": "add_assignmentupload", "name": "Can add assignment upload", "content_type": 14}}, {"pk": 41, "model": "auth.permission", "fields": {"codename": "change_assignmentupload", "name": "Can change assignment upload", "content_type": 14}}, {"pk": 42, "model": "auth.permission", "fields": {"codename": "delete_assignmentupload", "name": "Can delete assignment upload", "content_type": 14}}, {"pk": 43, "model": "auth.permission", "fields": {"codename": "add_testcase", "name": "Can add test case", "content_type": 15}}, {"pk": 44, "model": "auth.permission", "fields": {"codename": "change_testcase", "name": "Can change test case", "content_type": 15}}, {"pk": 45, "model": "auth.permission", "fields": {"codename": "delete_testcase", "name": "Can delete test case", "content_type": 15}}, {"pk": 46, "model": "auth.permission", "fields": {"codename": "add_tag", "name": "Can add Tag", "content_type": 16}}, {"pk": 47, "model": "auth.permission", "fields": {"codename": "change_tag", "name": "Can change Tag", "content_type": 16}}, {"pk": 48, "model": "auth.permission", "fields": {"codename": "delete_tag", "name": "Can delete Tag", "content_type": 16}}, {"pk": 49, "model": "auth.permission", "fields": {"codename": "add_taggeditem", "name": "Can add Tagged Item", "content_type": 17}}, {"pk": 50, "model": "auth.permission", "fields": {"codename": "change_taggeditem", "name": "Can change Tagged Item", "content_type": 17}}, {"pk": 51, "model": "auth.permission", "fields": {"codename": "delete_taggeditem", "name": "Can delete Tagged Item", "content_type": 17}}, {"pk": 1, "model": "auth.group", "fields": {"name": "moderator", "permissions": [25, 26, 27, 37, 38, 39, 40, 41, 42, 19, 20, 21, 22, 23, 24, 31, 32, 33, 34, 35, 36, 28, 29, 30, 43, 44, 45]}}, {"pk": 1, "model": "auth.user", "fields": {"username": "admin", "first_name": "", "last_name": "", "is_active": true, "is_superuser": true, "is_staff": true, "last_login": "2015-06-17T06:01:17.713", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$12000$8rJ0GgvuOHBH$5IFAyZYQsLDIivWuyxFaNpdXZmi0y67tjGvrCsqfcxs=", "email": "admin@admin.com", "date_joined": "2015-06-17T05:48:57.913"}}, {"pk": 2, "model": "auth.user", "fields": {"username": "student", "first_name": "Ek", "last_name": "Alavya", "is_active": true, "is_superuser": false, "is_staff": false, "last_login": "2015-06-17T05:56:48.295", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$12000$6uK7B3LL99I7$zZP8jAypXrP+zhb+BqRURGsrwcgoOeXQSr5FZz8anhg=", "email": "student@email.com", "date_joined": "2015-06-17T05:56:47.370"}}, {"pk": 3, "model": "auth.user", "fields": {"username": "teacher", "first_name": "Drona", "last_name": "Acharya", "is_active": true, "is_superuser": false, "is_staff": false, "last_login": "2015-06-17T06:11:24.812", "groups": [1], "user_permissions": [], "password": "pbkdf2_sha256$12000$SlSEt2Gr65Ac$QOsIXymGbbwVRF5+MNVmuIgN00DDpX6TBuYZai6KHp8=", "email": "teacher@email.com", "date_joined": "2015-06-17T06:00:04"}}, {"pk": 1, "model": "exam.profile", "fields": {"institute": "Institute", "department": "Department", "roll_number": "1234", "user": 2, "position": "Student"}}, {"pk": 2, "model": "exam.profile", "fields": {"institute": "Institute", "department": "Department", "roll_number": "4321", "user": 3, "position": "Faculty"}}, {"pk": 1, "model": "admin.logentry", "fields": {"action_flag": 1, "action_time": "2015-06-17T06:01:45.480", "object_repr": "moderator", "object_id": "1", "change_message": "", "user": 1, "content_type": 3}}, {"pk": 2, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2015-06-17T06:01:57.916", "object_repr": "teacher", "object_id": "3", "change_message": "Changed groups.", "user": 1, "content_type": 4}}]
\ No newline at end of file diff --git a/testapp/exam/language_registry.py b/testapp/exam/language_registry.py index 76a23d7..63f07ef 100644 --- a/testapp/exam/language_registry.py +++ b/testapp/exam/language_registry.py @@ -1,4 +1,4 @@ -from settings import code_evaluators +from testapp.exam.settings import code_evaluators import importlib registry = None diff --git a/testapp/scripts/__init__.py b/testapp/scripts/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/testapp/scripts/__init__.py diff --git a/testapp/scripts/project_detail.py b/testapp/scripts/project_detail.py new file mode 100644 index 0000000..583e9f4 --- /dev/null +++ b/testapp/scripts/project_detail.py @@ -0,0 +1,2 @@ +NAME = None +PATH = None diff --git a/testapp/scripts/vimarsh.py b/testapp/scripts/vimarsh.py new file mode 100644 index 0000000..863193a --- /dev/null +++ b/testapp/scripts/vimarsh.py @@ -0,0 +1,127 @@ +import subprocess +import contextlib +import os +from os import path +import argparse +from django.conf import settings +from django.core import management +from django.template import Template, Context, loader + +from project_detail import NAME, PATH + +CUR_DIR = os.getcwd() +SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) +PARENT_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) +TEMPLATE_DIR = path.join(PARENT_DIR, 'templates') + +def main(): + #Parse command-line to obtain the arguments and/or options + help_msg = ("Enter the subcommand to be executed.\n" + "Available subcommands:\n" + " - create_demo <projectname> [destination-path]\n" + " - run_demo") + + parser = argparse.ArgumentParser(prog="vimarsh", + usage="vimarsh.py subcommand [args]", + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument("subcommand", type=str, nargs='+', help=help_msg) + args = parser.parse_args() + + if args.subcommand[0] == "create_demo": + if len(args.subcommand) > 3 or len(args.subcommand) <= 1: + parser.print_help() + elif len(args.subcommand) == 3: + project_name = args.subcommand[1] + project_dir = args.subcommand[2] + create_demo(args.subcommand[1], args.subcommand[2]) + else: + project_name = args.subcommand[1] + create_demo(args.subcommand[1]) + + elif args.subcommand[0] == "run_demo": + if len(args.subcommand) != 1: + parser.print_help() + else: + try: + run_demo(NAME, PATH) + except Exception, e: + if not NAME or not PATH: + print "Error: Unable to find Project Name and Path variables\n" + else: + print "Error: ", e, "\n" + parser.print_help() + + else: + parser.print_help() + + +def create_demo(project_name='vimarsh_demo', project_dir=None): + try: + management.call_command('startproject', project_name, project_dir) + print "Demo Django project '{0}' created at '{1}'" + except Exception, e: + print "Error: ", e, "\nExiting Vimarsh Installer" + + if project_dir is None: + top_dir = path.join(os.getcwd(), project_name) + else: + top_dir = project_dir + + project_path = path.join(top_dir, project_name) + # Store project details + _set_project_details(project_name, top_dir) + + with _chdir(project_path): + root_urlconf = "{0}.{1}".format(project_name, 'demo_urls') + settings_template_path = path.join(TEMPLATE_DIR, 'demo_settings.py') + settings_target_path = path.join(project_path, 'demo_settings.py') + settings_context = Context({'project_name': project_name, # 'custom_apps': custom_apps, + 'root_urlconf': root_urlconf}) + urls_template_path = path.join(TEMPLATE_DIR, 'demo_urls.py') + urls_target_path = path.join(project_path, 'demo_urls.py') + command = ("python ../manage.py syncdb " + "--noinput --settings={0}.demo_settings").format(project_name) + + # Create demo_settings file + _render_demo_files(settings_template_path, settings_target_path, settings_context) + # Create demo_urls file + _render_demo_files(urls_template_path, urls_target_path) + # Run syncdb + subprocess.call(command, shell=True) + +def run_demo(project_name, top_dir): + with _chdir(top_dir): + project_path = path.join(top_dir, 'manage.py') + command = ("python manage.py runserver " + "--settings={0}.demo_settings").format(project_name) + subprocess.call(command, shell=True) + +def _set_project_details(project_name, top_dir): + file_path = path.join(SCRIPT_DIR, 'project_detail.py') + detail = "NAME ='{0}'\nPATH ='{1}'".format(project_name, top_dir) + with open(file_path, 'w') as data_store: + data_store.write(detail) + +def _render_demo_files(template_path, output_path, context=None): + with open(template_path, 'r') as template_file: + content = template_file.read() + if context: + content = content.decode('utf-8') + template = Template(content) + content = template.render(context) + content = content.encode('utf-8') + + with open(output_path, 'w') as new_file: + new_file.write(content) + +@contextlib.contextmanager +def _chdir(path): + starting_directory = os.getcwd() + try: + os.chdir(path) + yield + finally: + os.chdir(starting_directory) + +if __name__ == '__main__': + main() diff --git a/testapp/templates/demo_settings.py b/testapp/templates/demo_settings.py new file mode 100644 index 0000000..d731dc2 --- /dev/null +++ b/testapp/templates/demo_settings.py @@ -0,0 +1,87 @@ +""" +Django settings for my_demo project. + +For more information on this file, see +https://docs.djangoproject.com/en/1.6/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.6/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'TH!S_!S_@_DUMMY_K3Y' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +TEMPLATE_DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'testapp.exam', + 'taggit', + 'taggit_autocomplete_modified', +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = '{{ root_urlconf }}' + +WSGI_APPLICATION = '{{ project_name }}.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.6/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + +# Internationalization +# https://docs.djangoproject.com/en/1.6/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = False + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.6/howto/static-files/ + +STATIC_URL = '/static/' + +AUTH_PROFILE_MODULE = 'exam.Profile' |