Commit cc394767 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

added add_quiz functionality

parent 8cd457b2
......@@ -35,6 +35,9 @@ urlpatterns = [
url(r'^upload/',TemplateView.as_view(template_name = 'upload.html')),
url('instructor/',a.instructor),
path('uploaded/',a.upload_file,name="uploaded"), path('sign_up/',a.sign_up,name="sign-up"), path('accounts/',include('django.contrib.auth.urls')),
path('create_quiz/',a.create_quiz)
path('create_quiz/',a.create_quiz),
path('add_quiz/',a.add_quiz),
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
No preview for this file type
......@@ -27,7 +27,7 @@
<button type="button" id="del_question" class="del_question" onclick="del_que(`+next_qnumber+`)">Delete this question</button>
</div>
<h3>Question:</h3>
<textarea class="input_area" onchange="fillme(this)"></textarea>
<textarea class="input_area" name="question_`+next_qnumber+`" onchange="fillme(this)"></textarea>
<h3>Options:</h3>
<label class="op_box" id="box0"><span id="lbl_`+next_qnumber+`_0"><strong>A</strong><span role="textbox" id="span_`+next_qnumber+`_option0" contenteditable class="ques_txtara"></span></span></label>
<label class="op_box" id="box1"><span id="lbl_`+next_qnumber+`_1"><strong>B</strong><span role="textbox" id="span_`+next_qnumber+`_option1" contenteditable class="ques_txtara"></span></span></label>
......
......@@ -10,7 +10,7 @@
</head>
<body onload="add_que()">
<section>
<form action="add_quiz" id="quiz_create_form" enctype = "multipart/form-data" method = "POST">{% csrf_token %}
<form action="/add_quiz/" id="quiz_create_form" enctype = "multipart/form-data" method = "POST">{% csrf_token %}
<div id="quiz_controls">
<p><a href="../upload">Click here to automatically add all questions by uploading csv</a></p>
<div style="padding: 20px">
......
......@@ -168,7 +168,7 @@ def instructor(request):
allStudents.append(student['studentId'])
std=np.std(allMarks)
mean=np.mean(allMarks)
ax.hist(allMarks,allStudents)
ax.scatter(allMarks,allStudents)
html_graph = mpld3.fig_to_html(fig)
fig1, ax1 = plt.subplots()
mu = mean
......@@ -234,3 +234,33 @@ def view_sub(request):
return render(request,'view_submissions.html', { 'submissions' : subs , 'score': score, 'total': total })
def add_quiz(request):
vals=list()
for req in request.POST.values():
vals.append(req)
i=1
quizCode= vals[i]
print(quizCode)
i+=1
date=vals[i]
print(date)
i+=1
startTime=vals[i]
print(startTime)
i+=1
length=vals[i]
print(length)
i+=1
print(request.user)
q= quiz(length=length,quizCode=quizCode,quizInfo='',date=date,
quizInstructor=str(request.user),startTime =startTime,quizDone=False)
q.save()
while(i<len(vals)):
row=(vals[i],vals[i+1],vals[i+2],vals[i+3],vals[i+4],vals[i+5],vals[i+6],vals[i+7],vals[i+8])
q1=Questions(question=row[0],option1=row[1],option2=row[2],option3=row[3],option4=row[4],
answer=row[7],marks=int(row[5]),negative=float(row[6]),explainations=row[7],quizCode=quizCode,quizId=q)#hardcoded quizid
q1.save()
i=i+9
return HttpResponse('sucess')#(request,'success')
\ No newline at end of file
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