summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-01-16 21:59:30 +0530
committerGitHub2017-01-16 21:59:30 +0530
commit10b4635ab0684a698382a3e167ef546bb3ff97b7 (patch)
treecf75812acecffeb81081c9ba2632dfca481dd2ad /yaksh
parentd03826261adae349151e28d09ea2e2f85e168909 (diff)
parent67ed7f2a9bd137d746f1535cd3faee4d42bdbc9b (diff)
downloadonline_test-10b4635ab0684a698382a3e167ef546bb3ff97b7.tar.gz
online_test-10b4635ab0684a698382a3e167ef546bb3ff97b7.tar.bz2
online_test-10b4635ab0684a698382a3e167ef546bb3ff97b7.zip
Merge pull request #177 from adityacp/fix_management_commands
Fix management commands
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/demo_templates/demo_settings.py70
-rw-r--r--yaksh/demo_templates/demo_urls.py7
-rw-r--r--yaksh/fixtures/demo_fixtures.json190
-rw-r--r--yaksh/fixtures/demo_questions.zipbin1510 -> 4430 bytes
-rw-r--r--yaksh/models.py47
-rw-r--r--yaksh/scripts/cli.py14
-rw-r--r--yaksh/views.py7
7 files changed, 314 insertions, 21 deletions
diff --git a/yaksh/demo_templates/demo_settings.py b/yaksh/demo_templates/demo_settings.py
index 4e12463..3c38794 100644
--- a/yaksh/demo_templates/demo_settings.py
+++ b/yaksh/demo_templates/demo_settings.py
@@ -10,8 +10,13 @@ https://docs.djangoproject.com/en/1.6/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
+import tempfile
+from yaksh.pipeline.settings import AUTH_PIPELINE
+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+# The directory where user data can be saved.
+OUTPUT_DIR = os.path.join(tempfile.gettempdir(), 'output')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
@@ -22,10 +27,9 @@ 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 = []
+URL_ROOT = ''
# Application definition
@@ -40,6 +44,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'yaksh',
'taggit',
+ 'social.apps.django_app.default',
)
MIDDLEWARE_CLASSES = (
@@ -49,6 +54,9 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ 'yaksh.middleware.one_session_per_user.OneSessionPerUserMiddleware',
+ 'yaksh.middleware.user_time_zone.TimezoneMiddleware',
+ 'social.apps.django_app.middleware.SocialAuthExceptionMiddleware',
)
ROOT_URLCONF = '{{ root_urlconf }}'
@@ -77,7 +85,7 @@ USE_I18N = True
USE_L10N = True
-USE_TZ = False
+USE_TZ = True
# Static files (CSS, JavaScript, Images)
@@ -85,4 +93,58 @@ USE_TZ = False
STATIC_URL = '/static/'
-AUTH_PROFILE_MODULE = 'yaksh.Profile'
+LOGIN_URL = '/exam/login/'
+
+LOGIN_REDIRECT_URL = '/exam/'
+
+MEDIA_URL = "/data/"
+
+MEDIA_ROOT = os.path.join(BASE_DIR, "yaksh", "data")
+
+SOCIAL_AUTH_LOGIN_ERROR_URL = '/exam/login/'
+
+EMAIL_USE_TLS = False
+
+EMAIL_HOST = 'your_email_host'
+
+EMAIL_PORT = 'your_email_port'
+
+EMAIL_HOST_USER = 'email_host_user'
+
+DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'APP_DIRS': True,
+ 'DIRS': ['yaksh/templates'],
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.contrib.auth.context_processors.auth',
+ 'social.apps.django_app.context_processors.backends',
+ 'social.apps.django_app.context_processors.login_redirect',
+ ],
+ 'debug': False,
+ }
+ },
+]
+
+SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'GOOGLE_KEY_PROVIDED'
+SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'GOOGLE_SECRET_PROVIDED'
+
+SOCIAL_AUTH_FACEBOOK_KEY = 'FACEBOOK_KEY_PROVIDED'
+SOCIAL_AUTH_FACEBOOK_SECRET = 'FACEBOOK_SECRET_PROVIDED'
+
+AUTHENTICATION_BACKENDS = (
+ 'social.backends.google.GoogleOAuth2',
+ 'social.backends.facebook.FacebookOAuth2',
+ 'django.contrib.auth.backends.ModelBackend',
+)
+
+SOCIAL_AUTH_PIPELINE = AUTH_PIPELINE
+
+SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
+SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
+ 'fields': 'id, name, email'
+
+}
diff --git a/yaksh/demo_templates/demo_urls.py b/yaksh/demo_templates/demo_urls.py
index d99e473..5abc121 100644
--- a/yaksh/demo_templates/demo_urls.py
+++ b/yaksh/demo_templates/demo_urls.py
@@ -1,5 +1,6 @@
from django.conf.urls import patterns, include, url
-
+from django.conf import settings
+from django.conf.urls.static import static
from django.contrib import admin
admin.autodiscover()
@@ -9,5 +10,7 @@ urlpatterns = patterns('',
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
- url(r'^exam/', include('yaksh.urls')),
+ url(r'^exam/', include('yaksh.urls', namespace='yaksh', app_name='yaksh')),
+ url(r'^', include('social.apps.django_app.urls', namespace='social')),
)
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file
diff --git a/yaksh/fixtures/demo_fixtures.json b/yaksh/fixtures/demo_fixtures.json
index 517c2b2..779d4f9 100644
--- a/yaksh/fixtures/demo_fixtures.json
+++ b/yaksh/fixtures/demo_fixtures.json
@@ -1 +1,189 @@
-[{"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": "yaksh"}}, {"pk": 8, "model": "contenttypes.contenttype", "fields": {"model": "question", "name": "question", "app_label": "yaksh"}}, {"pk": 9, "model": "contenttypes.contenttype", "fields": {"model": "answer", "name": "answer", "app_label": "yaksh"}}, {"pk": 10, "model": "contenttypes.contenttype", "fields": {"model": "quiz", "name": "quiz", "app_label": "yaksh"}}, {"pk": 11, "model": "contenttypes.contenttype", "fields": {"model": "questionpaper", "name": "question paper", "app_label": "yaksh"}}, {"pk": 12, "model": "contenttypes.contenttype", "fields": {"model": "questionset", "name": "question set", "app_label": "yaksh"}}, {"pk": 13, "model": "contenttypes.contenttype", "fields": {"model": "answerpaper", "name": "answer paper", "app_label": "yaksh"}}, {"pk": 14, "model": "contenttypes.contenttype", "fields": {"model": "assignmentupload", "name": "assignment upload", "app_label": "yaksh"}}, {"pk": 15, "model": "contenttypes.contenttype", "fields": {"model": "testcase", "name": "test case", "app_label": "yaksh"}}, {"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": "kib1c35u44b8wleb8nltl5rkqwcsyrhr", "model": "sessions.session", "fields": {"expire_date": "2015-10-22T06:05:31.984", "session_data": "YjY4Mjg0Yjg4ZGI3OTIxYjc5NTY5NmNkMTgyMTQ4MGRmOTViNDRmOTp7fQ=="}}, {"pk": 1, "model": "yaksh.question", "fields": {"ref_code_path": "", "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", "language": "python", "summary": "Factorial", "snippet": "def fact(num):", "active": true, "points": 2.0, "test": "\nassert fact(0) == 1\nassert fact(5) == 120\n", "type": "code", "options": ""}}, {"pk": 2, "model": "yaksh.question", "fields": {"ref_code_path": "", "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>.", "language": "python", "summary": "Simple function", "snippet": "def sqr(num):", "active": true, "points": 1.0, "test": "\nimport math\nassert sqr(3) == 9\nassert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 \n ", "type": "code", "options": ""}}, {"pk": 3, "model": "yaksh.question", "fields": {"ref_code_path": "", "description": "Write a shell script which takes two arguments on the\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": "docs/sample.sh\ndocs/sample.args\n", "type": "code", "options": ""}}, {"pk": 4, "model": "yaksh.question", "fields": {"ref_code_path": "", "description": "What is the largest integer value that can be represented\nin Python?", "language": "python", "summary": "Size of integer in Python", "snippet": "", "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": "yaksh.quiz", "fields": {"start_date_time": "2015-10-08T05:54:38", "description": "Demo Quiz", "language": "python", "time_between_attempts": 0, "attempts_allowed": -1, "pass_criteria": 40.0, "active": true, "end_date_time": "2199-01-01T00:00:00", "duration": 20, "prerequisite": null}}, {"pk": 1, "model": "yaksh.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": 1, "model": "taggit.taggeditem", "fields": {"tag": 1, "content_type": 8, "object_id": 1}}, {"pk": 2, "model": "taggit.taggeditem", "fields": {"tag": 2, "content_type": 8, "object_id": 1}}, {"pk": 3, "model": "taggit.taggeditem", "fields": {"tag": 3, "content_type": 8, "object_id": 1}}, {"pk": 4, "model": "taggit.taggeditem", "fields": {"tag": 1, "content_type": 8, "object_id": 2}}, {"pk": 5, "model": "taggit.taggeditem", "fields": {"tag": 2, "content_type": 8, "object_id": 2}}, {"pk": 6, "model": "taggit.taggeditem", "fields": {"tag": 4, "content_type": 8, "object_id": 3}}, {"pk": 7, "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-10-08T06:01:15.263", "groups": [1], "user_permissions": [], "password": "pbkdf2_sha256$12000$qartiEZkS5K0$wP0uhbdYEcuvRXAveA2geMUcknL11UzwL+TS2r2pL2I=", "email": "admin@admin.com", "date_joined": "2015-10-08T05:51:13"}}, {"pk": 2, "model": "auth.user", "fields": {"username": "student", "first_name": "Student", "last_name": "Yaksh", "is_active": true, "is_superuser": false, "is_staff": false, "last_login": "2015-10-08T06:05:29.551", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$12000$iRBPv5gvit8o$xKheYrWGGL4c3WN/F7j5UlRkmjAy9hx1BWWhdhd9uh0=", "email": "student@yaksh.xyz", "date_joined": "2015-10-08T05:55:56.956"}}, {"pk": 3, "model": "auth.user", "fields": {"username": "teacher", "first_name": "Teacher", "last_name": "Yaksh", "is_active": true, "is_superuser": false, "is_staff": false, "last_login": "2015-10-08T06:01:51.536", "groups": [1], "user_permissions": [], "password": "pbkdf2_sha256$12000$J6BkGV3t0Ajz$Q0LPr2588cYNBjWsw+PyY+Kzc4FcrWojtZek5iZ4LA8=", "email": "teacher@yaksh.xyz", "date_joined": "2015-10-08T05:57:52"}}, {"pk": 1, "model": "yaksh.profile", "fields": {"institute": "Demo Institute", "department": "Demo Department", "roll_number": "1", "user": 2, "position": "Student"}}, {"pk": 2, "model": "yaksh.profile", "fields": {"institute": "Demo Institute", "department": "Demo Department", "roll_number": "2", "user": 3, "position": "Teacher"}}, {"pk": 1, "model": "admin.logentry", "fields": {"action_flag": 1, "action_time": "2015-10-08T05:58:41.912", "object_repr": "moderators", "object_id": "1", "change_message": "", "user": 1, "content_type": 3}}, {"pk": 2, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2015-10-08T05:59:22.724", "object_repr": "admin", "object_id": "1", "change_message": "Changed groups.", "user": 1, "content_type": 4}}, {"pk": 3, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2015-10-08T05:59:30.335", "object_repr": "teacher", "object_id": "3", "change_message": "Changed groups.", "user": 1, "content_type": 4}}, {"pk": 4, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2015-10-08T06:01:24.134", "object_repr": "moderator", "object_id": "1", "change_message": "Changed name.", "user": 1, "content_type": 3}}] \ No newline at end of file
+[
+{
+ "model": "auth.group",
+ "pk": 1,
+ "fields": {
+ "name": "moderator",
+ "permissions": [
+ 34,
+ 35,
+ 36,
+ 46,
+ 47,
+ 48,
+ 49,
+ 50,
+ 51,
+ 22,
+ 23,
+ 24,
+ 19,
+ 20,
+ 21,
+ 31,
+ 32,
+ 33,
+ 64,
+ 65,
+ 66,
+ 61,
+ 62,
+ 63,
+ 25,
+ 26,
+ 27,
+ 28,
+ 29,
+ 30,
+ 40,
+ 41,
+ 42,
+ 43,
+ 44,
+ 45,
+ 37,
+ 38,
+ 39,
+ 55,
+ 56,
+ 57,
+ 58,
+ 59,
+ 60,
+ 52,
+ 53,
+ 54
+ ]
+ }
+},
+{
+ "model": "auth.user",
+ "pk": 1,
+ "fields": {
+ "password": "pbkdf2_sha256$24000$MmYQQZFeXKAZ$yA6tEVLCd7HFwN5Zho6yUBxxm4ZpT04Rvo1/+K2lvlk=",
+ "last_login": "2017-01-09T05:55:35.578Z",
+ "is_superuser": true,
+ "username": "admin",
+ "first_name": "",
+ "last_name": "",
+ "email": "admin@mail.com",
+ "is_staff": true,
+ "is_active": true,
+ "date_joined": "2017-01-09T05:53:08.743Z",
+ "groups": [],
+ "user_permissions": []
+ }
+},
+{
+ "model": "auth.user",
+ "pk": 2,
+ "fields": {
+ "password": "pbkdf2_sha256$24000$VG6rNbuxpOht$epkN0rKp63rr14/0eHZPxB424CM62VZqiiB5SuEaZaQ=",
+ "last_login": "2017-01-09T05:58:13.210Z",
+ "is_superuser": false,
+ "username": "teacher",
+ "first_name": "Teacher",
+ "last_name": "Teacher",
+ "email": "teacher@mail.com",
+ "is_staff": false,
+ "is_active": true,
+ "date_joined": "2017-01-09T05:55:19Z",
+ "groups": [
+ 1
+ ],
+ "user_permissions": []
+ }
+},
+{
+ "model": "auth.user",
+ "pk": 3,
+ "fields": {
+ "password": "pbkdf2_sha256$24000$uvLwahv56EeP$2PVrFFhzeM+7VFwygYIg3eXRefBpaUhf+xXUuzs6w8E=",
+ "last_login": "2017-01-09T05:58:29.755Z",
+ "is_superuser": false,
+ "username": "student",
+ "first_name": "Student",
+ "last_name": "Student",
+ "email": "student@mail.com",
+ "is_staff": false,
+ "is_active": true,
+ "date_joined": "2017-01-09T05:57:02.954Z",
+ "groups": [],
+ "user_permissions": []
+ }
+},
+{
+ "model": "yaksh.concurrentuser",
+ "pk": 1,
+ "fields": {
+ "concurrent_user": 1,
+ "session_key": "jxiiylbd89c89o4gdym3pv99ctdbiykg"
+ }
+},
+{
+ "model": "yaksh.concurrentuser",
+ "pk": 2,
+ "fields": {
+ "concurrent_user": 2,
+ "session_key": "usatgwitj5kqz7pehukgujjtwqpr6j3f"
+ }
+},
+{
+ "model": "yaksh.concurrentuser",
+ "pk": 3,
+ "fields": {
+ "concurrent_user": 3,
+ "session_key": "s4iw5uwdutojr2a8bgu36x5qda1ctb69"
+ }
+},
+{
+ "model": "yaksh.profile",
+ "pk": 1,
+ "fields": {
+ "user": 2,
+ "roll_number": "12345",
+ "institute": "Demo",
+ "department": "Demo",
+ "position": "Faculty",
+ "timezone": "UTC"
+ }
+},
+{
+ "model": "yaksh.profile",
+ "pk": 2,
+ "fields": {
+ "user": 3,
+ "roll_number": "1234",
+ "institute": "demo",
+ "department": "demo",
+ "position": "Student",
+ "timezone": "UTC"
+ }
+},
+{
+ "model": "admin.logentry",
+ "pk": 1,
+ "fields": {
+ "action_time": "2017-01-09T05:53:57.249Z",
+ "user": 1,
+ "content_type": 3,
+ "object_id": "1",
+ "object_repr": "moderator",
+ "action_flag": 2,
+ "change_message": "No fields changed."
+ }
+},
+{
+ "model": "admin.logentry",
+ "pk": 2,
+ "fields": {
+ "action_time": "2017-01-09T05:55:45.973Z",
+ "user": 1,
+ "content_type": 4,
+ "object_id": "2",
+ "object_repr": "teacher",
+ "action_flag": 2,
+ "change_message": "Changed groups."
+ }
+}
+]
diff --git a/yaksh/fixtures/demo_questions.zip b/yaksh/fixtures/demo_questions.zip
index 562bf8a..c68e7ef 100644
--- a/yaksh/fixtures/demo_questions.zip
+++ b/yaksh/fixtures/demo_questions.zip
Binary files differ
diff --git a/yaksh/models.py b/yaksh/models.py
index 271ed6d..ca41885 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
from datetime import datetime, timedelta
import json
from random import sample, shuffle
@@ -22,6 +23,7 @@ from os.path import join, abspath, dirname, exists
import shutil
import zipfile
import tempfile
+from textwrap import dedent
from .file_utils import extract_files, delete_files
from yaksh.xmlrpc_clients import code_server
from django.conf import settings
@@ -65,6 +67,43 @@ test_status = (
('completed', 'Completed'),
)
+instructions_data = dedent("""\
+ <p>
+ This examination system has been developed with the intention of
+ making you learn programming and be assessed in an interactive and
+ fun manner. You will be presented with a series of programming questions
+ and problems that you will answer online and get immediate
+ feedback for.
+ </p>
+ <p>
+ Here are some important instructions and rules that you should
+ understand carefully.</p>
+ <ul>
+ <li>For any programming questions, you can submit solutions as many
+ times as you want without a penalty. You may skip questions
+ and solve them later.</li>
+ <li> You <strong>may</strong> use your computer's Python/IPython
+ shell or an editor to solve the problem and cut/paste the
+ solution to the web interface.
+ </li>
+ <li> <strong>You are not allowed to use any internet resources,
+ i.e. no google etc.</strong>
+ </li>
+ <li> Do not copy or share the questions or answers with anyone
+ until the exam is complete <strong>for everyone</strong>.
+ </li>
+ <li> <strong>All</strong> your attempts at the questions are logged.
+ Do not try to outsmart and break the testing system.
+ If you do, we know who you are and we will expel you from the
+ course. You have been warned.
+ </li>
+ </ul>
+ <p>
+ We hope you enjoy taking this
+ exam !!!
+ </p>
+ """)
+
def get_assignment_dir(instance, filename):
return '%s/%s/%s' % (instance.user.user, instance.assignmentQuestion.id, filename)
@@ -351,7 +390,7 @@ class Question(models.Model):
for file_name, extract in file_names:
q_file = os.path.join(path, file_name)
if os.path.exists(q_file):
- que_file = open(q_file, 'r')
+ que_file = open(q_file, 'rb')
# Converting to Python file object with
# some Django-specific additions
django_file = File(que_file)
@@ -378,8 +417,7 @@ class Question(models.Model):
self.load_questions(questions_list, user, file_path, files)
def create_demo_questions(self, user):
- zip_file_path = os.path.join(os.getcwd(), 'yaksh',
- 'fixtures', 'demo_questions.zip')
+ zip_file_path = os.path.join(settings.FIXTURE_DIRS, 'demo_questions.zip')
files, extract_path = extract_files(zip_file_path)
self.read_json(extract_path, user, files)
@@ -564,6 +602,7 @@ class Quiz(models.Model):
end_date_time=timezone.now() + timedelta(176590),
duration=30, active=True,
attempts_allowed=-1,
+ instructions=instructions_data,
time_between_attempts=0,
description='Yaksh Demo quiz', pass_criteria=0,
language='Python', prerequisite=None,
@@ -702,7 +741,7 @@ class QuestionPaper(models.Model):
def create_demo_quiz_ppr(self, demo_quiz, user):
question_paper = QuestionPaper.objects.create(quiz=demo_quiz,
- total_marks=7.0,
+ total_marks=6.0,
shuffle_questions=True
)
questions = Question.objects.filter(active=True,
diff --git a/yaksh/scripts/cli.py b/yaksh/scripts/cli.py
index 79523f9..1489af7 100644
--- a/yaksh/scripts/cli.py
+++ b/yaksh/scripts/cli.py
@@ -1,5 +1,6 @@
from __future__ import print_function
+import django
import subprocess
import contextlib
import os
@@ -8,15 +9,18 @@ import argparse
from importlib import import_module
from django.conf import settings
from django.core import management
-from django.template import Template, Context, loader
+from django.template import Template, Context
-from project_detail import NAME, PATH
+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, 'demo_templates')
+settings.configure()
+django.setup()
+
def main():
#Parse command-line to obtain the arguments and/or options
# create top-level parser object
@@ -72,7 +76,7 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR):
management.call_command('startproject', project_name, project_dir)
print("Demo Django project '{0}' created at '{1}'".format(project_name,
project_dir))
- except Exception, e:
+ except Exception as e:
print("Error: {0}\nExiting yaksh Installer".format(e))
if project_dir is None:
@@ -95,7 +99,7 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR):
'fixture_dir': fixture_dir})
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 "
+ command = ("python ../manage.py migrate --run-syncdb "
"--noinput --settings={0}.demo_settings").format(project_name)
loaddata_command = ("python ../manage.py loaddata "
@@ -132,10 +136,8 @@ 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)
diff --git a/yaksh/views.py b/yaksh/views.py
index 14faa9b..4be2fc1 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -267,7 +267,7 @@ def show_all_questionpapers(request, questionpaper_id=None):
@login_required
-def prof_manage(request):
+def prof_manage(request, msg=None):
"""Take credentials of the user with professor/moderator
rights/permissions and log in."""
user = request.user
@@ -301,7 +301,7 @@ def prof_manage(request):
temp = paper, answer_papers, users_passed, users_failed
users_per_paper.append(temp)
context = {'user': user, 'users_per_paper': users_per_paper,
- 'trial_paper': trial_paper
+ 'trial_paper': trial_paper, 'msg': msg
}
return my_render_to_response('yaksh/moderator_dashboard.html', context, context_instance=ci)
return my_redirect('/exam/login/')
@@ -1246,8 +1246,7 @@ def create_demo_course(request):
msg = "Created Demo course successfully"
else:
msg = "Demo course already created"
- context = {'msg': msg}
- return my_render_to_response('manage.html', context, context_instance=ci)
+ return prof_manage(request, msg)
@login_required