diff options
author | hardythe1 | 2012-04-02 18:04:43 +0530 |
---|---|---|
committer | hardythe1 | 2012-04-02 18:04:43 +0530 |
commit | c0fcc1181e209192f6d11f2ca521e55e33a4ead7 (patch) | |
tree | 576b100053a4ef35d4e686ce198f2882d98efbb2 /testapp | |
parent | 64b38d3365f1d65132942fce6e29fed7da076bba (diff) | |
download | online_test-c0fcc1181e209192f6d11f2ca521e55e33a4ead7.tar.gz online_test-c0fcc1181e209192f6d11f2ca521e55e33a4ead7.tar.bz2 online_test-c0fcc1181e209192f6d11f2ca521e55e33a4ead7.zip |
Question Paper generator changes
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/migrations/0001_initial.py | 193 | ||||
-rw-r--r-- | testapp/exam/migrations/__init__.py | 0 | ||||
-rw-r--r-- | testapp/exam/models.py | 15 | ||||
-rw-r--r-- | testapp/exam/urls.py | 8 | ||||
-rw-r--r-- | testapp/exam/views.py | 108 | ||||
-rw-r--r-- | testapp/settings.py | 7 | ||||
-rw-r--r-- | testapp/static/exam/css/base.css | 2 | ||||
-rw-r--r-- | testapp/templates/exam/add_questionpaper.html | 54 | ||||
-rw-r--r-- | testapp/templates/exam/add_quiz.html | 3 | ||||
-rw-r--r-- | testapp/templates/exam/automatic_questionpaper.html | 101 | ||||
-rw-r--r-- | testapp/templates/exam/editquestionpaper.html | 21 | ||||
-rw-r--r-- | testapp/templates/exam/manual_questionpaper.html | 42 | ||||
-rw-r--r-- | testapp/templates/exam/showquestionpapers.html | 21 | ||||
-rw-r--r-- | testapp/templates/manage.html | 3 |
14 files changed, 370 insertions, 208 deletions
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;"> <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 }}"> <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> +<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 }}"> <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> +<button class="btn" type="submit" name='edit' value='edit' onClick="return confirm_edit(frm);">Edit Selected</button> +<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> |