fact
which takes a single integer argument\n(say n
) and returns the factorial of the number. \nFor example:fact(3) -> 6
\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 sqr
which takes a single \nargument and returns the square of the argument. For example: sqr(3) -> 9
.", "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
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