Commit e971cc27 authored by CHINTHAREDDY SAI CHARITH REDDY's avatar CHINTHAREDDY SAI CHARITH REDDY

Prints and corrected chart

parents 3c422045 697b9501
......@@ -45,7 +45,7 @@ class TestForm(forms.ModelForm):
# 'expected_time_for_completion': forms.TimeInput(attrs={'type':'time'}),
# 'start_time': forms.DateInput(attrs={'type':'datetime-local'}),
}
exclude = ['test_ID', 'ownership']
exclude = ['test_ID', 'ownership', 'max_marks']
# def clean_start_time(self):
# dt = self.cleaned_data['start_time']
# print dt
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-26 21:16
# Generated by Django 1.11.16 on 2018-11-27 03:10
from __future__ import unicode_literals
import django.core.validators
......@@ -144,8 +144,6 @@ class Migration(migrations.Migration):
fields=[
('test_ID', models.AutoField(primary_key=True, serialize=False)),
('test_name', models.CharField(max_length=200, unique=True)),
('visibility_student', models.CharField(max_length=20)),
('ownership', models.CharField(max_length=20)),
('expected_time_for_completion', models.DurationField(blank=True)),
('start_time', models.DateTimeField()),
('max_marks', models.IntegerField(null=True)),
......
......@@ -28,11 +28,12 @@ class Faculty(arfa_user):
class Test(models.Model):
test_ID = models.AutoField(primary_key=True)
test_name = models.CharField(max_length=200,unique=True)
visibility_student = models.CharField(max_length=20)
ownership = models.CharField(max_length=20)
# visibility_student = models.CharField(max_length=20)
# ownership = models.CharField(max_length=20)
expected_time_for_completion = models.DurationField(blank=True)
start_time = models.DateTimeField(auto_now=False, auto_now_add=False,blank=False)
max_marks = models.IntegerField(null=True)
# class TestQuestions(models.Model):
# test_ID = models.ForeignKey(
......
{%extends 'base2.html'%}
{%block head%}
<script>
total_marks = 0;
num_questions = 0;
function dispTotalMarks() {
$('#total_marks').html(total_marks);
}
function computeTotalMarks() {
val = 0;
$('.pos_marks').each(function() {
//add '#' to the id of checkbox to obtain that element
//'if' condition checks if the box is checked
//if it is, add to val
if(document.getElementById($(this).attr('checkBoxID')).checked) {
console.log($(this).attr('checkBoxID'))
val += parseFloat($(this).val());
}
})
total_marks = val;
}
function handleMarkChange() {
computeTotalMarks();
dispTotalMarks();
}
function handleCheckBoxClick(cb) {
posmarks = parseFloat((document.getElementById(
cb.getAttribute('posMarksID'))).value);
// get value of input field like so: element.value
if(cb.checked) {
total_marks += posmarks;
//update num_questions
num_questions++;
}
else {
total_marks -= posmarks
//update num_questions
num_questions--;
}
dispTotalMarks();
dispNumQuestions();
}
function dispNumQuestions() {
$('#num_questions').html(num_questions);
}
</script>
{%endblock%}
{%block title%}
Create Test
......@@ -9,7 +58,7 @@ Create Test
{%block body%}
<h1 style="text-align:center"> You CAN CREATE A Test HERE prof {{username}}</h1>
<h1 style="text-align:center"> Create a test here</h1>
<div class="container">
<div class="panel-default">
......@@ -17,22 +66,47 @@ Create Test
<h3 class="panel-title">Choose which questions are to be a part of the test</h3>
</div>
<ul class="list-group">
<!-- <ul> -->
<div>
<div style="float:right ; margin-right: 30px ">
Total Marks : <p id='total_marks' style="float:right;"></p>
</div>
<br/> <br/>
<div style="float:right ;margin-right: 30px ">
Number of Questions : <p id='num_questions' style="float:right;"></p>
</div>
</div>
</div>
<form method="POST" action="create_Test">
{% csrf_token %}
{{ TestForm.as_p }}
{{TestForm.errors}}
{{TestForm.non_field_errors}}
{%for question in questions%}
<li class="list-group-item">
<!-- <li> -->
<div class="row toggle">
<div class="row toggle" style="margin-left:10%">
<div class="col-xs-10">
<input type="checkbox" value= "True" name = "{{question.q_id}}" >
{{question.question_text}} {{question.q_id}} </br>
<input type="checkbox" value= "True" name = "{{question.q_id}}"
id = "{{question.q_id}}" onclick="handleCheckBoxClick(this)"
posMarksID="{{question.q_id}}pos_marks">
<!-- link to posmarks in checkbox -->
{{question.question_text}} </br>
{%if question.ip%}
{%load static%}
<div align="center">
<img src = "{% static "" %}{{question.ip|slice:"16:" }}" width="35%" height="35%">
<p style="margin-top:5px">
{{question.imdesc}}
</p>
</div>
{%endif%}
</div>
</div>
<div>
<div style="margin-left:10%">
<hr></hr>
<ul>
{%for option in question.option_details%}
......@@ -46,19 +120,29 @@ Create Test
</li>
{%endif%}
{%endfor%}
<label> marks
<input type="number" name="{{question.q_id}}" min="0" max="10" placeholder="4" step="0.25" value="4">
<input type="number" name="{{question.q_id}}" min="-10" max="0" placeholder="-1" step="0.25" value="0">
</label>
<label style="margin-top:10px; margin-right:5px"> marks </label>
<!-- the id of checkboxes is q_id. I'm linking pos_marks to checkboxes
by id -->
<input class = "pos_marks" type="number" name="{{question.q_id}}"
min="0" max="10" placeholder="4" step="0.25" value="4"
checkBoxID = "{{question.q_id}}" onchange="handleMarkChange()"
id="{{question.q_id}}pos_marks">
<input type="number" name="{{question.q_id}}"
min="-10" max="0" placeholder="-1" step="0.25" value="0">
</ul>
</div>
</li>
{%endfor%}
<div style="float:right; margin-top: 10px; margin-right:20px " >
<button type="submit" class="btn btn-login float-right">Submit</button>
</div>
</form>
</ul>
</div>
<br><br><br><br><br><br>
</div>
{%endblock%}
\ No newline at end of file
......@@ -75,7 +75,7 @@ function prevTab(elem) {
var check = document.createElement("input");
var check_ans = document.createElement("label");
check_ans.for = "c" + x ;
check_ans.innerHTML = "Is this an / the answer?"
check_ans.innerHTML = "Is this an / the answer?" ;
check.type="checkbox";
check.className = "form-control" ;
check.name="c" + x ;
......@@ -110,8 +110,9 @@ function prevTab(elem) {
var qtext = document.getElementById('qtext').value ;
question_data['subject_ID'] = subject.value ;
question_data['question_text'] = qtext ;
console.log(question_data['question_text']) ;
console.log(question_data['subject_ID']) ;
question_data['difficulty_set'] = document.getElementById('diff').value;
question_data['visibilility'] = document.getElementById('visible').value ;
console.log(question_data) ;
document.getElementById('l2').click() ;
}
......@@ -228,7 +229,7 @@ Create Question
{%endblock%}
{%block body%}
<h3 style="text-align:center"> You CAN CREATE A QUESTION HERE prof {{username}}</h3>
<h3 style="text-align:center"> Create a question here</h3>
<div class="container" title="this is title">
<div class="row">
<section>
......@@ -288,6 +289,18 @@ Create Question
<label>Question Text</label>
<textarea class="form-control" rows="6" id= "qtext"></textarea>
</div>
<div class="form-group col-lg-4">
<label style="margin-right:20px">Specify question difficulty</label>
<input type="number" name="quantity" min="1" max="10" placeholder="5" value="5" id="diff">
</div>
<br>
<div class="form-group col-lg-4">
<label style="margin-right:20px;">Specify question visibility</label>
<select name="visible" id="visible">
<option value="public" >Public</option>
<option value="private" >Private</option>
</select>
</div>
</div>
<div class="tab-pane" role="tabpanel" id="step2">
<h3>Step 2 - Add some options</h3>
......@@ -308,7 +321,7 @@ Create Question
<p> Drop images in the order you want to display</p>
<ul class="list-inline pull-right">
<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 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="post()">Post Question</button></li>
</ul>
......
......@@ -143,12 +143,12 @@ profile
</a>
<a href="/arfa/view_personal_Test">
<center><button type="button" class="btn btn-lg btn-labeled btn-primary" href="#" style="margin-bottom: 15px;">
<span class="btn-label"><i class="fa fa-eye-slash"></i></span>VIEW MY Test
<span class="btn-label"><i class="fa fa-eye-slash"></i></span>VIEW MY Tests
</button></center>
</a>
<a href="/arfa/view_all_Test">
<center><button type="button" class="btn btn-lg btn-labeled btn-info" href="#" style="margin-bottom: 15px;">
<span class="btn-label"><i class="fa fa-eye"></i></span>VIEW ALL Test
<span class="btn-label"><i class="fa fa-eye"></i></span>VIEW ALL Tests
</button></center>
</a>
......
......@@ -13,9 +13,15 @@ Total Time :<b > {{total_time.hours}} {{total_time.minutes}} </b>
<p> Max Marks. <b>{{max_marks}}</b> </p>
<div id="Timer" style="border-style: solid; text-align: center;"></div>
</div>
<h2 align="center" style=" text-decoration: underline;"><b> {{testName.test_name}} </b> </h2>
<h2 align="center" style=" text-decoration: underline;"><b> {{testName.test_name}} </b> </h2>
</div>
<script>
function submitExam()
{
document.getElementById('ExamForm').submit() ;
}
</script>
<script>
// Set the date we're counting down to
var countDownDate = new Date( {{ end_time }} );
......@@ -49,19 +55,37 @@ var x = setInterval(function() {
<div style="margin-left: 5%; margin-top: 10%">
<ol>
<font size="3">
<form class="exam-form" method="POST" action="/arfa/result">
<form class="exam-form" method="POST" action="/arfa/result" id="ExamForm">
<p style="margin-right: 5%"> <b> Questions </b></p>
{% csrf_token %}
<input name="testID" value="{{testID}}" type="hidden" >
{% for question, options in questions.items %}
{{images}}
{% for question, data in questions.items %}
<div class="row" style="margin-top: 10px; margin-bottom: 10px">
<li style="font-weight: bold;" > {{ question }}</li>
{% for option in options %}
<li style="font-weight: bold;margin-left: 10px; margin-bottom: 10px" > {{ question }}<br></li>
<!-- adding an image -->
{% for image in data.images %}
{%load static%}
{%if image.0 %}
<div align="center" style="margin-top:30px">
<img src = "{% static "" %}{{ image.0 }}" width="35%" height="35%" >
<p style="margin-top:5px">{{image.1}}</p>
{%endif%}
</div>
{% endfor %}
{% for option in data.options %}
<input type="checkbox" name = "{{option.0}}" value= "{{option.1}}" > {{ option.2 }} </br>
{% endfor %}
</div>
{% endfor %}
<button type="submit" class="btn btn-login" style="float: right;">Submit</button>
<button onclick="submitExam()" class="btn btn-login" style="float: right;">Submit</button>
</form>
</font>
......
......@@ -16,17 +16,26 @@ My Tests
</div>
<ul class="list-group">
{% for t in activeTests %}
<div>
<p>{{t.test_ID}}</p>
<p>{{t.test_name}}</p>
</div>
<div class="row" style="margin-bottom: 10px; margin-top: 5px">
<div style="float: left; margin-left: 20px">
<p><i>Test Id</i> <b> {{t.test_ID}}</b></p>
<p><i> Test Name</i> <b>{{t.test_name}}</b> </p>
</div>
<div style="float:right">
<form method="POST" action="loadStudentTest">
{% csrf_token %}
<input name="testID" value="{{t.test_ID}}" type="hidden">
<button type="submit" class="btn btn-login float-right" style="margin-top: 10px ;margin-right: 40px">Load Test</button>
{% if t.hasTaken is True %}
<button type="button" disabled class="btn btn-login float-right"
style="margin-top: 10px ;margin-right: 40px">Attempted</button>
{% else %}
<button type="submit" class="btn btn-login float-right"
style="margin-top: 10px ;margin-right: 40px">Load Test</button>
{% endif %}
</form>
</div>
</div>
{% endfor %}
</ul>
</div>
......@@ -47,16 +56,34 @@ My Tests
<p><i> Test Name</i> <b>{{t.test_name}}</b> </p>
</div>
<div style="float:right">
<form method="POST" action="loadStudentTest">
<div class="row">
<form method="POST" action="loadStudentTest" style="float:right;">
{% csrf_token %}
<input name="testID" value="{{t.test_ID}}" type="hidden">
<button type="submit" class="btn btn-login float-right" style="margin-top: 10px ;margin-right: 40px">Load Test</button>
<button type="submit" class="btn btn-login float-right"
style="margin-top: 10px ;margin-right: 40px">Load Test</button>
</form>
<form method="POST" action="viewStudentPerformance">
<form method="POST" action="viewStudentPerformance" style="float:left;">
{% csrf_token %}
<!-- {% if t.hasTaken is True %} -->
<input name="test_ID" value="{{t.test_ID}}" type="hidden">
<button type="submit" class="btn btn-login float-right"
style="margin-top: 10px ;margin-right: 40px; background-color: gray; ">View Results</button>
<!-- {% endif %} -->
</form>
<form method="POST" action="CompareResponses" style="float:left;">
{% csrf_token %}
{% if t.hasTaken is True %}
<input name="test_ID" value="{{t.test_ID}}" type="hidden">
<button type="submit" class="btn btn-login float-right" style="margin-top: 10px ;margin-right: 40px">View Results</button>
<button type="submit" class="btn btn-login float-right"
style="margin-top: 10px ;margin-right: 40px; background-color: gray; ">View Responses</button>
{% endif %}
</form>
</div>
</div>
</div>
{% endfor %}
......
{%extends 'base2.html'%}
{%block title%}
View personal Question
{%endblock%}
{%block body%}
<h1 style="text-align:center"> You CAN VIEW all tests prof {{username}}</h1>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
<h1 style="text-align:center"> View all tests here</h1>
<div class="container">
<div class="panel-default">
<div class="panel-heading">
......@@ -19,9 +17,25 @@ View personal Question
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
{{test.test_name}}
<p> <h4> {{test.test_name}} </h4> </p>
<p> Start Time : {{test.start_time}} </p>
<p> Duration : {{test.duration}} </p>
<p> Maximum marks : {{test.max_marks}} </p>
</div>
<form method="POST" action="viewTestPerformance">
{% csrf_token %}
<input name="test_ID" value="{{test.test_id}}" type="hidden">
<button>View Performence</button>
</form>
<!-- <form method="POST" action="EditTest">
{% csrf_token %}
<input name="test_ID" value="{{test.test_ID}}" type="hidden">
<button>Edit Test</button>
</form> -->
</div>
<div>
<hr></hr>
</div>
......
......@@ -20,10 +20,20 @@ View all Question
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
{{question.question_text}}
<p> <b> Question. </b> {{question.question_text}}</p>
{%if question.ip%}
{%load static%}
<div align="center">
<img src = "{% static "" %}{{question.ip|slice:"16:" }}" width="35%" height="35%">
<p style="margin-top:5px">
{{question.imdesc}}
</p>
</div>
{%endif%}
</div>
</div>
<div>
<div class="col-xs-10">
<hr></hr>
<!-- <div class="container"> -->
<!-- <div class="fluid-row"> -->
......@@ -35,7 +45,9 @@ View all Question
</li>
{%else%}
<li>
<p>
{{option.option_text}}
</p>
</li>
{%endif%}
{%endfor%}
......
......@@ -4,8 +4,7 @@
View personal Question
{%endblock%}
{%block body%}
<h1 style="text-align:center"> You CAN VIEW your tests prof {{username}}</h1>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
<h1 style="text-align:center"> View your tests here</h1>
<div class="container">
<div class="panel-default">
<div class="panel-heading">
......
......@@ -4,24 +4,40 @@
View personal Question
{%endblock%}
{%block body%}
<h1 style="text-align:center"> You CAN VIEW personal QUESTION HERE prof {{username}}</h1>
<style>
p {
font-size: 130%
}
</style>
<h2 align="center"> View personal questions here </h2>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
<div class="container">
<div class="panel-default">
<div class="panel-heading">
<div class="panel-default" >
<div class="panel-heading" >
<h3 class="panel-title">LIST OF QUESTIONS</h3>
</div>
</div>
<ul class="list-group">
<!-- <ul> -->
{%for question in questions%}
<li class="list-group-item">
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
{{question.question_text}}
</div>
<p> <b> Question. </b> {{question.question_text}} </p>
{%if question.ip%}
{%load static%}
<div align="center">
<img src = "{% static "" %}{{question.ip|slice:"16:" }}" width="35%" height="35%">
<p style="margin-top:5px">
{{question.imdesc}}
</p>
</div>
{%endif%}
</div>
</div>
<div>
<div >
<hr></hr>
<ul>
{%for option in question.option_details%}
......@@ -31,7 +47,9 @@ View personal Question
</li>
{%else%}
<li>
<p>
{{option.option_text}}
</p>
</li>
{%endif%}
{%endfor%}
......@@ -40,6 +58,7 @@ View personal Question
</li>
{%endfor%}
</ul>
</div>
</div>
</div>
{%endblock%}
\ No newline at end of file
......@@ -29,6 +29,7 @@ urlpatterns=[
url(r'^loadStudentTest', views.loadStudentTest),
url(r'^viewTestPerformance',views.analyse_test),
url(r'^viewStudentPerformance',views.student_results),
url(r'^CompareResponses',views.student_responses),
# url(r'^viewStudentPerformance',views.student_responses),
......
......@@ -113,12 +113,13 @@ def getOptions(question): #returns queryset
def get_all_questions(request):
args={'username':request.session['username']}
# args = {'username':'mathura'}
cursor = connection.cursor()
cursor.execute(''' SELECT s.subject,q."q_ID" as q_ID,q.question_text,q.topic,q.subtopic,q.source,
q.difficulty_set,q.visibility,q.ownership,o."option_Value" as option_details,
q.difficulty_set,q.visibility,q.ownership,q.image as ip , q."imageDesc" as imdesc,
o."option_Value" as option_details,
o."is_Answer"
FROM "ARFA_app_question" as q,
FROM ("ARFA_app_question" as u LEFT OUTER JOIN "ARFA_app_questionimage" as v ON
u."q_ID" = v."q_ID_id") as q,
"ARFA_app_options" as o,"ARFA_app_subject" as s
WHERE ( q.faculty_id = %s or q.visibility='public' ) and s."subject_ID" = q."subject_ID_id" and q."q_ID" = o."q_ID_id"
order by s.subject,q_ID ''',[args['username']])
......@@ -126,6 +127,15 @@ def get_all_questions(request):
return res
def get_difficulty(request):
if(request.session.get('session',None)!=True):
return render(request,'ARFA_app/login.html')
if(request.session.get('role',None)!="faculty"):
return render(request,'ARFA_app/not_a_faculty.html',request.session.get('args',None))
else:
Diff = request.POST['difficulty']
Questions = models.Questions.objects.filter(difficulty_set = Diff)
def result_analysis(request,test_ID):
if(request.session.get('session',None)!=True):
......@@ -138,7 +148,6 @@ def result_analysis(request,test_ID):
order by total_marks desc ''',[test_ID])
rows = cursor.fetchall()
print rows
columns = [col[0] for col in cursor.description]
res_stud = []
for val in rows:
......@@ -151,7 +160,6 @@ def result_analysis(request,test_ID):
WHERE "test_ID_id" = %s''',[test_ID])
rows = cursor.fetchall()
print rows
columns = [col[0] for col in cursor.description]
res_agg=dict(zip(columns,rows[0]))
......@@ -159,44 +167,40 @@ def result_analysis(request,test_ID):
cursor.execute(''' SELECT floor(total_marks/10) as left_bin,count(student_ID) as cnt
FROM "ARFA_app_takes"
WHERE "test_ID_id" = %s
GROUP BY total_marks/10
GROUP BY left_bin
order by left_bin''',[test_ID])
hist = cursor.fetchall()
y=0
if hist!=[]:
y = int(list(hist[-1])[0])
y = int(hist[-1][0])
y = y+1
hist = [ [str(str(int(x[0]))+"-"+str(int(x[0])+10)),int(x[1])] for x in hist]
hist = [ [str(str(int(x[0])*10)+"-"+str(int(x[0])*10+10)),int(x[1])] for x in hist]
y = y+10
for i in range(15):
hist.append([str(str(y)+"-"+str(y+10)),0])
y=y+10
for i in range(5):
hist.append([str(str(y*10)+"-"+str(y*10+10)),0])
y=y+1
cursor = connection.cursor()
cursor.execute(''' SELECT q."q_ID" as q_ID,q.question_text,q.difficulty_set,
q.difficulty_observed,s.subject,o."option_Value" as option_details,
q.difficulty_observed,s.subject, q.image as ip , q."imageDesc" as imdesc,
o."option_Value" as option_details,
o."is_Answer"
FROM "ARFA_app_contains" as c,"ARFA_app_question" as q,
FROM "ARFA_app_contains" as c,
("ARFA_app_question" as u LEFT OUTER JOIN "ARFA_app_questionimage" as v ON
u."q_ID" = v."q_ID_id") as q,
"ARFA_app_options" as o, "ARFA_app_subject" as s
WHERE o."q_ID_id" = q."q_ID" and c."q_ID_id" = q."q_ID" and q."subject_ID_id" = s."subject_ID"
and c."test_ID_id" = %s
ORDER BY s.subject,q.difficulty_observed desc,o."q_ID_id" ''',[test_ID])
# rows = cursor.fetchall()
# print rows
# columns = [col[0] for col in cursor.description]
# q_stats = []
# for val in rows:
# q_stats.append(dict(zip(columns,val)))
q_stats = get_questions_dict(cursor)
# print q_stats
args = {"student_performance":res_stud,"test_aggregates":res_agg,"question_stats":q_stats,"distribution":hist}
return args
......@@ -218,7 +222,6 @@ def get_questions_dict(cursor):
else:
if not(preval[0]==val[0] ):
preval[-1] = options_so_far
# preval[1] = "q"+str(preval[1])
t = dict(zip(columns[:-1], preval))
res.append(t)
options_so_far = [{"option_text":val[-2],"is_answer":val[-1]}]
......@@ -258,9 +261,6 @@ def get_responses_side_by_side(test,student):
ORDER BY o."q_ID_id" ,o."option_ID" ''',[student.username,test.test_ID,test.test_ID])
args["responses"]=get_questions_dict(cursor)
print len(args["responses"])
print len(args["answers"])
print args["responses"]
bargs = []
for i in range(len(args["responses"])):
bargs.append({"answer":args["answers"][i],"response":args["responses"][i]})
......
This diff is collapsed.
pip install django-background-tasks
\ 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