Commit c6b58b6d authored by SANCHIT JAIN's avatar SANCHIT JAIN

uploading report and password hashes

parent 8639abc8
...@@ -88,7 +88,7 @@ DATABASES = { ...@@ -88,7 +88,7 @@ DATABASES = {
'USERNAME':'arfa_username', 'USERNAME':'arfa_username',
'USER':'arfa_username', 'USER':'arfa_username',
'PASSWORD':'', 'PASSWORD':'',
'HOST': '10.42.0.43', 'HOST': '10.196.2.153',
'PORT': '5430' 'PORT': '5430'
} }
} }
......
...@@ -197,12 +197,14 @@ function prevTab(elem) { ...@@ -197,12 +197,14 @@ function prevTab(elem) {
error = '<small class="text-muted error">' + error + '</small>' error = '<small class="text-muted error">' + error + '</small>'
$form.find('[name=' + name + ']').after(error); $form.find('[name=' + name + ']').after(error);
}) })
alert(response.error);
} }
else{ else{
alert(response.message) alert(response.message);
i = 1 ; i = 1 ;
window.location = "" ; window.location = "" ;
console.log("Added image also") ; console.log("Added image also") ;
// alert(response.message);
} }
}, },
cache: false, cache: false,
......
...@@ -87,14 +87,14 @@ profile ...@@ -87,14 +87,14 @@ profile
<h3>Tests Given</h3> <h3>Tests Given</h3>
<h4>{{tests_given}}</h4> <h4>{{tests_given}}</h4>
</div> </div>
<div class="col-md-4 user-pad text-center"> <!-- <div class="col-md-4 user-pad text-center">
<h3>Q Solved</h3> <h3>Q Solved</h3>
<h4>{{question_solved}}</h4> <h4>{{question_solved}}</h4>
</div> </div> -->
<div class="col-md-4 user-pad text-center"> <div class="col-md-4 user-pad text-center">
<h3>Best Rank</h3> <h3>Best Rank</h3>
<!-- TODO: Find rank relative to other students --> <!-- TODO: Find rank relative to other students -->
<h4>5</h4> <h4>{{best_rank}}</h4>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -59,10 +59,11 @@ My Tests ...@@ -59,10 +59,11 @@ My Tests
<div class="row"> <div class="row">
<form method="POST" action="loadStudentTest" style="float:right;"> <form method="POST" action="loadStudentTest" style="float:right;">
{% csrf_token %} {% csrf_token %}
{% if t.hasTaken is False %}
<input name="testID" value="{{t.test_ID}}" type="hidden"> <input name="testID" value="{{t.test_ID}}" type="hidden">
<button type="submit" class="btn btn-login float-right" <button type="submit" class="btn btn-login float-right"
style="margin-top: 10px ;margin-right: 40px">Load Test</button> style="margin-top: 10px ;margin-right: 40px">Load Test</button>
{%endif%}
</form> </form>
<form method="POST" action="viewStudentPerformance" style="float:left;"> <form method="POST" action="viewStudentPerformance" style="float:left;">
{% csrf_token %} {% csrf_token %}
......
...@@ -29,7 +29,7 @@ from .forms import ImageFileUploadForm ...@@ -29,7 +29,7 @@ from .forms import ImageFileUploadForm
from django.http import JsonResponse from django.http import JsonResponse
import datetime import datetime
import hashlib
def login(request): def login(request):
# This is the Login page and checks if anyone is already logged in and redirects accordingly # This is the Login page and checks if anyone is already logged in and redirects accordingly
if(request.session.get('session',None)==True): if(request.session.get('session',None)==True):
...@@ -74,7 +74,7 @@ def reg(request): ...@@ -74,7 +74,7 @@ def reg(request):
# TODO: create a subsitute table which records student and teacher applications and an Admin must approve it and set salary for the faculty or other relavant stuff # TODO: create a subsitute table which records student and teacher applications and an Admin must approve it and set salary for the faculty or other relavant stuff
if(request.method=="POST"): if(request.method=="POST"):
role=request.POST['role'] 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']} data={'username': request.POST['username'], 'name':request.POST['name'],'email_ID': request.POST['email_ID'],'address':request.POST['address'],'password':hashlib.md5(request.POST['password']).hexdigest(),'phone_number':request.POST['phone_number']}
try: try:
if(role=="Student"): if(role=="Student"):
print "Student with name "+ data['name']+" registered" print "Student with name "+ data['name']+" registered"
...@@ -155,8 +155,16 @@ def profile(request): ...@@ -155,8 +155,16 @@ def profile(request):
tests_given=models.Takes.objects.filter(student=args['username']).count() tests_given=models.Takes.objects.filter(student=args['username']).count()
question_solved=9 question_solved=9
cursor = connection.cursor()
cursor.execute(''' SELECT min(rank) from "ARFA_app_takes" where "student_id"=%s and rank>0''',[args['username']])
r=cursor.fetchall()
if len(r)>0:
best_rank=r[0][0]
else:
best_rank=None
# best_rank=models.Takes.objects.all().filter(student__username=args['username']).aggregate(kk=min('rank'))
# question_solved=models.Responses.objects.filter(student_ID=args['username']).annotate(myalias="q_ID").count() # question_solved=models.Responses.objects.filter(student_ID=args['username']).annotate(myalias="q_ID").count()
args3={'tests_given':tests_given,'question_solved':question_solved} args3={'tests_given':tests_given,'question_solved':question_solved,'best_rank':best_rank}
args.update(args3) args.update(args3)
print "rendering student home for student "+args['name'] print "rendering student home for student "+args['name']
...@@ -210,12 +218,12 @@ def profile(request): ...@@ -210,12 +218,12 @@ def profile(request):
return redirect('/arfa') return redirect('/arfa')
def check_auth(args): def check_auth(args):
tuple=models.Student.objects.filter(username=args["user"],password=args["password"]) tuple=models.Student.objects.filter(username=args["user"],password=hashlib.md5(args["password"]).hexdigest())
if len(tuple)==1 : if len(tuple)==1 :
return {'status':True,'object':tuple[0],'role':"student"} return {'status':True,'object':tuple[0],'role':"student"}
else : else :
tuple=models.Faculty.objects.filter(username=args["user"],password=args["password"]) tuple=models.Faculty.objects.filter(username=args["user"],password=hashlib.md5(args["password"]).hexdigest())
if len(tuple)==1 : if len(tuple)==1 :
return {'status':True,'object':tuple[0],'role':"faculty"} return {'status':True,'object':tuple[0],'role':"faculty"}
else : else :
...@@ -639,7 +647,7 @@ def student_results(request): ...@@ -639,7 +647,7 @@ def student_results(request):
test_ID = request.POST["test_ID"] test_ID = request.POST["test_ID"]
test = models.Test.objects.filter(test_ID=test_ID , test = models.Test.objects.filter(test_ID=test_ID ,
start_time__lte = -datetime.timedelta(minutes=5) + datetime.datetime.now() - F('expected_time_for_completion')).all() start_time__lte = -datetime.timedelta(seconds=5) + datetime.datetime.now() - F('expected_time_for_completion')).all()
if len(test)==0: if len(test)==0:
...@@ -685,7 +693,7 @@ def student_responses(request): ...@@ -685,7 +693,7 @@ def student_responses(request):
test = models.Test.objects.filter(test_ID=test_ID , test = models.Test.objects.filter(test_ID=test_ID ,
start_time__lte = -datetime.timedelta(minutes=5) + datetime.datetime.now() - F('expected_time_for_completion')).all() start_time__lte = -datetime.timedelta(seconds=5) + datetime.datetime.now() - F('expected_time_for_completion')).all()
if len(test)==0: if len(test)==0:
......
This diff is collapsed.
This diff is collapsed.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.core.validators import MinLengthValidator
# Create your models here.
class Student(models.Model):
name = models.CharField(max_length=200)
phone_number = models.CharField(max_length=10)
email_ID = models.CharField(max_length=200)
address = models.CharField(max_length=400)
username = models.CharField(max_length=200,primary_key=True)
password = models.CharField(max_length=200,validators=[MinLengthValidator(4)])
class Faculty(models.Model):
name = models.CharField(max_length=200)
phone_number = models.CharField(max_length=10)
email_ID = models.CharField(max_length=200)
address = models.CharField(max_length=400)
username = models.CharField(max_length=200,primary_key=True)
password = models.CharField(max_length=200,validators=[MinLengthValidator(4)])
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)
expected_time_for_completion = models.DurationField(blank=True)
start_time = models.DateTimeField(auto_now=False, auto_now_add=False)
max_marks = models.FloatField(null=True)
class Subject(models.Model):
subect_ID = models.CharField(max_length=20,primary_key=True)
subject = models.CharField(max_length=20)
class Question(models.Model):
q_ID = models.AutoField(primary_key=True)
subect_ID = models.ForeignKey('Subject', on_delete=models.CASCADE)
faculty = models.ForeignKey('Faculty',models.SET_NULL,blank=True,null=True)
topic = models.CharField(max_length=20)
subtopic = models.CharField(max_length=20)
time_stamp = models.DateTimeField(auto_now=True)
source = models.CharField(max_length=200)
dificulty_set = models.CharField(max_length=20)
dificulty_observed = models.CharField(max_length=20)
qestion_text = models.CharField(max_length=1000)
image_link = models.CharField(max_length=200)
num_appeared = models.IntegerField
num_correct = models.IntegerField
visibility = models.CharField(max_length=20)
ownership = models.CharField(max_length=20)
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