From 009a7305945b192c47d29b0ff4317cb72f3cccb6 Mon Sep 17 00:00:00 2001 From: ankitamk14 Date: Fri, 4 Nov 2022 13:10:28 +0530 Subject: [PATCH 01/12] migration files fixes --- csc/migrations/0017_auto_20221006_1045.py | 39 ------------------- ...103_1017.py => 0017_auto_20221104_1204.py} | 34 +++++++++++++--- csc/migrations/0018_invigilator_vle.py | 20 ++++++++++ csc/migrations/0018_test_invigilator.py | 18 --------- csc/migrations/0019_auto_20221006_1214.py | 18 --------- csc/migrations/0020_auto_20221006_1632.py | 19 --------- 6 files changed, 49 insertions(+), 99 deletions(-) delete mode 100644 csc/migrations/0017_auto_20221006_1045.py rename csc/migrations/{0021_auto_20221103_1017.py => 0017_auto_20221104_1204.py} (80%) create mode 100644 csc/migrations/0018_invigilator_vle.py delete mode 100644 csc/migrations/0018_test_invigilator.py delete mode 100644 csc/migrations/0019_auto_20221006_1214.py delete mode 100644 csc/migrations/0020_auto_20221006_1632.py diff --git a/csc/migrations/0017_auto_20221006_1045.py b/csc/migrations/0017_auto_20221006_1045.py deleted file mode 100644 index 962c17a..0000000 --- a/csc/migrations/0017_auto_20221006_1045.py +++ /dev/null @@ -1,39 +0,0 @@ -# Generated by Django 3.0.3 on 2022-10-06 05:15 - -import datetime -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('csc', '0016_auto_20220930_1304'), - ] - - operations = [ - migrations.RemoveField( - model_name='test', - name='test_name', - ), - migrations.AddField( - model_name='test', - name='participant_count', - field=models.IntegerField(default=10), - preserve_default=False, - ), - migrations.AddField( - model_name='test', - name='status', - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name='student', - name='date_of_registration', - field=models.DateField(default=datetime.date(2022, 10, 6)), - ), - migrations.AlterField( - model_name='test', - name='publish', - field=models.BooleanField(default=True), - ), - ] diff --git a/csc/migrations/0021_auto_20221103_1017.py b/csc/migrations/0017_auto_20221104_1204.py similarity index 80% rename from csc/migrations/0021_auto_20221103_1017.py rename to csc/migrations/0017_auto_20221104_1204.py index 340ef94..07f1ca7 100644 --- a/csc/migrations/0021_auto_20221103_1017.py +++ b/csc/migrations/0017_auto_20221104_1204.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.3 on 2022-11-03 04:47 +# Generated by Django 3.0.3 on 2022-11-04 06:34 import datetime from django.conf import settings @@ -10,10 +10,14 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('csc', '0020_auto_20221006_1632'), + ('csc', '0016_auto_20220930_1304'), ] operations = [ + migrations.RemoveField( + model_name='test', + name='test_name', + ), migrations.AddField( model_name='invigilator', name='password_mail_sent', @@ -24,6 +28,21 @@ class Migration(migrations.Migration): name='mdl_mail_sent', field=models.BooleanField(default=False), ), + migrations.AddField( + model_name='test', + name='invigilator', + field=models.ManyToManyField(blank=True, null=True, to='csc.Invigilator'), + ), + migrations.AddField( + model_name='test', + name='participant_count', + field=models.IntegerField(blank=True, null=True), + ), + migrations.AddField( + model_name='test', + name='status', + field=models.PositiveIntegerField(default=0), + ), migrations.AlterField( model_name='invigilator', name='phone', @@ -43,12 +62,17 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='student', name='date_of_registration', - field=models.DateField(default=datetime.date(2022, 11, 3)), + field=models.DateField(default=datetime.date(2022, 11, 4)), ), migrations.AlterField( model_name='test', - name='status', - field=models.PositiveIntegerField(default=0), + name='publish', + field=models.BooleanField(default=True), + ), + migrations.AlterField( + model_name='test', + name='vle', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='csc.VLE'), ), migrations.AlterUniqueTogether( name='invigilator', diff --git a/csc/migrations/0018_invigilator_vle.py b/csc/migrations/0018_invigilator_vle.py new file mode 100644 index 0000000..083e65a --- /dev/null +++ b/csc/migrations/0018_invigilator_vle.py @@ -0,0 +1,20 @@ +# Generated by Django 3.0.3 on 2022-11-04 06:34 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('csc', '0017_auto_20221104_1204'), + ] + + operations = [ + migrations.AddField( + model_name='invigilator', + name='vle', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='invig', to='csc.VLE'), + preserve_default=False, + ), + ] diff --git a/csc/migrations/0018_test_invigilator.py b/csc/migrations/0018_test_invigilator.py deleted file mode 100644 index 1cec19d..0000000 --- a/csc/migrations/0018_test_invigilator.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.0.3 on 2022-10-06 06:10 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('csc', '0017_auto_20221006_1045'), - ] - - operations = [ - migrations.AddField( - model_name='test', - name='invigilator', - field=models.ManyToManyField(blank=True, null=True, to='csc.Invigilator'), - ), - ] diff --git a/csc/migrations/0019_auto_20221006_1214.py b/csc/migrations/0019_auto_20221006_1214.py deleted file mode 100644 index d41d9d7..0000000 --- a/csc/migrations/0019_auto_20221006_1214.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.0.3 on 2022-10-06 06:44 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('csc', '0018_test_invigilator'), - ] - - operations = [ - migrations.AlterField( - model_name='test', - name='participant_count', - field=models.IntegerField(blank=True, null=True), - ), - ] diff --git a/csc/migrations/0020_auto_20221006_1632.py b/csc/migrations/0020_auto_20221006_1632.py deleted file mode 100644 index e003884..0000000 --- a/csc/migrations/0020_auto_20221006_1632.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.3 on 2022-10-06 11:02 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('csc', '0019_auto_20221006_1214'), - ] - - operations = [ - migrations.AlterField( - model_name='test', - name='vle', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='csc.VLE'), - ), - ] From 48a3dd9a898b33f80cf03ad844af1efd9c58f33b Mon Sep 17 00:00:00 2001 From: ankitamk14 Date: Fri, 4 Nov 2022 13:55:50 +0530 Subject: [PATCH 02/12] vle related model changes in invigilator --- csc/migrations/0017_auto_20221104_1204.py | 14 -------------- csc/migrations/0018_invigilator_vle.py | 20 -------------------- 2 files changed, 34 deletions(-) delete mode 100644 csc/migrations/0018_invigilator_vle.py diff --git a/csc/migrations/0017_auto_20221104_1204.py b/csc/migrations/0017_auto_20221104_1204.py index 07f1ca7..06bd6fd 100644 --- a/csc/migrations/0017_auto_20221104_1204.py +++ b/csc/migrations/0017_auto_20221104_1204.py @@ -53,12 +53,6 @@ class Migration(migrations.Migration): name='user', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invi', to=settings.AUTH_USER_MODEL), ), - migrations.AddField( - model_name='invigilator', - name='vle', - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='invig', to='csc.VLE'), - preserve_default=False, - ), migrations.AlterField( model_name='student', name='date_of_registration', @@ -74,10 +68,6 @@ class Migration(migrations.Migration): name='vle', field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='csc.VLE'), ), - migrations.AlterUniqueTogether( - name='invigilator', - unique_together={('user', 'vle')}, - ), migrations.CreateModel( name='CSCFossMdlCourses', fields=[ @@ -92,10 +82,6 @@ class Migration(migrations.Migration): model_name='invigilator', name='added_by', ), - migrations.RemoveField( - model_name='invigilator', - name='vle', - ), migrations.CreateModel( name='CSCTestAtttendance', fields=[ diff --git a/csc/migrations/0018_invigilator_vle.py b/csc/migrations/0018_invigilator_vle.py deleted file mode 100644 index 083e65a..0000000 --- a/csc/migrations/0018_invigilator_vle.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 3.0.3 on 2022-11-04 06:34 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('csc', '0017_auto_20221104_1204'), - ] - - operations = [ - migrations.AddField( - model_name='invigilator', - name='vle', - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='invig', to='csc.VLE'), - preserve_default=False, - ), - ] From 33e3e06bd432f00aea6593a55ccfe2705572abba Mon Sep 17 00:00:00 2001 From: ankitamk14 Date: Fri, 4 Nov 2022 16:14:45 +0530 Subject: [PATCH 03/12] vle changes from fk to many-to-many --- csc/models.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/csc/models.py b/csc/models.py index 47cb114..e145b21 100644 --- a/csc/models.py +++ b/csc/models.py @@ -200,9 +200,8 @@ def __str__(self): class Invigilator(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE,related_name='invi') phone = models.CharField(max_length=32,null=True,blank=True) - # vle = models.ManyToManyField(VLE) - # vle = models.ForeignKey(User,on_delete=models.CASCADE,related_name='invig') - vle = models.ForeignKey(VLE,on_delete=models.CASCADE,related_name='invig') + vle = models.ManyToManyField(VLE) + # vle = models.ForeignKey(VLE,on_delete=models.CASCADE,related_name='invig') # added_by = models.ForeignKey(User,on_delete=models.CASCADE,related_name='added_by_user') created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) @@ -210,9 +209,6 @@ class Invigilator(models.Model): def __str__(self): return f"{self.user.first_name} {self.user.last_name} - {self.user.email}" - - class Meta: - unique_together = [['user', 'vle']] class Test(models.Model): foss = models.ForeignKey(FossCategory,on_delete=models.CASCADE) From 7344e0481e44568892a9c7a6b32b5b59a90b4669 Mon Sep 17 00:00:00 2001 From: ankitamk14 Date: Fri, 4 Nov 2022 17:13:24 +0530 Subject: [PATCH 04/12] vle invi changes --- csc/vle_views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/csc/vle_views.py b/csc/vle_views.py index 682e4dd..f0f7cd3 100644 --- a/csc/vle_views.py +++ b/csc/vle_views.py @@ -782,7 +782,10 @@ def create_invigilator(request): user = User.objects.filter(email=email)[0] messages.add_message(request,messages.SUCCESS,f'User with this email {email} already exists & assigned to you as an Invigilator.') try: - Invigilator.objects.create(user=user,vle=vle,phone=phone) + # Invigilator.objects.create(user=user,vle=vle,phone=phone) + i=Invigilator.objects.create(user=user,phone=phone) + print(f"invi ************************************ {i}") + i.vle.add(vle) invi_group = Group.objects.get(name='INVIGILATOR') invi_group.user_set.add(user) if send_mail: From 68b56a0315dd3eed44d11e536fff2195bc721399 Mon Sep 17 00:00:00 2001 From: ankitamk14 Date: Fri, 4 Nov 2022 17:46:58 +0530 Subject: [PATCH 05/12] added static files --- static/spoken/utility.css | 16 ++++++++++++++++ static/spoken/utility.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 static/spoken/utility.css create mode 100644 static/spoken/utility.js diff --git a/static/spoken/utility.css b/static/spoken/utility.css new file mode 100644 index 0000000..75c46c2 --- /dev/null +++ b/static/spoken/utility.css @@ -0,0 +1,16 @@ +.form-group{ + margin-bottom: 12px; + margin-top: 12px; +} +label{ + font-weight: bold; +} +.fa-check-circle{ + color: green; +} +.fa-times-circle,.fa-trash-alt{ + color: maroon; +} +.fa-edit{ + color: midnightblue; +} \ No newline at end of file diff --git a/static/spoken/utility.js b/static/spoken/utility.js new file mode 100644 index 0000000..1a9eed7 --- /dev/null +++ b/static/spoken/utility.js @@ -0,0 +1,16 @@ + + $( ".student_check" ).click(function() { + alert( "Handler for .click() called." ); + }); + + + function myFunc(){ + alert('he') + onchange="this.form.submit()" + + } + + $('#select_test').on('change', function(){ + // alert('c'); + $(this).closest('form').submit(); +}); \ No newline at end of file From 782f93fcd195e90bb4ee81a46289498677d45ea0 Mon Sep 17 00:00:00 2001 From: Shivam Date: Wed, 9 Nov 2022 14:29:40 +0530 Subject: [PATCH 06/12] added test stats --- csc/stats/urls.py | 4 ++-- csc/stats/views.py | 7 ++++++- csc/templates/stats/stats.html | 12 ++++++++++++ csc/templates/stats/stats_base.html | 6 ++++++ csc/templates/stats/test_report.html | 25 +++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 csc/templates/stats/test_report.html 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..fc6a369 100644 --- a/csc/stats/views.py +++ b/csc/stats/views.py @@ -233,4 +233,9 @@ 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): + return render(request, 'stats/test_report.html') \ No newline at end of file diff --git a/csc/templates/stats/stats.html b/csc/templates/stats/stats.html index 80db1cb..8750558 100644 --- a/csc/templates/stats/stats.html +++ b/csc/templates/stats/stats.html @@ -71,6 +71,18 @@

{{total_certificate_course}}

+
+
+

Total Upcoming Tests

+

{{total_certificate_course}}

+
+
+
+
+

Total Tests Conducted

+

{{total_certificate_course}}

+
+
diff --git a/csc/templates/stats/stats_base.html b/csc/templates/stats/stats_base.html index 357ccb4..67dc03c 100644 --- a/csc/templates/stats/stats_base.html +++ b/csc/templates/stats/stats_base.html @@ -132,6 +132,12 @@

Test Stats

+{% endblock content %} \ No newline at end of file From 66010b8c75df45f27bdd607e3fef47e49be09cd2 Mon Sep 17 00:00:00 2001 From: Shivam Date: Wed, 9 Nov 2022 16:53:11 +0530 Subject: [PATCH 07/12] fix forget password --- csc/api/utility.py | 26 +++++++++++++++- .../csc/invigilator_mail_template.html | 31 +++++++++++++++++++ .../templates/registration/change.html | 2 +- .../templates/registration/password.html | 2 +- .../templates/spokenlogin/messages.html | 2 +- spokenlogin/views.py | 19 ++++++++---- 6 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 csc/templates/csc/invigilator_mail_template.html diff --git a/csc/api/utility.py b/csc/api/utility.py index ef36bce..a01abeb 100644 --- a/csc/api/utility.py +++ b/csc/api/utility.py @@ -10,7 +10,7 @@ import random, string from csc.models import Student_certificate_course,CategoryCourses,Student_Foss 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,6 +61,30 @@ def send_pwd_mail(u): Spoken Tutorial """ path = 'vle_mail_template.html' + if is_user_invigilator(u): + 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 {u.get_full_name()}, {u.username}. + + 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(),'username':u.username,'password':pwd}) try: print(f"/n/nSending mail ; username,pwd : {u.username},{pwd}".ljust(40,'*')) diff --git a/csc/templates/csc/invigilator_mail_template.html b/csc/templates/csc/invigilator_mail_template.html new file mode 100644 index 0000000..0662dd1 --- /dev/null +++ b/csc/templates/csc/invigilator_mail_template.html @@ -0,0 +1,31 @@ + + + + + Order received + + + +

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 {{full_name}}, {{username}}.

+ +

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/spokenlogin/templates/registration/change.html b/spokenlogin/templates/registration/change.html index 1ed27a2..3ebf369 100644 --- a/spokenlogin/templates/registration/change.html +++ b/spokenlogin/templates/registration/change.html @@ -1,7 +1,7 @@ {% extends 'spoken/base.html' %} {% load crispy_forms_tags %} {% block content %} -
+
{% include 'spokenlogin/messages.html' %}

Change Password

diff --git a/spokenlogin/templates/registration/password.html b/spokenlogin/templates/registration/password.html index a59d379..f4c7bbe 100644 --- a/spokenlogin/templates/registration/password.html +++ b/spokenlogin/templates/registration/password.html @@ -1,7 +1,7 @@ {% extends 'spoken/base.html' %} {% load crispy_forms_tags %} {% block content %} -
+
{% include 'spokenlogin/messages.html' %}

Forget Password

diff --git a/spokenlogin/templates/spokenlogin/messages.html b/spokenlogin/templates/spokenlogin/messages.html index 551d132..0388598 100644 --- a/spokenlogin/templates/spokenlogin/messages.html +++ b/spokenlogin/templates/spokenlogin/messages.html @@ -1,7 +1,7 @@
{% if messages %} {% for message in messages %} -
+
{{ message|safe }}
{% endfor %} diff --git a/spokenlogin/views.py b/spokenlogin/views.py index 2600b2e..6508e82 100644 --- a/spokenlogin/views.py +++ b/spokenlogin/views.py @@ -1,5 +1,6 @@ from django.shortcuts import render, redirect from django.contrib.auth.models import User +from django.contrib.auth.decorators import login_required from csc.api.utility import send_pwd_mail from django.contrib import messages @@ -11,20 +12,26 @@ def password(request): user = User.objects.get(username=email) send_pwd_mail(user) messages.add_message(request, messages.SUCCESS, 'Password Mail Sent Successfully.') - return redirect('/') + return redirect('/accounts/login') except User.DoesNotExist: - messages.add_message(request, messages.WARNING, 'User DoesNotExist.') - return redirect('/') + messages.add_message(request, messages.ERROR, 'User Does Not Exist.') + return redirect('/accounts/login') return render(request, 'registration/password.html') +@login_required(login_url='/accounts/login') def change(request): if request.method == 'POST': user = User.objects.get(username=request.user.username) new = request.POST['new'] confirm = request.POST['confirm'] - if new == confirm: + if new != confirm: + messages.add_message(request, messages.ERROR, 'Password did not match.') + elif len(new) < 8: + messages.add_message(request, messages.ERROR, 'Password should be 8 characters long.') + elif not str(new).isalnum(): + messages.add_message(request, messages.ERROR, 'Password should contain only numbers and letters.') + else: user.set_password(new) user.save() - messages.add_message(request, messages.SUCCESS, 'Password Changed Successfully') - return redirect('/') + messages.add_message(request, messages.SUCCESS, 'Password Changed Successfully') return render(request, 'registration/change.html') From 66d854bc0ca53f104fa273969688ce9152f41c83 Mon Sep 17 00:00:00 2001 From: Shivam Date: Wed, 9 Nov 2022 19:33:13 +0530 Subject: [PATCH 08/12] fix forgot password invigilator --- csc/api/utility.py | 10 ++++++---- csc/stats/views.py | 4 +++- csc/templates/csc/invigilator_mail_template.html | 2 +- csc/templates/stats/stats.html | 8 ++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/csc/api/utility.py b/csc/api/utility.py index a01abeb..678cae5 100644 --- a/csc/api/utility.py +++ b/csc/api/utility.py @@ -8,7 +8,7 @@ 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, is_user_invigilator from django.template.loader import render_to_string @@ -62,14 +62,16 @@ def send_pwd_mail(u): """ path = 'vle_mail_template.html' 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 {u.get_full_name()}, {u.username}. - + 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} @@ -85,7 +87,7 @@ def send_pwd_mail(u): Spoken Tutorial """ path = 'invigilator_mail_template.html' - html_content = render_to_string(path, {'full_name':u.get_full_name(),'username':u.username,'password':pwd}) + 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/views.py b/csc/stats/views.py index fc6a369..90b5b8d 100644 --- a/csc/stats/views.py +++ b/csc/stats/views.py @@ -7,7 +7,7 @@ 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 @@ -27,6 +27,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(status=1).count() + context['total_upcoming_tests'] = Test.objects.filter(status=0).count() student_gender = get_student_gender_stats() context['student_gender'] = student_gender diff --git a/csc/templates/csc/invigilator_mail_template.html b/csc/templates/csc/invigilator_mail_template.html index 0662dd1..dcf5d64 100644 --- a/csc/templates/csc/invigilator_mail_template.html +++ b/csc/templates/csc/invigilator_mail_template.html @@ -10,7 +10,7 @@

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 {{full_name}}, {{username}}.

+

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/

diff --git a/csc/templates/stats/stats.html b/csc/templates/stats/stats.html index 8750558..754c351 100644 --- a/csc/templates/stats/stats.html +++ b/csc/templates/stats/stats.html @@ -73,14 +73,14 @@
-

Total Upcoming Tests

-

{{total_certificate_course}}

+

Total Tests Conducted

+

{{total_test_conducted}}

-

Total Tests Conducted

-

{{total_certificate_course}}

+

Total Upcoming Tests

+

{{total_upcoming_tests}}

From dcec466e54a55cca15f92945d4a98b8fa11b2152 Mon Sep 17 00:00:00 2001 From: Shivam Date: Fri, 11 Nov 2022 15:34:45 +0530 Subject: [PATCH 09/12] total tests in vle data --- csc/stats/views.py | 16 ++++++-- csc/templates/stats/test_report.html | 55 +++++++++++++++++++++++++++- csc/templates/stats/vle_stats.html | 14 +++++++ 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/csc/stats/views.py b/csc/stats/views.py index 90b5b8d..8bb1f2d 100644 --- a/csc/stats/views.py +++ b/csc/stats/views.py @@ -13,6 +13,8 @@ from csc.utils import is_csc_team_role from .utility import * +from datetime import datetime + @login_required @dec_is_csc_team @@ -27,8 +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(status=1).count() - context['total_upcoming_tests'] = Test.objects.filter(status=0).count() + 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 @@ -155,7 +157,8 @@ 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')) + print(vars(qs[0])) 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)) @@ -200,6 +203,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) @@ -240,4 +245,7 @@ def vle_report(request): @login_required @dec_is_csc_team def test_report(request): - return render(request, 'stats/test_report.html') \ No newline at end of file + context = {} + all_foss = FossCategory.objects.annotate(Count('test')) + context['all_foss'] = all_foss + return render(request, 'stats/test_report.html', context) \ No newline at end of file diff --git a/csc/templates/stats/test_report.html b/csc/templates/stats/test_report.html index 61f7169..238aec5 100644 --- a/csc/templates/stats/test_report.html +++ b/csc/templates/stats/test_report.html @@ -21,5 +21,56 @@ {% endblock custom_style %} {% block content %} -

Test Stats

-{% endblock content %} \ No newline at end of file +
+
+ +
+
+
+
+ + + + + + + + + + + + + + {% for item in all_foss %} + + + + + + + + + + {% endfor %} + +
#FossUpcoming TestsConducted TestsTotal Students UpcomingTotal students AppearedTotal certificates
{{forloop.counter}}{{item}}{{item.test__count}}{{item.test__count}}{{item.}}{{item.}}{{item.}}
+
+
+
+
+{% endblock content %} +{% block js_script %} + + + +{% endblock js_script %} \ No newline at end of file diff --git a/csc/templates/stats/vle_stats.html b/csc/templates/stats/vle_stats.html index d5dc9e3..499a7b5 100644 --- a/csc/templates/stats/vle_stats.html +++ b/csc/templates/stats/vle_stats.html @@ -98,6 +98,7 @@
Search VLE
District Plan Date of Joining + Total Tests @@ -114,6 +115,7 @@
Search VLE
{{vle.csc.district}} {{vle.csc.plan}} {{vle.user.date_joined}} + {{vle.test__count}} {% endfor %} @@ -155,6 +157,16 @@
VLE De Total Students :

+
+

+ Conducted Tests : +

+
+
+

+ Upcoming Tests : +

+
@@ -244,6 +256,8 @@
VLE De document.getElementById("pr_district").innerHTML = data['district']; document.getElementById("pin").innerHTML = data['pin']; document.getElementById("total_students").innerHTML = data['total_students']; + document.getElementById("conducted_test").innerHTML = data['conducted_test']; + document.getElementById("upcoming_test").innerHTML = data['upcoming_test']; $("#tb_students tr").remove(); var tb_students = document.getElementById("tb_students"); From 9fe8ebd9f90e7c3e7cec021a83b0327a84b15cad Mon Sep 17 00:00:00 2001 From: Shivam Date: Fri, 11 Nov 2022 16:22:07 +0530 Subject: [PATCH 10/12] foss table in test stats --- csc/stats/views.py | 2 +- csc/templates/stats/test_report.html | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/csc/stats/views.py b/csc/stats/views.py index 8bb1f2d..70d58de 100644 --- a/csc/stats/views.py +++ b/csc/stats/views.py @@ -246,6 +246,6 @@ def vle_report(request): @dec_is_csc_team def test_report(request): context = {} - all_foss = FossCategory.objects.annotate(Count('test')) + 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())), upcoming_students=Count('student_foss', distinct=True), appeared_students=Count('student_foss', distinct=True), all_certificates=Count('categorycourses', distinct=True)) context['all_foss'] = all_foss return render(request, 'stats/test_report.html', context) \ No newline at end of file diff --git a/csc/templates/stats/test_report.html b/csc/templates/stats/test_report.html index 238aec5..1dee986 100644 --- a/csc/templates/stats/test_report.html +++ b/csc/templates/stats/test_report.html @@ -40,9 +40,9 @@ Foss Upcoming Tests Conducted Tests - Total Students Upcoming - Total students Appeared - Total certificates + Upcoming Students + Appeared Students + Certificates @@ -50,11 +50,11 @@ {{forloop.counter}} {{item}} - {{item.test__count}} - {{item.test__count}} - {{item.}} - {{item.}} - {{item.}} + {{item.upcoming_tests}} + {{item.conducted_tests}} + {{item.upcoming_students}} + {{item.appeared_students}} + {{item.all_certificates}} {% endfor %} From 9dc3146f64a629307d28a5d6c8a6ca386f493267 Mon Sep 17 00:00:00 2001 From: Shivam Date: Mon, 21 Nov 2022 15:12:40 +0530 Subject: [PATCH 11/12] foss table --- csc/stats/views.py | 17 ++++++++++++++--- csc/templates/stats/test_report.html | 17 +++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/csc/stats/views.py b/csc/stats/views.py index 70d58de..86ab972 100644 --- a/csc/stats/views.py +++ b/csc/stats/views.py @@ -158,7 +158,6 @@ def get_context_data(self, **kwargs): def get_queryset(self): qs = super().get_queryset() qs = qs_vle.annotate(Count('test')) - print(vars(qs[0])) 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)) @@ -246,6 +245,18 @@ def vle_report(request): @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())), upcoming_students=Count('student_foss', distinct=True), appeared_students=Count('student_foss', distinct=True), all_certificates=Count('categorycourses', distinct=True)) - context['all_foss'] = all_foss + 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/stats/test_report.html b/csc/templates/stats/test_report.html index 1dee986..9820fee 100644 --- a/csc/templates/stats/test_report.html +++ b/csc/templates/stats/test_report.html @@ -46,15 +46,15 @@ - {% for item in all_foss %} + {% for key, value in fosses.items %} {{forloop.counter}} - {{item}} - {{item.upcoming_tests}} - {{item.conducted_tests}} - {{item.upcoming_students}} - {{item.appeared_students}} - {{item.all_certificates}} + {{key}} + {{value.upcoming_tests}} + {{value.conducted_tests}} + {{value.upcoming_students}} + {{value.appeared_students}} + {{value.all_certificates}} {% endfor %} @@ -71,6 +71,7 @@ $(document).ready(function () { $('#foss_test').DataTable({ pageLength: 100 - }); + }) + }); {% endblock js_script %} \ No newline at end of file From c6f583872d926dc5907c0d6edfb002358927030c Mon Sep 17 00:00:00 2001 From: Shivam Date: Thu, 24 Nov 2022 12:20:26 +0530 Subject: [PATCH 12/12] fixed test list table --- csc/templates/csc/test_list.html | 22 +++------ csc/templates/csc/test_students.html | 74 ++++++++++++++++++++++++++++ csc/vle_urls.py | 1 + csc/vle_views.py | 8 ++- 4 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 csc/templates/csc/test_students.html diff --git a/csc/templates/csc/test_list.html b/csc/templates/csc/test_list.html index fa78ca1..afa4771 100644 --- a/csc/templates/csc/test_list.html +++ b/csc/templates/csc/test_list.html @@ -17,13 +17,14 @@ # - Title FOSS Date Time - Published Delete Edit + Students + Upcoming + Appeared @@ -31,25 +32,14 @@ {% for test in tests %} {{forloop.counter}} - - {% if test.test_name %} - {{test.test_name | title}} - {% else %} - {{test.foss | title}} Test - {% endif %} - {{test.foss | title }} {{test.tdate}} {{test.ttime}} - - {% if test.publish %} - - {% else %} - - {% endif %} - + + {{test.upcoming_students}} + {{test.appeared_students}} {% if test.tdate|is_today %} diff --git a/csc/templates/csc/test_students.html b/csc/templates/csc/test_students.html new file mode 100644 index 0000000..d02bc4e --- /dev/null +++ b/csc/templates/csc/test_students.html @@ -0,0 +1,74 @@ +{% extends 'csc_base.html'%} +{% load static %} +{% load csc_tags %} +{% block css %} + + + +{% endblock css %} +{% block content %} +
+
+
+ + + + + + + + + + + + + + + + + + {% for test in tests %} + + + + + + + + + + + {% if test.status == 0%} + + {% elif test.status == 1%} + + {% elif test.status == 2%} + + {% elif test.status == 3%} + + {% elif test.status == 4%} + + {% endif %} + + + {% endfor %} + +
#NameEmailGenderAgePhoneEdu QualificationOccupationCategoryStatusGrade
{{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}}OpenAttendance MarkedOngoingCompleted by StudentClosed by VLE{{test.mdlgrade}}
+
+
+
+
+
+{% endblock %} +{% block script %} + + + + +{% endblock %} \ No newline at end of file diff --git a/csc/vle_urls.py b/csc/vle_urls.py index 6a344f3..254f839 100644 --- a/csc/vle_urls.py +++ b/csc/vle_urls.py @@ -25,6 +25,7 @@ path('detail_test/', TestDetailView.as_view(), name="detail_test"), # path('update_test/', TestUpdateView.as_view(), name="update_test"), path('update_test/', update_test, name="update_test"), + path('test_students/', test_students, name="test_students"), path('delete_test/', TestDeleteView.as_view(), name="delete_test"), path('list_test/', TestListView.as_view(), name="list_test"), path('invigilator/', invigilator, name="invigilator"), diff --git a/csc/vle_views.py b/csc/vle_views.py index f0f7cd3..f7c2e21 100644 --- a/csc/vle_views.py +++ b/csc/vle_views.py @@ -652,10 +652,16 @@ def test_assign(request): def test_list(request): context = {} vle = VLE.objects.get(user=request.user) - tests = Test.objects.filter(vle=vle) + tests = Test.objects.filter(vle=vle).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))) context['tests'] = tests return render(request,'csc/test_list.html',context) +def test_students(request, pk): + context = {} + tests = CSCTestAtttendance.objects.filter(test=pk) + context['tests'] = tests + return render(request,'csc/test_students.html', context) + def update_test(request,pk): context = {} if request.method == 'GET':