Skip to content
32 changes: 29 additions & 3 deletions csc/api/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from django.conf import settings

import random, string
from csc.models import Student_certificate_course,CategoryCourses,Student_Foss
from csc.models import Student_certificate_course,CategoryCourses,Student_Foss, Invigilator
from django.db import IntegrityError
from csc.utils import is_user_vle, is_user_student
from csc.utils import is_user_vle, is_user_student, is_user_invigilator
from django.template.loader import render_to_string
def send_pwd_mail(u):
print(u.username)
Expand Down Expand Up @@ -61,7 +61,33 @@ def send_pwd_mail(u):
Spoken Tutorial
"""
path = 'vle_mail_template.html'
html_content = render_to_string(path, {'full_name':u.get_full_name(),'username':u.username,'password':pwd})
if is_user_invigilator(u):
inv = Invigilator.objects.get(user=u)
name = inv.vle.all()[0].user.get_full_name()
message = f"""
Dear {u.get_full_name()},

Welcome to IIT Bombay Spoken Tutorial Program. We are happy to be partnered with CSC Academy to
empower youth from all over the country via VLEs.

You have been added as an invigilator by VLE {name}.

Please use the below Login details for the Spoken Tutorial Dashboard:
Link to Login: https://spoken-tutorial.in/login/
username : {u.username}
password : {pwd}
Please click the following training link to know the process of
Student Registration Instructions : https://docs.google.com/document/d/1z8-s4sSl7viPqJ8WAFeeNmoJUVLRPv2L9jLOrfN6ln0/edit?usp=sharing
Course Allotment Instructions : https://docs.google.com/document/d/1Mv23iijOVuS6eCcHCgYKbbxopjk_SkSfExXW-61G2AQ/edit?usp=sharing

In case of any query, please feel free to contact at [email protected].

Thanks & Regards,
Team,
Spoken Tutorial
"""
path = 'invigilator_mail_template.html'
html_content = render_to_string(path, {'full_name':u.get_full_name(), 'vle': name,'username':u.username,'password':pwd})
try:
print(f"/n/nSending mail ; username,pwd : {u.username},{pwd}".ljust(40,'*'))
send_mail(
Expand Down
4 changes: 2 additions & 2 deletions csc/stats/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
path('vle_stats/',VLEListView.as_view(),name="vle_stats"),
path('student_stats/',StudentListView.as_view(),name="student_stats"),
path('vle_report/',vle_report,name="vle_report"),
path('student_report/',student_report,name="student_report")

path('student_report/',student_report,name="student_report"),

path('test_report/',test_report,name="test_report")


]
32 changes: 29 additions & 3 deletions csc/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
from django.utils.decorators import method_decorator

from django.contrib.auth.mixins import LoginRequiredMixin
from csc.models import CSC,VLE,Student, FossCategory, CertifiateCategories, Student_Foss
from csc.models import CSC,VLE,Student, FossCategory, CertifiateCategories, Student_Foss, Test
from cms.models import State, District
from csc.decorators import is_csc_team as dec_is_csc_team
from csc.utils import is_csc_team_role
from .utility import *

from datetime import datetime


@login_required
@dec_is_csc_team
Expand All @@ -27,6 +29,8 @@ def stats(request):
context['total_students'] = total_students
context['total_foss'] = total_foss
context['total_certificate_course'] = total_certificate_course
context['total_test_conducted'] = Test.objects.filter(tdate__lt=datetime.now().date()).count()
context['total_upcoming_tests'] = Test.objects.filter(tdate__gte=datetime.now().date()).count()

student_gender = get_student_gender_stats()
context['student_gender'] = student_gender
Expand Down Expand Up @@ -153,7 +157,7 @@ def get_context_data(self, **kwargs):
return context
def get_queryset(self):
qs = super().get_queryset()
qs = qs_vle
qs = qs_vle.annotate(Count('test'))
if self.request.GET.get('name'):
name = self.request.GET.get('name')
qs = qs.filter(Q(user__first_name__icontains=name)|Q(user__last_name__icontains=name)|Q(user__email__icontains=name))
Expand Down Expand Up @@ -198,6 +202,8 @@ def ajax_vle_detail(request):
data['students'] = [x for x in Student.objects.filter(vle_id=vle_id).values('user__first_name', 'user__last_name','user__email')]
cert_category = CertifiateCategories.objects.get(code='INDI')
data['indi_fosses'] = [x for x in Student_Foss.objects.filter(student__vle_id=vle_id,cert_category=cert_category).values('csc_foss__foss').annotate(count=Count('csc_foss'))]
data['conducted_test'] = Test.objects.filter(vle=vle, tdate__lt=datetime.now().date()).count()
data['upcoming_test'] = Test.objects.filter(vle=vle, tdate__gte=datetime.now().date()).count()

return JsonResponse(data)

Expand Down Expand Up @@ -233,4 +239,24 @@ def vle_report(request):
csc_district = CSC.objects.values('district').annotate(count=Count('district')).order_by('district')
context['csc_district'] = csc_district

return render(request, 'stats/vle_report.html', context)
return render(request, 'stats/vle_report.html', context)

@login_required
@dec_is_csc_team
def test_report(request):
context = {}
all_foss = FossCategory.objects.annotate(upcoming_tests = Count('test', distinct=True, filter=Q(test__tdate__gte=datetime.now().date())), conducted_tests=Count('test', distinct=True, filter=Q(test__tdate__lt=datetime.now().date()))).order_by()
all_test = Test.objects.annotate(upcoming_students = Count('csctestatttendance', distinct=True, filter=Q(csctestatttendance__status__lte=2)), appeared_students = Count('csctestatttendance', distinct=True, filter=Q(csctestatttendance__status__gt=2)), all_certificates = Count('csctestatttendance', distinct=True, filter=Q(csctestatttendance__status__gte=3)))
foss = {}
for item in all_foss:
for value in all_test:
foss[item.foss] = {
'upcoming_tests': item.upcoming_tests,
'conducted_tests': item.conducted_tests,
'upcoming_students': value.upcoming_students,
'appeared_students': value.appeared_students,
'all_certificates': value.all_certificates,
}
context['fosses'] = foss
print(context['fosses']['Blender'])
return render(request, 'stats/test_report.html', context)
31 changes: 31 additions & 0 deletions csc/templates/csc/invigilator_mail_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Order received</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body style="margin: 0; padding: 0;">
<p>Dear {{full_name}},</p>
<p>Welcome to IIT Bombay Spoken Tutorial Program. We are happy to be partnered with CSC Academy to
empower youth from all over the country via VLEs.</p>

<p>You have been added as an invigilator by VLE {{vle}}.</p>

<p>Please use the below Login details for the Spoken Tutorial Dashboard:</p>
<p>Link to Login: https://spoken-tutorial.in/login/</p>

<p>username : {{username}}</p>
<p>password : {{password}}</p>

<p>Please click the following training link to know the process of </p>
<p>Student Registration Instructions : <a href="https://docs.google.com/document/d/1z8-s4sSl7viPqJ8WAFeeNmoJUVLRPv2L9jLOrfN6ln0/edit?usp=sharing">Click Here</a></p>
<p>Course Allotment Instructions : <a href="https://docs.google.com/document/d/1Mv23iijOVuS6eCcHCgYKbbxopjk_SkSfExXW-61G2AQ/edit?usp=sharing">Click Here</a></p>

<p>In case of any query, please feel free to contact at [email protected].</p>

<p>Thanks & Regards,</p>
<p>Team,</p>
<p>Spoken Tutorial</p>
</body>
</html>
32 changes: 11 additions & 21 deletions csc/templates/csc/test_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,30 @@
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th scope="col">FOSS</th>
<th scope="col">Date</th>
<th scope="col">Time</th>
{% comment %} <th scope="col">Published</th> {% endcomment %}
{% comment %} <th scope="col">Delete</th>
<th scope="col">Edit</th> {% endcomment %}
<th scope="col">Delete</th>
<th scope="col">Edit</th>
<th scope="col">Students</th>
<th scope="col">Upcoming</th>
<th scope="col">Appeared</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for test in tests %}
<tr>
<td>{{forloop.counter}}</td>
<td>
{% if test.test_name %}
<span>{{test.test_name | title}}</span>
{% else %}
<span>{{test.foss | title}} Test</span>
{% endif %}
</td>
<td>{{test.foss | title }}</td>
<td>{{test.tdate}}</td>
<td>{{test.ttime}}</td>
{% comment %} <td>
{% if test.publish %}
<i class="far fa-check-circle"></i>
{% else %}
<i class="far fa-times-circle"></i>
{% endif %}
</td> {% endcomment %}
{% comment %} <td><a href="{% url 'csc:delete_test' test.id %}"><i class="far fa-trash-alt"></i></a></td>
<td><a href="{% url 'csc:update_test' test.id %}"><i class="far fa-edit"></i></a></td> {% endcomment %}
<td>{% if test.tdate|is_gte_today %}
<td><a href="{% url 'csc:delete_test' test.id %}"><i class="far fa-trash-alt"></i></a></td>
<td><a href="{% url 'csc:update_test' test.id %}"><i class="far fa-edit"></i></a></td>
<td><a class="text-dark" href="{% url 'csc:test_students' test.id %}"><i class="fas fa-users"></i></a></td>
<td>{{test.upcoming_students}}</td>
<td>{{test.appeared_students}}</td>
<td>{% if test.tdate|is_today %}
<!-- <button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">Toggle right offcanvas</button> -->

<!-- <button class="btn btn-sm btn-warning attendance" id="att_{{test.id}}"></button> -->
Expand Down
74 changes: 74 additions & 0 deletions csc/templates/csc/test_students.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{% extends 'csc_base.html'%}
{% load static %}
{% load csc_tags %}
{% block css %}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" type="text/css" href="{% static '/spoken/utility.css' %}">
<style></style>
{% endblock css %}
{% block content %}
<div>
<div class="container">
<div>
<table class="table my-5" id="example">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Gender</th>
<th scope="col">Age</th>
<th scope="col">Phone</th>
<th scope="col">Edu Qualification</th>
<th scope="col">Occupation</th>
<th scope="col">Category</th>
<th scope="col">Status</th>
<th scope="col">Grade</th>
</tr>
</thead>
<tbody>
{% for test in tests %}
<tr>
<td>{{forloop.counter}}</td>
<td><a class="text-dark" href="{% url 'csc:student_profile' id=test.student_id %}">{{test.student.user.first_name | title}} {{test.student.user.last_name | title}}</a></td>
<td>{{test.student.user.email}}</td>
<td>{{test.student.gender | title}}</td>
<td>{{test.student.dob | timesince}}</td>
<td>{{test.student.phone}}</td>
<td>{{test.student.edu_qualification}}</td>
<td>{{test.student.occupation}}</td>
<td>{{test.student.category}}</td>
{% if test.status == 0%}
<td>Open</td>
{% elif test.status == 1%}
<td>Attendance Marked</td>
{% elif test.status == 2%}
<td>Ongoing</td>
{% elif test.status == 3%}
<td>Completed by Student</td>
{% elif test.status == 4%}
<td>Closed by VLE</td>
{% endif %}
<td>{{test.mdlgrade}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div>
</div>
</div>
{% endblock %}
{% block script %}
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>
<script>
$(document).ready(function () {
$('#example').DataTable({
"pageLength": 100
});
});
</script>
{% endblock %}
12 changes: 12 additions & 0 deletions csc/templates/stats/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
<p class="fs-3">{{total_certificate_course}}</p>
</div>
</div>
<div class=" col-md-3 col-sm-6 p-2 ">
<div class="border rounded p-3 count">
<p class="font-size-xs text-uppercase">Total Tests Conducted</p>
<p class="fs-3">{{total_test_conducted}}</p>
</div>
</div>
<div class=" col-md-3 col-sm-6 p-2 ">
<div class="border rounded p-3 count">
<p class="font-size-xs text-uppercase">Total Upcoming Tests</p>
<p class="fs-3">{{total_upcoming_tests}}</p>
</div>
</div>
</div>
<div class="row">
<div class=" col p-2">
Expand Down
6 changes: 6 additions & 0 deletions csc/templates/stats/stats_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-
Student Stats
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'test_report' %}" id="test_report">
<span data-feather="file-text"></span>
Test Stats
</a>
</li>
<li class="nav-item">
<a class="nav-link scroll_link " href="{% url 'home' %}"><i class="fas fa-home sb-icon" ></i>Home<span class="sr-only">(current)</span></a>
</li>
Expand Down
Loading