Commit 466b5c37 authored by NARRA SURAJ's avatar NARRA SURAJ

Merge branch 'master' of https://git.cse.iitb.ac.in/ARFA/ARFA

parents 9e9fe6ec c0b01136
{
"python.linting.enabled": false
}
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-26 08:57
# Generated by Django 1.11.16 on 2018-11-26 21:16
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(
......
......@@ -58,7 +58,7 @@ Create Test
{%block body%}
<h1> You CAN CREATE A Test HERE prof {{username}}</h1>
<h1 style="text-align:center"> You CAN CREATE A Test HERE prof {{username}}</h1>
<div class="container">
<div class="panel-default">
......
......@@ -228,7 +228,7 @@ Create Question
{%endblock%}
{%block body%}
<h3> You CAN CREATE A QUESTION HERE prof {{username}}</h3>
<h3 style="text-align:center"> You CAN CREATE A QUESTION HERE prof {{username}}</h3>
<div class="container" title="this is title">
<div class="row">
<section>
......@@ -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>
......
......@@ -16,12 +16,16 @@ Total Time :<b > {{total_time.hours}} {{total_time.minutes}} </b>
<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 }} );
countDownDate.setMonth(countDownDate.getMonth() - 1) ;
countDownDate.setMonth(countDownDate.getMonth() - 1) ;
countDownDate.setMonth(countDownDate.getMonth() - 1) ;
console.log(countDownDate) ;
// Update the count down every 1 second
var x = setInterval(function() {
......@@ -51,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>
......
......@@ -12,7 +12,7 @@ Logout
{%endblock%}
{%block body%}
<h3 class="myh3 deepshd"> You have succesfully logged out </h3>
<h3 style="text-align:center" class="myh3 deepshd"> You have succesfully logged out </h3>
<!-- <div class="container">
<centre>
<h1> You have succesfully logged out</h1>
......
......@@ -7,5 +7,5 @@ View All Question
{%endblock%}
{%block body%}
<h1> You are not authorized for this action {{username}}</h1>
<h1 style="text-align:center"> You are not authorized for this action {{username}}</h1>
{%endblock%}
\ No newline at end of file
{%extends 'base2.html'%}
{%block title%}
View personal Question
{%endblock%}
{%block head%}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
// data.addColumn('string', 'Number');
data.addColumn('string', 'bin');
data.addColumn('number', 'Count');
// data.addRows( [['100',10],['90',9],['80',8]] );
data.addRows( {{distribution|safe}} );
console.log(data)
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, {width: 500, height: 300, title: "Scores Distribution"});
}
</script>
{%endblock%}
{%block body%}
<h1 style="text-align:center"> Test Performance</h1>
<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">
<h3 class="panel-title"> Test Stats </h3>
</div>
<ul class="list-group">
<li class="list-group-item">
<div class="row toggle">
<div id="c1" class="col-xs-10" style="float:left;width:50%">
<p> Average Score : {{test_aggregates.avg_marks}}</p>
<p>Best Score : {{test_aggregates.max_marks}} </p>
<p>Minimum score : {{test_aggregates.max_marks}} </p>
<p>Students appeared : {{test_aggregates.students_appeared}}</p>
</div>
<div class="col-xs-10" style="float: right;width:50%" id="chart_div"> </div>
</div>
<!-- <div>
<hr></hr>
</div> -->
</li>
</ul>
<!-- <div id="chart_div" > </div> -->
<div class="panel-heading">
<h3 class="panel-title"> Student Performance </h3>
</div>
<ul class="list-group">
{%for p in student_performance%}
<li class="list-group-item">
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
<p> student: {{p.student_id}}</p>
<p> rank: {{p.rank}}</p>
<p> Score: {{p.marks}}</p>
</div>
</div>
<!-- <div class="container"> -->
<!-- <div class="fluid-row"> -->
<!-- <ul>
{%for option in question.option_details%}
{%if option.is_answer %}
<li>
<p style="color: green"> {{option.option_text}} </p>
</li>
{%else%}
<li>
{{option.option_text}}
</li>
{%endif%}
{%endfor%}
</ul> -->
<!-- </div> -->
<!-- </div> -->
</li>
{%endfor%}
</ul>
<div class="panel-heading">
<h3 class="panel-title"> Per Question stats </h3>
</div>
<ul class="list-group">
{%for q in question_stats%}
<li class="list-group-item">
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
<p> Difficulty set: {{q.difficulty_set}}</p>
<p> Difficulty observed: {{q.difficulty_observed}}</p>
<p> Question: {{q.question_text}} </p>
</div>
</div>
<div>
<div>
<hr></hr>
<!-- <div class="container"> -->
<!-- <div class="fluid-row"> -->
<ul>
{%for option in q.option_details%}
{%if option.is_answer %}
<li>
<p style="color: green"> {{option.option_text}} </p>
</li>
{%else%}
<li>
{{option.option_text}}
</li>
{%endif%}
{%endfor%}
</ul>
<!-- </div> -->
<!-- </div> -->
</div>
</div>
</li>
{%endfor%}
</ul>
</div>
</div>
{%endblock%}
......@@ -5,6 +5,8 @@ profile
{%block body%}
<h1 style="text-align:center">Test Successfully Recorded </h1>
{%endblock%}
\ No newline at end of file
......@@ -52,6 +52,11 @@ My Tests
<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>
</form>
<form method="POST" action="viewTestPerformance">
{% csrf_token %}
<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>
</form>
</div>
</div>
{% endfor %}
......
{%extends 'base2.html'%}
{%block head%}
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
{%endblock%}
{%block title%}
View personal Question
{%endblock%}
{%block body%}
<h1> You CAN VIEW all your tests HERE student {{username}}</h1>
<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">
<h3 class="panel-title">LIST OF QUESTIONS</h3>
</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>
</div>
<div>
<hr></hr>
<!-- <div class="container"> -->
<!-- <div class="fluid-row"> -->
<ul>
{%for option in question.option_details%}
<!-- <div class="col-xs-1"> -->
<li> {{option.is_answer}}
<!-- </div> -->
<!-- <div class="col-xs-5"> -->
{{option.option_text}}
<!-- </div> -->
</li>
{%endfor%}
</ul>
<!-- </div> -->
<!-- </div> -->
</div>
</li>
{%endfor%}
</ul>
</div>
</div>
{%endblock%}
\ No newline at end of file
{%extends 'base2.html'%}
{%block title%}
View All Test
View personal Question
{%endblock%}
{%block body%}
<h1> You CAN VIEW ALL Test HERE prof {{username}}</h1>
<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">
<div class="container">
<div class="panel-default">
<div class="panel-heading">
<h3 class="panel-title">LIST OF TESTS</h3>
</div>
<ul class="list-group">
<!-- <ul> -->
{%for test in tests%}
<li class="list-group-item">
<!-- <li> -->
<div class="row toggle">
<div class="col-xs-10">
{{test.test_name}}
</div>
</div>
<div>
<hr></hr>
</div>
</li>
{%endfor%}
</ul>
</div>
</div>
{%endblock%}
\ No newline at end of file
{%extends 'base2.html'%}
{%block title%}
View all Question
{%endblock%}
{%block body%}
<h1> You CAN VIEW all questions QUESTION HERE prof {{username}}</h1>
<h1 style="text-align:center"> You CAN VIEW all questions QUESTION HERE prof {{username}}</h1>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
<div class="container">
<div class="panel-default">
......@@ -34,7 +35,9 @@ View all Question
</li>
{%else%}
<li>
<p>
{{option.option_text}}
</p>
</li>
{%endif%}
{%endfor%}
......
{%extends 'base2.html'%}
{%block head%}
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
{%endblock%}
{%block title%}
View personal Question
{%endblock%}
{%block body%}
<h1> You CAN VIEW your tests prof {{username}}</h1>
<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">
<div class="container">
<div class="panel-default">
......@@ -25,9 +18,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>
......
......@@ -4,7 +4,12 @@
View personal Question
{%endblock%}
{%block body%}
<h1> You CAN VIEW personal QUESTION HERE prof {{username}}</h1>
<style>
p {
font-size: 130%
}
</style>
<h2 align="center"> You CAN VIEW personal QUESTIONS HERE prof {{username}}</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">
......@@ -18,7 +23,17 @@ View personal 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>
......@@ -31,7 +46,9 @@ View personal Question
</li>
{%else%}
<li>
<p>
{{option.option_text}}
</p>
</li>
{%endif%}
{%endfor%}
......
......@@ -22,6 +22,7 @@
{% load static %}
<link rel="stylesheet" href="{% static 'ARFA_app/style.css' %}" type="text/css">
<script type="text/javascript" src="{% static 'ARFA_app/lib/MathJax-2.7.5/MathJax.js' %}">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" src="{% static 'ARFA_app/lib/MathJax-2.7.5/config/TeX-MML-AM_CHTML-full.js' %}">
</script>
......
......@@ -27,5 +27,7 @@ urlpatterns=[
url(r'^reg',views.reg),
url(r'^studentTestHome', views.studentTestHome),
url(r'^loadStudentTest', views.loadStudentTest),
url(r'^viewTestPerformance',views.analyse_test),
]
......@@ -21,6 +21,7 @@ from django.db.models import F
from pprint import pprint
import datetime
def evaluate(responses, otherData):
"""responses contains a list of dicts of the form {q_ID: [option1, option2 ..]}
other data contains any other data necessary for evaluation such as testID and studentID"""
......@@ -121,8 +122,89 @@ def get_all_questions(request):
"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']])
res = get_questions_dict(cursor)
return res
def result_analysis(request,test_ID):
if(request.session.get('session',None)!=True):
return render(request,'ARFA_app/login.html')
cursor = connection.cursor()
cursor.execute(''' SELECT student_id,total_marks as marks,rank
FROM "ARFA_app_takes"
WHERE "test_ID_id" = %s
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:
res_stud.append(dict(zip(columns,val)))
cursor = connection.cursor()
cursor.execute(''' SELECT avg(total_marks) as avg_marks,min(total_marks) as min_marks
,max(total_marks) as max_marks, count(student_id) as students_appeared
FROM "ARFA_app_takes"
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]))
cursor = connection.cursor()
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
order by left_bin''',[test_ID])
hist = cursor.fetchall()
y=0
if hist!=[]:
y = int(list(hist[-1])[0])
hist = [ [str(str(int(x[0]))+"-"+str(int(x[0])+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
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,
o."is_Answer"
FROM "ARFA_app_contains" as c,"ARFA_app_question" 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
def get_questions_dict(cursor):
rows = cursor.fetchall()
# print(len(rows))
print rows
columns = [col[0] for col in cursor.description]
res=[]
options_so_far = []
......@@ -146,7 +228,6 @@ def get_all_questions(request):
options_so_far.append({"option_text":val[-2],"is_answer":val[-1]})
if not(first):
preval[-1] = options_so_far
# preval[1] = "q"+str(preval[1])
t = dict(zip(columns[:-1], preval))
res.append(t)
return res
\ No newline at end of file
This diff is collapsed.
-- psql -h localhost -p 5430 -d arfa_database < <dump_file.sql>
--
-- PostgreSQL database dump
--
......
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