Commit 83a2e921 authored by SANCHIT JAIN's avatar SANCHIT JAIN

changed name of button and created a database file

parent cb3dfd3e
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-26 08:57
# Generated by Django 1.11.15 on 2018-11-26 18:47
from __future__ import unicode_literals
import django.core.validators
......@@ -81,7 +81,6 @@ class Migration(migrations.Migration):
('difficulty_set', models.CharField(max_length=20)),
('difficulty_observed', models.CharField(max_length=20)),
('question_text', models.CharField(max_length=1000)),
('image_link', models.CharField(max_length=200)),
('num_appeared', models.IntegerField(default=0)),
('num_correct', models.IntegerField(default=0)),
('visibility', models.CharField(max_length=20)),
......@@ -92,11 +91,11 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='QuestionImage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.FileField(upload_to='QuestionImages/')),
('image_id', models.AutoField(primary_key=True, serialize=False)),
('image', models.FileField(upload_to='ARFA_app/static/ARFA_app/QuestionImages/')),
('imageDesc', models.CharField(max_length=100)),
('orderNum', models.IntegerField(default=1)),
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ARFA_app.Question')),
('q_ID', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='ARFA_app.Question')),
],
),
migrations.CreateModel(
......
......@@ -310,7 +310,7 @@ Create Question
<li><button type="button" class="btn btn-default prev-step" onclick="document.getElementById('l2').click() ; ">Previous</button></li>
<li><button type="button" class="btn btn-default next-step" onclick="document.getElementById('l4').click() ;">Skip</button></li>
<li><button align="left" type="button" class="btn btn-primary" id="addsubjectiveque" onclick="intend_to_add_img() ; post()" >Add an image</button></li>
<li><button type="button" class="btn btn-primary btn-info-full next-step" onclick="step3()">Save and continue</button></li>
<li><button type="button" class="btn btn-primary btn-info-full next-step" onclick="post()">Post Question</button></li>
</ul>
......
......@@ -74,17 +74,20 @@ def reg(request):
if(request.method=="POST"):
role=request.POST['role']
data={'username': request.POST['username'], 'name':request.POST['name'],'email_ID': request.POST['email_ID'],'address':request.POST['address'],'password':request.POST['password'],'phone_number':request.POST['phone_number']}
if(role=="Student"):
print "Student with name "+ data['name']+" registered"
s=models.Student(**data)
s.save()
else:
data['salary']=0
data['subject_ID']=models.Subject.objects.filter(subject_ID=request.POST['subject_ID']).get()
print "Faculty with name "+ data['name']+" registered"
s=models.Faculty(**data)
s.save()
try:
if(role=="Student"):
print "Student with name "+ data['name']+" registered"
s=models.Student(**data)
s.save()
else:
data['salary']=0
data['subject_ID']=models.Subject.objects.filter(subject_ID=request.POST['subject_ID']).get()
print "Faculty with name "+ data['name']+" registered"
s=models.Faculty(**data)
s.save()
except:
print "registration failed"
return redirect('/arfa/register')
else:
return redirect('/arfa')
......@@ -620,7 +623,6 @@ def add_question(request):
try:
question_data = dict(json.loads(request.POST['client_response']))
args = question_data['question_data']
print args['question_text']
if args['question_text']=='':
......@@ -629,8 +631,11 @@ def add_question(request):
args['faculty'] = models.Faculty.objects.filter(username=request.session['username']).get()
print args['faculty']
options = question_data['options_details']
print options
args['subject_ID'] = models.Subject.objects.filter(subject_ID = args['subject_ID']).get()
print args['subject_ID']
flag = False
for i in range(0,len(options)):
if options[str(i)]['option_Value']:
......@@ -638,8 +643,11 @@ def add_question(request):
break
if not(flag):
return HttpResponse(json.dumps({'status':'Failed','reason':'No correct option provided'}))
print args
question = models.Question(**args)
print question
question.save()
print "saved"
for i in range(0,len(options)):
option = models.Options(q_ID=question,option_Value=options[str(i)]['option_Value'],
is_Answer=options[str(i)]['is_Answer'],option_ID=options[str(i)]['id'])
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment