summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildout.cfg1
-rw-r--r--initial_fixtures.json1
-rw-r--r--testapp/exam/migrations/0001_initial.py193
-rw-r--r--testapp/exam/migrations/__init__.py0
-rw-r--r--testapp/exam/models.py15
-rw-r--r--testapp/exam/urls.py8
-rw-r--r--testapp/exam/views.py108
-rw-r--r--testapp/settings.py7
-rw-r--r--testapp/static/exam/css/base.css2
-rw-r--r--testapp/templates/exam/add_questionpaper.html54
-rw-r--r--testapp/templates/exam/add_quiz.html3
-rw-r--r--testapp/templates/exam/automatic_questionpaper.html101
-rw-r--r--testapp/templates/exam/editquestionpaper.html21
-rw-r--r--testapp/templates/exam/manual_questionpaper.html42
-rw-r--r--testapp/templates/exam/showquestionpapers.html21
-rw-r--r--testapp/templates/manage.html3
16 files changed, 372 insertions, 208 deletions
diff --git a/buildout.cfg b/buildout.cfg
index db1c35d..02aba05 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -5,6 +5,7 @@ eggs =
South
django-taggit
django-taggit-autocomplete-modified
+ django-debug-toolbar
[versions]
django = 1.3
diff --git a/initial_fixtures.json b/initial_fixtures.json
new file mode 100644
index 0000000..f7cbceb
--- /dev/null
+++ b/initial_fixtures.json
@@ -0,0 +1 @@
+[{"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
diff --git a/testapp/exam/migrations/0001_initial.py b/testapp/exam/migrations/0001_initial.py
deleted file mode 100644
index 49048cc..0000000
--- a/testapp/exam/migrations/0001_initial.py
+++ /dev/null
@@ -1,193 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Adding model 'Profile'
- db.create_table('exam_profile', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('user', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True)),
- ('roll_number', self.gf('django.db.models.fields.CharField')(max_length=20)),
- ('institute', self.gf('django.db.models.fields.CharField')(max_length=128)),
- ('department', self.gf('django.db.models.fields.CharField')(max_length=64)),
- ('position', self.gf('django.db.models.fields.CharField')(max_length=64)),
- ))
- db.send_create_signal('exam', ['Profile'])
-
- # Adding model 'Question'
- db.create_table('exam_question', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('summary', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ('description', self.gf('django.db.models.fields.TextField')()),
- ('points', self.gf('django.db.models.fields.FloatField')(default=1.0)),
- ('test', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('options', self.gf('django.db.models.fields.TextField')(blank=True)),
- ('type', self.gf('django.db.models.fields.CharField')(max_length=24)),
- ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
- ))
- db.send_create_signal('exam', ['Question'])
-
- # Adding model 'Answer'
- db.create_table('exam_answer', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('question', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['exam.Question'])),
- ('answer', self.gf('django.db.models.fields.TextField')()),
- ('error', self.gf('django.db.models.fields.TextField')()),
- ('marks', self.gf('django.db.models.fields.FloatField')(default=0.0)),
- ('correct', self.gf('django.db.models.fields.BooleanField')(default=False)),
- ))
- db.send_create_signal('exam', ['Answer'])
-
- # Adding model 'Quiz'
- db.create_table('exam_quiz', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('start_date', self.gf('django.db.models.fields.DateField')()),
- ('duration', self.gf('django.db.models.fields.IntegerField')(default=20)),
- ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
- ('description', self.gf('django.db.models.fields.CharField')(max_length=256)),
- ))
- db.send_create_signal('exam', ['Quiz'])
-
- # Adding model 'QuestionPaper'
- db.create_table('exam_questionpaper', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
- ('profile', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['exam.Profile'])),
- ('quiz', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['exam.Quiz'])),
- ('start_time', self.gf('django.db.models.fields.DateTimeField')()),
- ('user_ip', self.gf('django.db.models.fields.CharField')(max_length=15)),
- ('key', self.gf('django.db.models.fields.CharField')(max_length=10)),
- ('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
- ('questions', self.gf('django.db.models.fields.CharField')(max_length=128)),
- ('questions_answered', self.gf('django.db.models.fields.CharField')(max_length=128)),
- ('comments', self.gf('django.db.models.fields.TextField')()),
- ))
- db.send_create_signal('exam', ['QuestionPaper'])
-
- # Adding M2M table for field answers on 'QuestionPaper'
- db.create_table('exam_questionpaper_answers', (
- ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
- ('questionpaper', models.ForeignKey(orm['exam.questionpaper'], null=False)),
- ('answer', models.ForeignKey(orm['exam.answer'], null=False))
- ))
- db.create_unique('exam_questionpaper_answers', ['questionpaper_id', 'answer_id'])
-
-
- def backwards(self, orm):
-
- # Deleting model 'Profile'
- db.delete_table('exam_profile')
-
- # Deleting model 'Question'
- db.delete_table('exam_question')
-
- # Deleting model 'Answer'
- db.delete_table('exam_answer')
-
- # Deleting model 'Quiz'
- db.delete_table('exam_quiz')
-
- # Deleting model 'QuestionPaper'
- db.delete_table('exam_questionpaper')
-
- # Removing M2M table for field answers on 'QuestionPaper'
- db.delete_table('exam_questionpaper_answers')
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'exam.answer': {
- 'Meta': {'object_name': 'Answer'},
- 'answer': ('django.db.models.fields.TextField', [], {}),
- 'correct': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'error': ('django.db.models.fields.TextField', [], {}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'marks': ('django.db.models.fields.FloatField', [], {'default': '0.0'}),
- 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exam.Question']"})
- },
- 'exam.profile': {
- 'Meta': {'object_name': 'Profile'},
- 'department': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'institute': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'position': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
- 'roll_number': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
- 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'})
- },
- 'exam.question': {
- 'Meta': {'object_name': 'Question'},
- 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'description': ('django.db.models.fields.TextField', [], {}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'options': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'points': ('django.db.models.fields.FloatField', [], {'default': '1.0'}),
- 'summary': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'test': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'type': ('django.db.models.fields.CharField', [], {'max_length': '24'})
- },
- 'exam.questionpaper': {
- 'Meta': {'object_name': 'QuestionPaper'},
- 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'answers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['exam.Answer']", 'symmetrical': 'False'}),
- 'comments': ('django.db.models.fields.TextField', [], {}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'key': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
- 'profile': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exam.Profile']"}),
- 'questions': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'questions_answered': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'quiz': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['exam.Quiz']"}),
- 'start_time': ('django.db.models.fields.DateTimeField', [], {}),
- 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
- 'user_ip': ('django.db.models.fields.CharField', [], {'max_length': '15'})
- },
- 'exam.quiz': {
- 'Meta': {'object_name': 'Quiz'},
- 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'description': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'duration': ('django.db.models.fields.IntegerField', [], {'default': '20'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'start_date': ('django.db.models.fields.DateField', [], {})
- }
- }
-
- complete_apps = ['exam']
diff --git a/testapp/exam/migrations/__init__.py b/testapp/exam/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testapp/exam/migrations/__init__.py
+++ /dev/null
diff --git a/testapp/exam/models.py b/testapp/exam/models.py
index da45e7d..ad3dad8 100644
--- a/testapp/exam/models.py
+++ b/testapp/exam/models.py
@@ -105,9 +105,13 @@ class Quiz(models.Model):
desc = self.description or 'Quiz'
return '%s: on %s for %d minutes'%(desc, self.start_date, self.duration)
-
################################################################################
class QuestionPaper(models.Model):
+ quiz = models.ForeignKey(Quiz)
+ questions = models.ManyToManyField(Question)
+
+################################################################################
+class AnswerPaper(models.Model):
"""A question paper for a student -- one per student typically.
"""
# The user taking this question paper.
@@ -118,21 +122,14 @@ class QuestionPaper(models.Model):
profile = models.ForeignKey(Profile)
# The Quiz to which this question paper is attached to.
- quiz = models.ForeignKey(Quiz)
+ question_paper = models.ForeignKey(QuestionPaper)
# The time when this paper was started by the user.
start_time = models.DateTimeField()
# User's IP which is logged.
user_ip = models.CharField(max_length=15)
- # Unused currently.
- key = models.CharField(max_length=10)
- # used to allow/stop a user from retaking the question paper.
- active = models.BooleanField(default = True)
-
- # The questions (a list of ids separated by '|')
- questions = models.CharField(max_length=128)
# The questions successfully answered (a list of ids separated by '|')
questions_answered = models.CharField(max_length=128)
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py
index f435e63..4651204 100644
--- a/testapp/exam/urls.py
+++ b/testapp/exam/urls.py
@@ -24,9 +24,15 @@ urlpatterns = patterns('exam.views',
url(r'^manage/questions/$', 'show_all_questions'),
url(r'^manage/showquiz/$','show_all_quiz'),
url(r'^manage/monitor/$', 'monitor'),
+ url(r'^manage/showquestionpapers/$','show_all_questionpapers'),
+ url(r'^manage/showquestionpapers/(?P<questionpaper_id>\d+)/$', 'show_all_questionpapers'),
url(r'^manage/monitor/(?P<quiz_id>\d+)/$', 'monitor'),
url(r'^manage/user_data/(?P<username>[a-zA-Z0-9_.]+)/$', 'user_data'),
-
+ url(r'^manage/designquestionpaper/$','design_questionpaper'),
+ url(r'^manage/designquestionpaper/(?P<questionpaper_id>\d+)/$', 'design_questionpaper'),
+ url(r'^manage/designquestionpaper/automatic/(?P<questionpaper_id>\d+)/$','automatic_questionpaper'),
+ url(r'^manage/designquestionpaper/automatic$','automatic_questionpaper'),
+ url(r'^manage/designquestionpaper/manual$','manual_questionpaper'),
)
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 5b980f5..464bc3c 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -11,7 +11,8 @@ from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import RequestContext
from django.http import Http404
from django.db.models import Sum
-
+from taggit.models import Tag
+from itertools import chain
# Local imports.
from exam.models import Quiz, Question, QuestionPaper, Profile, Answer, User
from exam.forms import UserRegisterForm, UserLoginForm, QuizForm , QuestionForm
@@ -20,6 +21,8 @@ from settings import URL_ROOT
# The directory where user data can be saved.
OUTPUT_DIR = abspath(join(dirname(__file__), pardir, 'output'))
+set1 = set()
+set2 = set()
def my_redirect(url):
"""An overridden redirect to deal with URL_ROOT-ing. See settings.py
@@ -245,7 +248,7 @@ def add_quiz(request,quiz_id=None):
for tag in tags:
tag = tag.strip()
quiz.tags.add(tag)
- return my_redirect("/exam/manage/showquiz")
+ return my_redirect("/exam/manage/designquestionpaper")
else:
d = Quiz.objects.get(id=quiz_id)
d.start_date = form['start_date'].data
@@ -291,6 +294,107 @@ def add_quiz(request,quiz_id=None):
return my_render_to_response('exam/add_quiz.html',{'form':form},context_instance=RequestContext(request))
+def design_questionpaper(request,questionpaper_id=None):
+ user=request.user
+ if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 :
+ raise Http404('You are not allowed to view this page!')
+ return my_render_to_response('exam/add_questionpaper.html',{},context_instance=RequestContext(request))
+
+
+def show_all_questionpapers(request,questionpaper_id=None):
+ user=request.user
+ if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 :
+ raise Http404('You are not allowed to view this page!')
+
+ if request.method=="POST" and request.POST.get('add') == "add":
+ return my_redirect("/exam/manage/designquestionpaper/" + questionpaper_id)
+
+ if questionpaper_id == None:
+ qu_papers = QuestionPaper.objects.all()
+ context = {'papers':qu_papers}
+ return my_render_to_response('exam/showquestionpapers.html',context,context_instance=RequestContext(request))
+ else:
+ qu_papers = QuestionPaper.objects.get(id=questionpaper_id)
+ quiz = qu_papers.quiz
+ questions = qu_papers.questions.all()
+ q = []
+ for i in questions:
+ q.append(i)
+ context = {'papers':{'quiz':quiz,'questions':q}}
+ return my_render_to_response('exam/editquestionpaper.html',context,context_instance=RequestContext(request))
+
+
+def automatic_questionpaper(request,questionpaper_id=None):
+
+ user=request.user
+ global set1
+ global set2
+ if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 :
+ raise Http404('You are not allowed to view this page!')
+
+ if questionpaper_id == None:
+ if request.method=="POST":
+ if request.POST.get('save') == 'save' :
+ quiz = Quiz.objects.order_by("-id")[0]
+ quest_paper = QuestionPaper()
+ quest_paper.quiz = quiz
+ quest_paper.save()
+ for i in set2:
+ print str(i.id) + " " + i.summary
+ q = Question.objects.get(summary=i)
+ quest_paper.questions.add(q)
+ return my_redirect('/exam/manage/showquiz')
+ else:
+ set1 = set()
+ set2 = set()
+ no_questions = int(request.POST.get('questions'))
+ first_tag = request.POST.get('first_tag')
+ first_condition = request.POST.get('first_condition')
+ second_tag = request.POST.get('second_tag')
+ second_condition = request.POST.get('second_condition')
+ third_tag = request.POST.get('third_tag')
+ question1 = set(Question.objects.filter(tags__name__in=[first_tag]))
+ question2 = set(Question.objects.filter(tags__name__in=[second_tag]))
+ question3 = set(Question.objects.filter(tags__name__in=[third_tag]))
+ if first_condition == 'and':
+ set1 = question1.intersection(question2)
+ if second_condition == 'and':
+ set2 = set1.intersection(question3)
+ else:
+ set2 = set1.union(question3)
+ else:
+ set1 = question1.union(question2)
+ if second_condition == 'and':
+ set2 = set1.intersection(question3)
+ else:
+ set2 = set1.union(question3)
+ n = len(set2)
+ msg = ''
+ if (no_questions < n ) :
+ i = n - no_questions
+ for i in range(0,i):
+ set2.pop()
+ elif( no_questions > n):
+ msg = 'The given Criteria does not satisfy the number of Questions...'
+ tags = Tag.objects.all()
+ context = {'data':{'questions':set2,'tags':tags,'msg':msg}}
+ return my_render_to_response('exam/automatic_questionpaper.html',context,context_instance=RequestContext(request))
+ else:
+ tags = Tag.objects.all()
+ context = {'data':{'tags':tags}}
+ return my_render_to_response('exam/automatic_questionpaper.html',context,context_instance=RequestContext(request))
+
+ else:
+ return HttpResponse("eni mane pochi gaya ayan... ")
+
+def manual_questionpaper(request):
+ user=request.user
+ if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 :
+ raise Http404('You are not allowed to view this page!')
+ return my_render_to_response('exam/manual_questionpaper.html',{},context_instance=RequestContext(request))
+
+
+
def prof_manage(request):
"""Take credentials of the user with professor/moderator rights/permissions and log in."""
diff --git a/testapp/settings.py b/testapp/settings.py
index 6edf08c..92a597b 100644
--- a/testapp/settings.py
+++ b/testapp/settings.py
@@ -123,6 +123,8 @@ MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
+ 'debug_toolbar.middleware.DebugToolbarMiddleware',
+
)
ROOT_URLCONF = '%s.urls'%(basename(CURDIR))
@@ -149,6 +151,8 @@ INSTALLED_APPS = (
'south',
'exam',
'taggit_autocomplete_modified',
+ 'debug_toolbar',
+ 'django_extensions',
)
# A sample logging configuration. The only tangible logging
@@ -188,3 +192,6 @@ LOGGING = {
}
AUTH_PROFILE_MODULE = 'exam.Profile'
+
+INTERNAL_IPS = ('127.0.0.1',)
+
diff --git a/testapp/static/exam/css/base.css b/testapp/static/exam/css/base.css
index e1adc48..c822f4d 100644
--- a/testapp/static/exam/css/base.css
+++ b/testapp/static/exam/css/base.css
@@ -631,7 +631,7 @@ textarea {
}
select
{
- width : 80px;
+ width : auto;
}
label {
padding-top: 6px;
diff --git a/testapp/templates/exam/add_questionpaper.html b/testapp/templates/exam/add_questionpaper.html
new file mode 100644
index 0000000..664093c
--- /dev/null
+++ b/testapp/templates/exam/add_questionpaper.html
@@ -0,0 +1,54 @@
+{% extends "manage.html" %}
+
+
+{% block subtitle %}Design Question Paper{% endblock %}
+
+{% block css %}
+<link rel="stylesheet" href="{{ URL_ROOT }}/static/exam/css/question_quiz.css" type="text/css" />
+<link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/exam/css/autotaggit.css" />
+{% endblock %}
+{% block script %}
+<script src="/static/taggit_autocomplete_modified/jquery.min.js" type="text/javascript"></script>
+<script src="/static/taggit_autocomplete_modified/jquery.autocomplete.js" type="text/javascript"></script>
+
+<script>
+function load_data()
+{
+ var value = document.getElementById('mode').value;
+ var pathArray = window.location.pathname.split( '/' );
+ length = pathArray.length;
+ var digit = parseInt(pathArray[length-2]);
+
+ if (! isNaN(digit) && value == 'Automatic')
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/automatic/" + digit;
+ }
+ else if(!isNaN(digit) && value == 'Manual')
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/manual/" + digit;
+ }
+ else if(value == 'Automatic')
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/automatic";
+ }
+ else if( value == 'Manual')
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/manual";
+ }
+}
+</script>
+{% endblock %}
+
+{% block manage %}
+<form>
+{% csrf_token %}
+Select mode to design Question Paper:
+<select name='mode' id='mode' onChange='javascript:load_data();'>
+ <option>---------</option>
+ <option>Automatic</option>
+ <option>Manual</option>
+</select>
+</form>
+
+
+{% endblock %}
diff --git a/testapp/templates/exam/add_quiz.html b/testapp/templates/exam/add_quiz.html
index c5998d8..c8e1ac3 100644
--- a/testapp/templates/exam/add_quiz.html
+++ b/testapp/templates/exam/add_quiz.html
@@ -27,7 +27,8 @@
{{ form.as_table }}
</table>
</center>
- <center><button class="btn" type="submit" name="save">Save</button>
+
+ <center><button class="btn" type="submit" name="questionpaper">Design Question Paper</button>
<button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/showquiz/");'>Cancel</button> </center>
</form>
{% endblock %}
diff --git a/testapp/templates/exam/automatic_questionpaper.html b/testapp/templates/exam/automatic_questionpaper.html
new file mode 100644
index 0000000..b961711
--- /dev/null
+++ b/testapp/templates/exam/automatic_questionpaper.html
@@ -0,0 +1,101 @@
+{% extends "manage.html" %}
+
+
+{% block subtitle %}Design Question Paper{% endblock %}
+
+{% block css %}
+<link rel="stylesheet" href="{{ URL_ROOT }}/static/exam/css/question_quiz.css" type="text/css" />
+<link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/exam/css/autotaggit.css" />
+<style>
+select
+{
+ width:auto;
+}
+</style>
+{% endblock %}
+{% block script %}
+<script src="/static/taggit_autocomplete_modified/jquery.min.js" type="text/javascript"></script>
+<script src="/static/taggit_autocomplete_modified/jquery.autocomplete.js" type="text/javascript"></script>
+
+<script>
+function load_data()
+{
+ var value = document.getElementById('mode').value;
+ if (value == 'Automatic')
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/automatic";
+ }
+ else if(value == "Manual")
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/manual";
+ }
+}
+</script>
+{% endblock %}
+
+{% block manage %}
+<center><b>Automotic mode to design the Question Paper</center><br>
+
+<form action="" method="post" name=frm>
+ {% csrf_token %}
+ <center>
+ Tag Conditions:
+ <select name='first_tag'>
+ <option value="">Select Tag </option>
+ {% for tag in data.tags %}
+ <option value={{tag}}>{{tag}}</option>
+ {% endfor %}
+ </select>
+
+ <select name='first_condition'>
+ <option value="or">OR</option>
+ <option value="and">AND</option>
+ </select>
+
+ <select name='second_tag'>
+ <option value="">Select Tag </option>
+ {% for tag in data.tags %}
+ <option value={{tag}}>{{tag}}</option>
+ {% endfor %}
+ </select>
+
+ <select name='second_condition'>
+ <option value="or">OR</option>
+ <option value="and">AND</option>
+ </select>
+
+ <select name='third_tag'>
+ <option value="null">Select Tag </option>
+ {% for tag in data.tags %}
+ <option value={{tag}}>{{tag}}</option>
+ {% endfor %}
+ </select>
+ </center>
+
+ <br>
+
+ <center>Number of question: <input type=text id=questions name='questions' style="width:25px;">&nbsp;<button class=btn type=submit name='fetch' value='fetch'>Fetch Questions</button><br></center>
+
+ <br>
+ <br>
+ <p><b>Below is the list of Questions fetched according to the given tag conditions</p>
+ <hr>
+ <center><table class=span10>
+ <th>Summary
+ <th>Type
+ <th>Points
+ <th>Tags
+ {% for question in data.questions %}
+ <tr><td>{{ question.summary }} <td>{{ question.type }} <td>{{ question.points }} <td>
+ {% for tag in question.tags.all %}
+ {{ tag }}
+ {% endfor %}
+ </tr>
+ <br>
+ {% endfor %}
+ </table>
+ {% if data.msg %}<div class="alert alert-error">{{ data.msg }}</div>{% endif %}
+ <center><button class=btn type=submit name='save' value='save'>Save Question Paper</button></center>
+</form>
+
+{% endblock %}
diff --git a/testapp/templates/exam/editquestionpaper.html b/testapp/templates/exam/editquestionpaper.html
new file mode 100644
index 0000000..68a9c22
--- /dev/null
+++ b/testapp/templates/exam/editquestionpaper.html
@@ -0,0 +1,21 @@
+{% extends "manage.html" %}
+
+
+{% block subtitle %}Questions in "{{ papers.quiz.description }}"{% endblock %}
+
+{% block script %}
+<script src="{{ URL_ROOT }}/static/exam/js/show_question.js"></script>
+{% endblock %}
+
+{% block manage %}
+<form name=frm action="" method="post">
+{% csrf_token %}
+
+{% for i in papers.questions %}
+<input type="checkbox" name="papers" value="{{ i.id }}">&nbsp;&nbsp;<a href="{{URL_ROOT}}/exam/manage/editquestionpaper/{{ i.id }}">{{ i.summary}}</a><br>
+{% endfor %}
+<br>
+<button class="btn" type="submit" name=add value=add>Add Question</button>&nbsp;&nbsp;
+<button class="btn" type="submit" onClick="return confirm_delete(frm);" name='delete' value='delete'>Delete Selected</button>
+</form>
+{% endblock %}
diff --git a/testapp/templates/exam/manual_questionpaper.html b/testapp/templates/exam/manual_questionpaper.html
new file mode 100644
index 0000000..96370c0
--- /dev/null
+++ b/testapp/templates/exam/manual_questionpaper.html
@@ -0,0 +1,42 @@
+{% extends "manage.html" %}
+
+
+{% block subtitle %}Design Question Paper{% endblock %}
+
+{% block css %}
+<link rel="stylesheet" href="{{ URL_ROOT }}/static/exam/css/question_quiz.css" type="text/css" />
+<link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/exam/css/autotaggit.css" />
+{% endblock %}
+{% block script %}
+<script src="/static/taggit_autocomplete_modified/jquery.min.js" type="text/javascript"></script>
+<script src="/static/taggit_autocomplete_modified/jquery.autocomplete.js" type="text/javascript"></script>
+
+<script>
+function load_data()
+{
+ var value = document.getElementById('mode').value;
+ if (value == 'Automatic')
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/automatic";
+ }
+ else if(value == "Manual")
+ {
+ window.location = "{{ URL_ROOT }}/exam/manage/designquestionpaper/manual";
+ }
+}
+</script>
+{% endblock %}
+
+{% block manage %}
+<form >
+{% csrf_token %}
+Select mode to design Question Paper:
+<select name='mode' id='mode' onChange='javascript:load_data();'>
+ <option>Manual</option>
+ <option>Automatic</option>
+</select>
+</form>
+
+
+
+{% endblock %}
diff --git a/testapp/templates/exam/showquestionpapers.html b/testapp/templates/exam/showquestionpapers.html
new file mode 100644
index 0000000..7a77d2f
--- /dev/null
+++ b/testapp/templates/exam/showquestionpapers.html
@@ -0,0 +1,21 @@
+{% extends "manage.html" %}
+
+
+{% block subtitle %}List of Question Papers {% endblock %}
+
+{% block script %}
+<script src="{{ URL_ROOT }}/static/exam/js/show_question.js"></script>
+{% endblock %}
+
+{% block manage %}
+<form name=frm action="" method="post">
+{% csrf_token %}
+{% for i in papers %}
+<input type="checkbox" name="papers" value="{{ i.id }}">&nbsp;&nbsp;<a href="{{URL_ROOT}}/exam/manage/showquestionpapers/{{ i.id }}">{{ i.quiz.description }}</a><br>
+{% endfor %}
+<br>
+<button class="btn" type="button" onclick='location.replace("{{URL_ROOT}}/exam/manage/addquestion/");'>Add Question</button>&nbsp;&nbsp;
+<button class="btn" type="submit" name='edit' value='edit' onClick="return confirm_edit(frm);">Edit Selected</button>&nbsp;&nbsp;
+<button class="btn" type="submit" onClick="return confirm_delete(frm);" name='delete' value='delete'>Delete Selected</button>
+</form>
+{% endblock %}
diff --git a/testapp/templates/manage.html b/testapp/templates/manage.html
index 43578f7..0f122b0 100644
--- a/testapp/templates/manage.html
+++ b/testapp/templates/manage.html
@@ -30,8 +30,9 @@
<ul>
<li><a href="{{ URL_ROOT }}/exam/manage/questions">Questions</a></li>
<li><a href="{{ URL_ROOT }}/exam/manage/showquiz">Quizzes</a></li>
+ <li><a href="{{ URL_ROOT }}/exam/manage/showquestionpapers">Question Papers</a></li>
<li><a href="{{ URL_ROOT }}/exam/manage/gradeuser">Grade User</a></li>
- <li><a href="{{ URL_ROOT }}/exam/manage/monitor">Monitor</a></li>
+ <li><a href="{{ URL_ROOT }}/exam/manage/monitor">Monitor</a></li>
</ul>
<ul style="float:right;">
<li><strong><a style='cursor:pointer' onClick='location.replace("{{URL_ROOT}}/exam/complete/");'>Log out</a></strong></li>