diff --git a/csc/api/utility.py b/csc/api/utility.py index ef36bce..678cae5 100644 --- a/csc/api/utility.py +++ b/csc/api/utility.py @@ -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) @@ -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 animation-hackathon@cscacademy.org. + + 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( diff --git a/csc/stats/urls.py b/csc/stats/urls.py index e301bf9..0e2a113 100644 --- a/csc/stats/urls.py +++ b/csc/stats/urls.py @@ -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") ] \ No newline at end of file diff --git a/csc/stats/views.py b/csc/stats/views.py index d0035f7..86ab972 100644 --- a/csc/stats/views.py +++ b/csc/stats/views.py @@ -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 @@ -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 @@ -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)) @@ -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) @@ -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) \ No newline at end of file + 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) \ No newline at end of file diff --git a/csc/templates/csc/invigilator_mail_template.html b/csc/templates/csc/invigilator_mail_template.html new file mode 100644 index 0000000..dcf5d64 --- /dev/null +++ b/csc/templates/csc/invigilator_mail_template.html @@ -0,0 +1,31 @@ + + +
+ +Dear {{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 {{vle}}.
+ +Please use the below Login details for the Spoken Tutorial Dashboard:
+Link to Login: https://spoken-tutorial.in/login/
+ +username : {{username}}
+password : {{password}}
+ +Please click the following training link to know the process of
+Student Registration Instructions : Click Here
+Course Allotment Instructions : Click Here
+ +In case of any query, please feel free to contact at animation-hackathon@cscacademy.org.
+ +Thanks & Regards,
+Team,
+Spoken Tutorial
+ + \ No newline at end of file diff --git a/csc/templates/csc/test_list.html b/csc/templates/csc/test_list.html index 8edc759..afa4771 100644 --- a/csc/templates/csc/test_list.html +++ b/csc/templates/csc/test_list.html @@ -17,13 +17,14 @@| # | +Name | +Gender | +Age | +Phone | +Edu Qualification | +Occupation | +Category | +Status | +Grade | +|||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{forloop.counter}} | +{{test.student.user.first_name | title}} {{test.student.user.last_name | title}} | +{{test.student.user.email}} | +{{test.student.gender | title}} | +{{test.student.dob | timesince}} | +{{test.student.phone}} | +{{test.student.edu_qualification}} | +{{test.student.occupation}} | +{{test.student.category}} | + {% if test.status == 0%} +Open | + {% elif test.status == 1%} +Attendance Marked | + {% elif test.status == 2%} +Ongoing | + {% elif test.status == 3%} +Completed by Student | + {% elif test.status == 4%} +Closed by VLE | + {% endif %} +{{test.mdlgrade}} | +
{{total_certificate_course}}
+Total Tests Conducted
+{{total_test_conducted}}
+Total Upcoming Tests
+{{total_upcoming_tests}}
+| # | +Foss | +Upcoming Tests | +Conducted Tests | +Upcoming Students | +Appeared Students | +Certificates | +
|---|---|---|---|---|---|---|
| {{forloop.counter}} | +{{key}} | +{{value.upcoming_tests}} | +{{value.conducted_tests}} | +{{value.upcoming_students}} | +{{value.appeared_students}} | +{{value.all_certificates}} | +
+ Conducted Tests : +
++ Upcoming Tests : +
+