-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84e6437
commit e159e3e
Showing
10 changed files
with
251 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Authentication | ||
from .models import * | ||
|
||
admin.site.register(Authentication) | ||
|
||
admin.site.register(hidden_grades) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from rest_framework.authtoken.models import Token | ||
from rest_framework import serializers | ||
|
||
|
||
from applications.academic_procedures.models import (course_registration) | ||
|
||
class CourseRegistrationSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = course_registration | ||
fields = ('__all__') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
from django.conf.urls import url | ||
from django.urls import path, include | ||
from . import views | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^registered_student_details/', views.fetch_student_details, name='fetch_student_details'), | ||
url(r'^update_grade/', views.update_grade, name='update_grade'), | ||
url(r'^add_student/', views.add_student, name='add_student'), | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
from django.db.models.query_utils import Q | ||
from django.http import request,HttpResponse | ||
from django.shortcuts import get_object_or_404, render, HttpResponse,redirect | ||
from django.http import HttpResponse, HttpResponseRedirect | ||
import itertools | ||
from django.contrib import messages | ||
from django.contrib.auth.decorators import login_required | ||
from django.contrib.auth.models import User | ||
from django.http import JsonResponse | ||
|
||
from applications.academic_procedures.models import(course_registration) | ||
|
||
from . import serializers | ||
from applications.examination.models import(hidden_grades) | ||
|
||
from rest_framework import status | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
|
||
|
||
|
||
@api_view(['GET']) | ||
def fetch_student_details(request): | ||
if request.method == 'GET': | ||
# obj=course_registration.objects.filter(course_id__id=course_id, student_id__batch=batch) | ||
student_obj=course_registration.objects.all() | ||
student_serialized = serializers.CourseRegistrationSerializer(student_obj , many=True).data | ||
resp = { | ||
'objt' : student_serialized | ||
} | ||
|
||
return Response(data=resp , status=status.HTTP_200_OK) | ||
|
||
|
||
|
||
@api_view(['POST']) | ||
def update_grade(request): | ||
if request.method == 'POST': | ||
student_id = request.POST.get('student_id') | ||
course_id = request.POST.get('course_id') | ||
new_grade = request.POST.get('grade') | ||
|
||
private_grade = get_object_or_404(private_grade, student_id=student_id, course_id=course_id) | ||
private_grade.grade = new_grade | ||
private_grade.save() | ||
|
||
return JsonResponse({'message': 'Grade updated successfully'}) | ||
else: | ||
return JsonResponse({'error': 'Invalid request method'}, status=400) | ||
|
||
|
||
def add_student(request): | ||
if request.method == 'POST': | ||
# Assuming the POST request contains necessary data for a new student | ||
student_id = request.POST.get('student_id') | ||
course_id = request.POST.get('course_id') | ||
semester_id = request.POST.get('semester_id') | ||
grades = request.POST.get('grades') | ||
|
||
# Create a new private_grade object | ||
new_student = hidden_grades.objects.create( | ||
student_id=student_id, | ||
course_id=course_id, | ||
semester_id=semester_id, | ||
grades=grades | ||
) | ||
|
||
return JsonResponse({'message': 'Student added successfully'}) | ||
else: | ||
return JsonResponse({'error': 'Invalid request method'}, status=400) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# @login_required(login_url='/accounts/login') | ||
# def exam(request): | ||
# """ | ||
# This function is used to Differenciate acadadmin and all other user. | ||
|
||
# @param: | ||
# request - contains metadata about the requested page | ||
|
||
# @variables: | ||
# user_details - Gets the information about the logged in user. | ||
# des - Gets the designation about the looged in user. | ||
# """ | ||
# user_details = ExtraInfo.objects.get(user = request.user) | ||
# des = HoldsDesignation.objects.all().filter(user = request.user).first() | ||
# if str(des.designation) == "Associate Professor" or str(des.designation) == "Professor" or str(des.designation) == "Assistant Professor" : | ||
# return HttpResponseRedirect('/examination/submit/') | ||
# elif str(request.user) == "acadadmin" : | ||
# return HttpResponseRedirect('/examination/submit/') | ||
|
||
# return HttpResponseRedirect('/dashboard/') | ||
|
||
# @login_required(login_url='/accounts/login') | ||
|
||
|
||
# def submit(request): | ||
|
||
# return render(request,'../templates/examination/submit.html' , {}) | ||
|
||
# @login_required(login_url='/accounts/login') | ||
# def verify(request): | ||
# return render(request,'../templates/examination/verify.html' , {}) | ||
|
||
# @login_required(login_url='/accounts/login') | ||
# def publish(request): | ||
# return render(request,'../templates/examination/publish.html' ,{}) | ||
|
||
|
||
# @login_required(login_url='/accounts/login') | ||
# def notReady_publish(request): | ||
# return render(request,'../templates/examination/notReady_publish.html',{}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
FusionIIIT/applications/examination/migrations/0003_hidden_grades.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.1.5 on 2024-02-17 10:21 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('examination', '0002_auto_20240217_0001'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='hidden_grades', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('student_id', models.CharField(max_length=20)), | ||
('course_id', models.CharField(max_length=50)), | ||
('semester_id', models.CharField(max_length=10)), | ||
('grade', models.CharField(max_length=5)), | ||
], | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
FusionIIIT/applications/examination/migrations/0004_auto_20240217_1024.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.5 on 2024-02-17 10:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('examination', '0003_hidden_grades'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='hidden_grades', | ||
name='grade', | ||
field=models.CharField(default='C', max_length=5), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
# your_app/models.py | ||
|
||
|
||
from django.db import models | ||
|
||
class Authentication(models.Model): | ||
authenticator_1 = models.BooleanField(default=False) | ||
authenticator_2 = models.BooleanField(default=False) | ||
authenticator_3 = models.BooleanField(default=False) | ||
course = models.CharField(max_length=255, default="") | ||
timestamp = models.DateTimeField(default=timezone.now) | ||
def save(self, *args, **kwargs): | ||
|
||
self.timestamp = timezone.now() | ||
super(Authentication, self).save(*args, **kwargs) | ||
|
||
def __str__(self): | ||
return f"{self.course} - Auth1: {self.authenticator_1}, Auth2: {self.authenticator_2}, Auth3: {self.authenticator_3}" | ||
|
||
|
||
class hidden_grades(models.Model): | ||
student_id = models.CharField(max_length=20) | ||
course_id = models.CharField(max_length=50) | ||
semester_id = models.CharField(max_length=10) | ||
grade = models.CharField(max_length=5,default="C") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
FusionIIIT/applications/globals/migrations/0005_auto_20240217_0001.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.5 on 2024-02-17 00:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('globals', '0004_auto_20240215_1257'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='extrainfo', | ||
name='user_status', | ||
field=models.CharField(choices=[('PRESENT', 'PRESENT'), ('NEW', 'NEW')], default='PRESENT', max_length=50), | ||
), | ||
] |