├── MTP
├── __init__.py
├── migrations
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── 0001_initial.cpython-36.pyc
│ │ ├── 0005_faculty_admin.cpython-36.pyc
│ │ ├── 0002_auto_20191023_0934.cpython-36.pyc
│ │ ├── 0003_auto_20191023_1010.cpython-36.pyc
│ │ ├── 0004_auto_20191023_1030.cpython-36.pyc
│ │ ├── 0006_auto_20191031_0943.cpython-36.pyc
│ │ ├── 0007_auto_20191031_0953.cpython-36.pyc
│ │ └── 0008_remove_test_created_by.cpython-36.pyc
│ ├── 0008_remove_test_created_by.py
│ ├── 0003_auto_20191023_1010.py
│ ├── 0005_faculty_admin.py
│ ├── 0006_auto_20191031_0943.py
│ ├── 0002_auto_20191023_0934.py
│ ├── 0007_auto_20191031_0953.py
│ ├── 0004_auto_20191023_1030.py
│ └── 0001_initial.py
├── admin.py
├── tests.py
├── apps.py
├── __pycache__
│ ├── admin.cpython-36.pyc
│ ├── urls.cpython-36.pyc
│ ├── views.cpython-36.pyc
│ ├── __init__.cpython-36.pyc
│ └── models.cpython-36.pyc
├── templates
│ ├── fdash.html
│ ├── sdash.html
│ ├── base.html
│ ├── s_login.html
│ ├── fac_login.html
│ ├── fcourse_list.html
│ ├── fsubject_list.html
│ ├── fstudent_list.html
│ ├── ftest_list.html
│ └── f_admin.html
├── urls.py
├── models.py
└── views.py
├── django_projects
├── __init__.py
├── __pycache__
│ ├── urls.cpython-36.pyc
│ ├── wsgi.cpython-36.pyc
│ ├── __init__.cpython-36.pyc
│ └── settings.cpython-36.pyc
├── urls.py
├── wsgi.py
└── settings.py
├── db.sqlite3
├── .gitattributes
├── MTP DB Schema.vsdx
├── .idea
├── inspectionProfiles
│ └── profiles_settings.xml
├── modules.xml
├── misc.xml
├── django_projects.iml
└── workspace.xml
├── README.md
└── manage.py
/MTP/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/MTP/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/django_projects/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/db.sqlite3
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/MTP/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/MTP/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/MTP DB Schema.vsdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP DB Schema.vsdx
--------------------------------------------------------------------------------
/MTP/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class MtpConfig(AppConfig):
5 | name = 'MTP'
6 |
--------------------------------------------------------------------------------
/MTP/__pycache__/admin.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/__pycache__/admin.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/__pycache__/urls.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/__pycache__/urls.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/__pycache__/views.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/__pycache__/views.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/__pycache__/models.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/__pycache__/models.cpython-36.pyc
--------------------------------------------------------------------------------
/django_projects/__pycache__/urls.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/django_projects/__pycache__/urls.cpython-36.pyc
--------------------------------------------------------------------------------
/django_projects/__pycache__/wsgi.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/django_projects/__pycache__/wsgi.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/templates/fdash.html:
--------------------------------------------------------------------------------
1 | {% extends "fac_dashbase.html" %}
2 | {% block title %}Dashboard{% endblock %}
3 | {% block page_content %}
4 |
5 | {% endblock %}
--------------------------------------------------------------------------------
/MTP/templates/sdash.html:
--------------------------------------------------------------------------------
1 | {% extends "dashbase.html" %}
2 | {% block title %}Dashboard{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 | {% endblock %}
--------------------------------------------------------------------------------
/django_projects/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/django_projects/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/django_projects/__pycache__/settings.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/django_projects/__pycache__/settings.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0001_initial.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0001_initial.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0005_faculty_admin.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0005_faculty_admin.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0002_auto_20191023_0934.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0002_auto_20191023_0934.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0003_auto_20191023_1010.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0003_auto_20191023_1010.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0004_auto_20191023_1030.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0004_auto_20191023_1030.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0006_auto_20191031_0943.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0006_auto_20191031_0943.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0007_auto_20191031_0953.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0007_auto_20191031_0953.cpython-36.pyc
--------------------------------------------------------------------------------
/MTP/migrations/__pycache__/0008_remove_test_created_by.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranajoy-dutta/MTP/master/MTP/migrations/__pycache__/0008_remove_test_created_by.cpython-36.pyc
--------------------------------------------------------------------------------
/django_projects/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import path, include
3 |
4 | urlpatterns = [
5 | path('admin/', admin.site.urls),
6 | path('', include('MTP.urls'))
7 | ]
8 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MTP
2 | An application to have mock test of aptitute exams of college recruitment process.
3 |
4 | ## Setup
5 | 1. Setup Django Environment. -> install Django (pip install django)
6 | 2. clone the repository.
7 | 3. you are ready to run the application using command line.
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/MTP/migrations/0008_remove_test_created_by.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-31 04:23
2 |
3 | from django.db import migrations
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('MTP', '0007_auto_20191031_0953'),
10 | ]
11 |
12 | operations = [
13 | migrations.RemoveField(
14 | model_name='test',
15 | name='created_by',
16 | ),
17 | ]
18 |
--------------------------------------------------------------------------------
/.idea/django_projects.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MTP/migrations/0003_auto_20191023_1010.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-23 04:40
2 |
3 | from django.db import migrations
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('MTP', '0002_auto_20191023_0934'),
10 | ]
11 |
12 | operations = [
13 | migrations.DeleteModel(
14 | name='dummyclass',
15 | ),
16 | migrations.DeleteModel(
17 | name='dummysss',
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/django_projects/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for django_projects project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_projects.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/MTP/migrations/0005_faculty_admin.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-24 07:51
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('MTP', '0004_auto_20191023_1030'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='faculty',
15 | name='admin',
16 | field=models.CharField(default=0, max_length=1),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/MTP/migrations/0006_auto_20191031_0943.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-31 04:13
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('MTP', '0005_faculty_admin'),
10 | ]
11 |
12 | operations = [
13 | migrations.AlterField(
14 | model_name='subject',
15 | name='co_name',
16 | field=models.CharField(default=0, max_length=100),
17 | preserve_default=False,
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/MTP/migrations/0002_auto_20191023_0934.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-23 04:04
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('MTP', '0001_initial'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='student',
15 | name='batch',
16 | field=models.CharField(max_length=4, null=True),
17 | ),
18 | migrations.AddField(
19 | model_name='student',
20 | name='section',
21 | field=models.CharField(max_length=4, null=True),
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_projects.settings')
9 | try:
10 | from django.core.management import execute_from_command_line
11 | except ImportError as exc:
12 | raise ImportError(
13 | "Couldn't import Django. Are you sure it's installed and "
14 | "available on your PYTHONPATH environment variable? Did you "
15 | "forget to activate a virtual environment?"
16 | ) from exc
17 | execute_from_command_line(sys.argv)
18 |
19 |
20 | if __name__ == '__main__':
21 | main()
22 |
--------------------------------------------------------------------------------
/MTP/migrations/0007_auto_20191031_0953.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-31 04:23
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('MTP', '0006_auto_20191031_0943'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='test',
15 | name='co_name',
16 | field=models.CharField(default=0, max_length=100),
17 | preserve_default=False,
18 | ),
19 | migrations.AddField(
20 | model_name='test',
21 | name='sub_name',
22 | field=models.CharField(default=0, max_length=100),
23 | preserve_default=False,
24 | ),
25 | migrations.AlterField(
26 | model_name='test',
27 | name='test_name',
28 | field=models.CharField(max_length=100),
29 | ),
30 | ]
31 |
--------------------------------------------------------------------------------
/MTP/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from MTP import views
3 |
4 | urlpatterns = [
5 | path('', views.index, name='index'),
6 | path('sLogin', views.sLogin, name='Login'),
7 | path('Dashboard', views.sDash, name='Dashboard'),
8 | path('fac_dash', views.fac_dash, name='Fac_Dash'),
9 | path("logout", views.logout_request, name="logout"),
10 | path("faculty", views.faculty_login, name="Faculty"),
11 | path("student_list", views.student_list, name="student_list"),
12 | path("create_student", views.create_student, name="create_student"),
13 | path("delete_student", views.delete_student, name="delete_student"),
14 | path("f_admin", views.f_admin, name="f_admin"),
15 | path("create_faculty", views.create_faculty, name="create_faculty"),
16 | path("create_course", views.create_course, name="create_course"),
17 | path("course_list", views.course_list, name="course_list"),
18 | path("subject_list", views.subject_list, name="subject_list"),
19 | path("create_subject", views.create_subject, name="create_subject"),
20 | path("test_list", views.test_list, name="test_list"),
21 | path("create_test", views.create_test, name="create_test"),
22 | ]
--------------------------------------------------------------------------------
/MTP/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% load static %}
5 |
6 |
7 | {% block title %}Django Auth Tutorial{% endblock %}
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 | {% block page_content %}
20 |
21 | {% endblock %}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/MTP/migrations/0004_auto_20191023_1030.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-23 05:00
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('MTP', '0003_auto_20191023_1010'),
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Question',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('title', models.CharField(max_length=100, null=True)),
19 | ('description', models.CharField(max_length=10000)),
20 | ('tid_list', models.CharField(max_length=20000, null=True)),
21 | ('option1', models.CharField(max_length=1000, null=True)),
22 | ('option2', models.CharField(max_length=1000, null=True)),
23 | ('option3', models.CharField(max_length=1000, null=True)),
24 | ('option4', models.CharField(max_length=1000, null=True)),
25 | ('option5', models.CharField(max_length=1000, null=True)),
26 | ('correct', models.CharField(max_length=1, null=True)),
27 | ],
28 | ),
29 | migrations.AlterField(
30 | model_name='faculty',
31 | name='lname',
32 | field=models.CharField(max_length=40, null=True),
33 | ),
34 | migrations.AlterField(
35 | model_name='student',
36 | name='lname',
37 | field=models.CharField(max_length=40, null=True),
38 | ),
39 | migrations.AlterField(
40 | model_name='subject',
41 | name='co_name',
42 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='MTP.Course'),
43 | ),
44 | migrations.CreateModel(
45 | name='Test',
46 | fields=[
47 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
48 | ('test_name', models.CharField(max_length=40)),
49 | ('qid_list', models.CharField(max_length=20000, null=True)),
50 | ('created_on', models.DateTimeField(auto_now_add=True)),
51 | ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='MTP.Faculty')),
52 | ],
53 | ),
54 | ]
55 |
--------------------------------------------------------------------------------
/MTP/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 |
4 | class Student(models.Model):
5 | fname = models.CharField(max_length=40)
6 | lname = models.CharField(max_length=40, null=True)
7 | email = models.EmailField(unique=True)
8 | password = models.CharField(max_length=100)
9 | batch = models.CharField(max_length=4, null=True)
10 | section = models.CharField(max_length=4, null=True)
11 | image = models.FilePathField(path="/img")
12 |
13 | def __str__(self):
14 | lv_studentdata = "id: {}, Name: {} {}, email: {}, image: {}".format(self.id, self.fname, self.lname, self.email, self.image)
15 | return lv_studentdata
16 |
17 |
18 | class Faculty(models.Model):
19 | fname = models.CharField(max_length=40)
20 | lname = models.CharField(max_length=40, null=True)
21 | email = models.EmailField(unique=True)
22 | password = models.CharField(max_length=100)
23 | admin = models.CharField(max_length=1, default=0)
24 | image = models.FilePathField(path="/img")
25 |
26 | def __str__(self):
27 | lv_facdata = "id: {}, Name: {} {}, email: {}, admin: {}, image: {}".format(self.id, self.fname, self.lname, self.email, self.admin, self.image)
28 | return lv_facdata
29 |
30 |
31 | class Course(models.Model):
32 | co_name = models.CharField(max_length=100, null=False)
33 |
34 |
35 | class Subject(models.Model):
36 | sub_name = models.CharField(max_length=100, null=False)
37 | co_name = models.CharField(max_length=100, null=False)
38 |
39 | def __str__(self):
40 | lv_subData = "id: {}, Name: {}, Course: {}".format(self.id, self.sub_name, self.co_name)
41 | return lv_subData
42 |
43 |
44 | class Test(models.Model):
45 | test_name = models.CharField(max_length=100, null=False)
46 | sub_name = models.CharField(max_length=100, null=False)
47 | co_name = models.CharField(max_length=100, null=False)
48 | qid_list = models.CharField(max_length=20000, null=True)
49 | created_on = models.DateTimeField(auto_now_add=True, editable=False, blank=False, null=False)
50 |
51 |
52 | class Question(models.Model):
53 | title = models.CharField(max_length=100, null=True)
54 | description = models.CharField(max_length=10000, null=False)
55 | tid_list = models.CharField(max_length=20000, null=True)
56 | option1 = models.CharField(max_length=1000, null=True)
57 | option2 = models.CharField(max_length=1000, null=True)
58 | option3 = models.CharField(max_length=1000, null=True)
59 | option4 = models.CharField(max_length=1000, null=True)
60 | option5 = models.CharField(max_length=1000, null=True)
61 | correct = models.CharField(max_length=1, null=True)
62 |
--------------------------------------------------------------------------------
/MTP/templates/s_login.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block title %}Login{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
7 |
52 |
53 |
54 |
55 | {% endblock %}
--------------------------------------------------------------------------------
/MTP/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.2.6 on 2019-10-22 04:51
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | initial = True
10 |
11 | dependencies = [
12 | ]
13 |
14 | operations = [
15 | migrations.CreateModel(
16 | name='Course',
17 | fields=[
18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 | ('co_name', models.CharField(max_length=100)),
20 | ],
21 | ),
22 | migrations.CreateModel(
23 | name='dummyclass',
24 | fields=[
25 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
26 | ('name', models.CharField(max_length=40)),
27 | ],
28 | ),
29 | migrations.CreateModel(
30 | name='dummysss',
31 | fields=[
32 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
33 | ('name', models.CharField(max_length=40)),
34 | ],
35 | ),
36 | migrations.CreateModel(
37 | name='Faculty',
38 | fields=[
39 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
40 | ('fname', models.CharField(max_length=40)),
41 | ('lname', models.CharField(blank=True, max_length=40)),
42 | ('email', models.EmailField(max_length=254, unique=True)),
43 | ('password', models.CharField(max_length=100)),
44 | ('image', models.FilePathField(path='/img')),
45 | ],
46 | ),
47 | migrations.CreateModel(
48 | name='Student',
49 | fields=[
50 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
51 | ('fname', models.CharField(max_length=40)),
52 | ('lname', models.CharField(blank=True, max_length=40)),
53 | ('email', models.EmailField(max_length=254, unique=True)),
54 | ('password', models.CharField(max_length=100)),
55 | ('image', models.FilePathField(path='/img')),
56 | ],
57 | ),
58 | migrations.CreateModel(
59 | name='Subject',
60 | fields=[
61 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
62 | ('sub_name', models.CharField(max_length=100)),
63 | ('co_name', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='MTP.Course')),
64 | ],
65 | ),
66 | ]
67 |
--------------------------------------------------------------------------------
/MTP/templates/fac_login.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block title %}Login{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {% if message %}
13 |
{{ message }}
14 | {% endif %}
15 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {% endblock %}
--------------------------------------------------------------------------------
/MTP/templates/fcourse_list.html:
--------------------------------------------------------------------------------
1 | {% extends "fac_dashbase.html" %}
2 | {% block title %}Courses{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
33 |
34 |
35 | {% if message_code == 1 %}
36 |
37 |
38 | Data Successfully Stored
39 |
42 |
43 |
44 |
45 | {% elif message_code == 2 %}
46 |
47 |
48 | Last Transaction Failed
49 |
52 |
53 |
54 | {% elif message_code == 3 %}
55 |
56 |
57 | Last Transaction Failed! Email already exists.
58 |
61 |
62 |
63 | {% endif %}
64 |
65 | {% if course_list.count > 0 %}
66 |
67 |
68 |
69 |
70 | | Course Name |
71 |
72 |
73 |
74 | {% for course in course_list %}
75 |
76 | | {{ course.co_name }} |
77 |
78 | {% endfor %}
79 |
80 |
81 |
82 | {% endif %}
83 | {% endblock %}
84 |
--------------------------------------------------------------------------------
/django_projects/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for django_projects project.
3 |
4 | Generated by 'django-admin startproject' using Django 2.2.6.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.2/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/2.2/ref/settings/
11 | """
12 |
13 | import os
14 |
15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 'hldq+*up8#$72f-!z469_thd@*#9l5u5evt@6tdxv*8p5cl#r8'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'django.contrib.admin',
35 | 'django.contrib.auth',
36 | 'django.contrib.contenttypes',
37 | 'django.contrib.sessions',
38 | 'django.contrib.messages',
39 | 'django.contrib.staticfiles',
40 | 'MTP',
41 | 'django_tables2',
42 | 'bootstrap',
43 | 'fontawesome',
44 | ]
45 |
46 | MIDDLEWARE = [
47 | 'django.middleware.security.SecurityMiddleware',
48 | 'django.contrib.sessions.middleware.SessionMiddleware',
49 | 'django.middleware.common.CommonMiddleware',
50 | 'django.middleware.csrf.CsrfViewMiddleware',
51 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
52 | 'django.contrib.messages.middleware.MessageMiddleware',
53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
54 | ]
55 |
56 | ROOT_URLCONF = 'django_projects.urls'
57 |
58 | TEMPLATES = [
59 | {
60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
61 | 'DIRS': ["MTP/templates"],
62 | 'APP_DIRS': True,
63 | 'OPTIONS': {
64 | 'context_processors': [
65 | 'django.template.context_processors.debug',
66 | 'django.template.context_processors.request',
67 | 'django.contrib.auth.context_processors.auth',
68 | 'django.contrib.messages.context_processors.messages',
69 | ],
70 | },
71 | },
72 | ]
73 |
74 | WSGI_APPLICATION = 'django_projects.wsgi.application'
75 |
76 |
77 | # Database
78 | # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
79 |
80 | DATABASES = {
81 | 'default': {
82 | 'ENGINE': 'django.db.backends.sqlite3',
83 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
84 | }
85 | }
86 |
87 |
88 | # Password validation
89 | # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
90 |
91 | AUTH_PASSWORD_VALIDATORS = [
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
100 | },
101 | {
102 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
103 | },
104 | ]
105 |
106 |
107 | # Internationalization
108 | # https://docs.djangoproject.com/en/2.2/topics/i18n/
109 |
110 | LANGUAGE_CODE = 'en-us'
111 |
112 | TIME_ZONE = 'UTC'
113 |
114 | USE_I18N = True
115 |
116 | USE_L10N = True
117 |
118 | USE_TZ = True
119 |
120 |
121 | # Static files (CSS, JavaScript, Images)
122 | # https://docs.djangoproject.com/en/2.2/howto/static-files/
123 |
124 | STATIC_URL = '/static/'
125 |
--------------------------------------------------------------------------------
/MTP/templates/fsubject_list.html:
--------------------------------------------------------------------------------
1 | {% extends "fac_dashbase.html" %}
2 | {% block title %}Subject List{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
43 |
44 |
45 | {% if message_code == 1 %}
46 |
47 |
48 | Transaction Successful
49 |
52 |
53 |
54 |
55 | {% elif message_code == 2 %}
56 |
57 |
58 | Last Transaction Failed
59 |
62 |
63 |
64 | {% elif message_code == 3 %}
65 |
66 |
67 | Last Transaction Failed! Email already exists.
68 |
71 |
72 |
73 | {% endif %}
74 |
75 | {% if subject_list.count > 0 %}
76 |
77 |
78 |
79 |
80 | | Subject Name |
81 | Course Name |
82 |
83 |
84 |
85 | {% for subject in subject_list %}
86 |
87 | | {{ subject.sub_name }} |
88 | {{ subject.co_name }}
89 |
92 | |
93 |
94 |
95 |
96 |
97 | {% endfor %}
98 |
99 |
100 |
101 | {% endif %}
102 | {% endblock %}
103 |
--------------------------------------------------------------------------------
/MTP/templates/fstudent_list.html:
--------------------------------------------------------------------------------
1 | {% extends "fac_dashbase.html" %}
2 | {% block title %}Dashboard{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
45 |
46 |
47 | {% if message_code == 1 %}
48 |
49 |
50 | Transaction Successful
51 |
54 |
55 |
56 |
57 | {% elif message_code == 2 %}
58 |
59 |
60 | Last Transaction Failed
61 |
64 |
65 |
66 | {% elif message_code == 3 %}
67 |
68 |
69 | Last Transaction Failed! Email already exists.
70 |
73 |
74 |
75 | {% endif %}
76 |
77 | {% if student_list.count > 0 %}
78 |
79 |
80 |
81 |
82 | | First Name |
83 | Last Name |
84 | Email |
85 | Password |
86 | Image |
87 |
88 |
89 |
90 | {% for student in student_list %}
91 |
92 | | {{ student.fname }} |
93 | {{ student.lname }} |
94 | {{ student.email }} |
95 | {{ student.password }} |
96 | {{ student.image }}
97 |
98 |
103 |
104 | |
105 |
106 | {% endfor %}
107 |
108 |
109 |
110 | {% endif %}
111 | {% endblock %}
112 |
--------------------------------------------------------------------------------
/MTP/templates/ftest_list.html:
--------------------------------------------------------------------------------
1 | {% extends "fac_dashbase.html" %}
2 | {% block title %}Test List{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
53 |
54 |
55 | {% if message_code == 1 %}
56 |
57 |
58 | Data Successfully Stored
59 |
62 |
63 |
64 |
65 | {% elif message_code == 2 %}
66 |
67 |
68 | Last Transaction Failed
69 |
72 |
73 |
74 | {% elif message_code == 3 %}
75 |
76 |
77 | Last Transaction Failed! Email already exists.
78 |
81 |
82 |
83 | {% endif %}
84 |
85 | {% if test_list.count > 0 %}
86 |
87 |
88 |
89 |
90 | | Test Name |
91 | Subject Name |
92 | Course Name |
93 |
94 |
95 |
96 | {% for test in test_list %}
97 |
98 | | {{ test.test_name }} |
99 | {{ test.sub_name }} |
100 | {{ test.co_name }}
101 |
104 | |
105 |
106 | {% endfor %}
107 |
108 |
109 |
110 | {% endif %}
111 | {% endblock %}
112 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | 1571597006285
85 |
86 |
87 | 1571597006285
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/MTP/templates/f_admin.html:
--------------------------------------------------------------------------------
1 | {% extends "fac_dashbase.html" %}
2 | {% block title %}Admin{% endblock %}
3 | {% block page_content %}
4 |
5 |
6 |
64 |
65 |
66 | {% if message_code == 1 %}
67 |
68 |
69 | Data Successfully Stored
70 |
73 |
74 |
75 |
76 | {% elif message_code == 2 %}
77 |
78 |
79 | Last Transaction Failed
80 |
83 |
84 |
85 | {% elif message_code == 3 %}
86 |
87 |
88 | Last Transaction Failed! Email already exists.
89 |
92 |
93 |
94 | {% endif %}
95 |
96 |
97 | {% if faculty_list.count > 0 %}
98 |
99 |
100 |
101 |
102 | | First Name |
103 | Last Name |
104 | Email |
105 | Password |
106 | Admin Rights |
107 | Image |
108 |
109 |
110 |
111 | {% for faculty in faculty_list %}
112 |
113 | | {{ faculty.fname }} |
114 | {{ faculty.lname }} |
115 | {{ faculty.email }} |
116 | {{ faculty.password }} |
117 | {% if faculty.admin == '1' %}
118 | Yes |
119 | {% else %}
120 | No |
121 | {% endif %}
122 | {{ faculty.image }} |
123 |
124 | {% endfor %}
125 |
126 |
127 |
128 |
129 | {% else %}
130 | No Faculty records found
131 | {% endif %}
132 |
133 | {% endblock %}
--------------------------------------------------------------------------------
/MTP/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render, redirect
2 | from django.views.decorators.csrf import csrf_exempt
3 | from django.contrib.auth import logout, authenticate, login
4 | from .models import Student, Faculty, Course, Subject, Question, Test
5 | from django.http import HttpResponse
6 |
7 |
8 | def index(request):
9 | try:
10 | if request.session['no_session']==1:
11 | context = {'message': 'Please Login'}
12 | return render(request, 's_login.html', context)
13 | else:
14 | return render(request, 's_login.html', {})
15 | except:
16 | context = {}
17 | return render(request, 's_login.html', context)
18 |
19 |
20 |
21 | def sDash(request):
22 | if request.session.get('email', None) :
23 | lv_dbdata = Student.objects.get(email=request.session.get('email', None))
24 | context = {
25 | 'username': lv_dbdata.fname
26 | }
27 | print('------------>>>>', context)
28 | return render(request, 'sdash.html', context)
29 | else:
30 | request.session['no_session'] = '1'
31 | return redirect('index')
32 |
33 |
34 | @csrf_exempt
35 | def sLogin(request):
36 | if request.method == 'POST':
37 | lv_email = request.POST.get("email")
38 | lv_password = request.POST.get("password")
39 | dbQuery = Student.objects.filter(email=lv_email)
40 | if dbQuery.count() == 1:
41 | print(">>>>> [INFO] ", lv_email, lv_password)
42 | request.session['email'] = lv_email
43 | return redirect('Dashboard')
44 | # return redirect('Dashboard', lv_fname)
45 | else:
46 | return HttpResponse("Invalid Credentials")
47 | else:
48 | return redirect('index')
49 |
50 |
51 | def logout_request(request):
52 | logout(request)
53 | request.session['no_session'] = 0
54 | return redirect("index")
55 | # messages.info(request, "Logged out successfully!")
56 |
57 |
58 | def faculty_login(request):
59 | if request.method == 'POST':
60 | lv_email = request.POST.get("email")
61 | lv_password = request.POST.get("password")
62 | dbQuery = Faculty.objects.filter(email=lv_email)
63 | if dbQuery.count() == 1:
64 | print(">>>>> [INFO] ", lv_email, lv_password)
65 | request.session['f_email'] = lv_email
66 | lv_dbdata = Faculty.objects.get(email=request.session.get('f_email', None))
67 | request.session['f_username'] = lv_dbdata.fname
68 | return redirect('Fac_Dash')
69 | # return redirect('Dashboard', lv_fname)
70 | else:
71 | return render(request, 'fac_login.html', {'message': 'Invalid Credentials'})
72 | else:
73 | try:
74 | if request.session['no_session'] == 1:
75 | return render(request, 'fac_login.html', {'message': 'Please Login'})
76 | else:
77 | return render(request, 'fac_login.html', {})
78 | except:
79 | return render(request, 'fac_login.html', {})
80 | return render(request, 'fac_login.html', {})
81 |
82 |
83 | def fac_dash(request):
84 | if request.session.get('f_email', None) :
85 | lv_dbdata = Faculty.objects.get(email=request.session.get('f_email', None))
86 | context = {
87 | 'username': lv_dbdata.fname,
88 | 'admin': lv_dbdata.admin
89 | }
90 | print('------------>>>>', context)
91 | return render(request, 'fdash.html', context)
92 | else:
93 | request.session['no_session'] = '1'
94 | return redirect('faculty')
95 |
96 |
97 | def student_list(request):
98 | if request.session.get('f_email', None):
99 | try:
100 | if request.session['message_code']:
101 | pass
102 | except:
103 | request.session['message_code'] = 0
104 | lv_dbdata = Student.objects.all()
105 | lv_userdata = Faculty.objects.get(email=request.session.get('f_email', None))
106 | context = {'student_list': lv_dbdata,
107 | 'message_code': request.session['message_code'],
108 | 'username': lv_userdata.fname,
109 | 'admin': lv_userdata.admin}
110 | if request.session.get('flag', None) == 1:
111 | request.session['message_code'] = 0
112 | return render(request, 'fstudent_list.html', context)
113 | else:
114 | request.session['no_session'] = '1'
115 | return redirect('faculty')
116 |
117 |
118 | @csrf_exempt
119 | def create_student(request):
120 | if request.session.get('f_email', None) and request.method == 'POST':
121 | lv_email = request.POST.get("email")
122 | lv_fname = request.POST.get("fname")
123 | lv_lname = request.POST.get("lname")
124 | lv_password = request.POST.get("password")
125 | dbQuery = Student.objects.filter(email=lv_email)
126 | if dbQuery.count() > 0:
127 | print(">>>>> [ERROR] already exists -> ", lv_email, lv_password)
128 | request.session['message_code'] = 3
129 | request.session['flag'] = 1
130 | return redirect('student_list')
131 | elif dbQuery.count() == 0:
132 | s1 = Student(email=lv_email, fname=lv_fname, lname=lv_lname, password=lv_password)
133 | s1.save()
134 | dbQuery = Student.objects.filter(email=lv_email)
135 | if dbQuery.count()==1:
136 | request.session['message_code'] = 1
137 | request.session['flag'] = 1
138 | return redirect('student_list')
139 | else:
140 | request.session['message_code'] = 2
141 | request.session['flag'] = 1
142 | return redirect('student_list')
143 | else:
144 | return redirect('faculty')
145 |
146 |
147 | @csrf_exempt
148 | def delete_student(request):
149 | if request.session.get('f_email', None) and request.method == 'POST':
150 | lv_sid = request.POST.get("student_id")
151 | dbQuery = Student.objects.filter(id=lv_sid)
152 | if dbQuery.count() > 0:
153 | s1 = Student(id=lv_sid).delete()
154 | dbQuery = Student.objects.filter(id=lv_sid)
155 | if dbQuery.count()!=0:
156 | request.session['message_code'] = 2
157 | request.session['flag'] = 1
158 | return redirect('student_list')
159 | elif dbQuery.count()==0:
160 | request.session['message_code'] = 1
161 | request.session['flag'] = 1
162 | return redirect('student_list')
163 | return redirect('student_list')
164 | else:
165 | return redirect('faculty')
166 |
167 |
168 | def f_admin(request):
169 | if request.session.get('f_email', None):
170 | try:
171 | if request.session['message_code']:
172 | pass
173 | except:
174 | request.session['message_code'] = 0
175 | lv_userdata = Faculty.objects.get(email=request.session.get('f_email', None))
176 | if lv_userdata.admin == '1':
177 | lt_facdata = Faculty.objects.all()
178 | context = {'faculty_list': lt_facdata,
179 | 'message_code': request.session['message_code'],
180 | 'username': lv_userdata.fname,
181 | 'admin': lv_userdata.admin}
182 | if request.session.get('flag', None) == 1:
183 | request.session['message_code'] = 0
184 | return render(request, 'f_admin.html', context)
185 | else:
186 | return redirect('fac_dash')
187 | else:
188 | request.session['no_session'] = '1'
189 | return redirect('faculty')
190 | return redirect('faculty')
191 |
192 |
193 | @csrf_exempt
194 | def create_faculty(request):
195 | if request.session.get('f_email', None) and request.method == 'POST':
196 | lv_email = request.POST.get("email")
197 | lv_fname = request.POST.get("fname")
198 | lv_lname = request.POST.get("lname")
199 | lv_password = request.POST.get("password")
200 | lv_admin = request.POST.get("adminright")
201 | dbQuery = Faculty.objects.filter(email=lv_email)
202 | if dbQuery.count() > 0:
203 | print(">>>>> [ERROR] already exists -> ", lv_email, lv_password)
204 | request.session['message_code'] = 3
205 | request.session['flag'] = 1
206 | return redirect('student_list')
207 | elif dbQuery.count() == 0:
208 | f1 = Faculty(email=lv_email, fname=lv_fname, lname=lv_lname, password=lv_password, admin=lv_admin)
209 | f1.save()
210 | dbQuery = Faculty.objects.filter(email=lv_email)
211 | if dbQuery.count()==1:
212 | request.session['message_code'] = 1
213 | request.session['flag'] = 1
214 | return redirect('f_admin')
215 | else:
216 | request.session['message_code'] = 2
217 | request.session['flag'] = 1
218 | return redirect('f_admin')
219 | else:
220 | return redirect('faculty')
221 |
222 |
223 | def course_list(request):
224 | if request.session.get('f_email', None):
225 | try:
226 | if request.session['message_code']:
227 | pass
228 | except:
229 | request.session['message_code'] = 0
230 | lv_dbdata = Course.objects.all()
231 | lv_userdata = Faculty.objects.get(email=request.session.get('f_email', None))
232 | context = {'course_list': lv_dbdata,
233 | 'message_code': request.session['message_code'],
234 | 'username': lv_userdata.fname,
235 | 'admin': lv_userdata.admin}
236 | if request.session.get('flag', None) == 1:
237 | request.session['message_code'] = 0
238 | return render(request, 'fcourse_list.html', context)
239 | else:
240 | request.session['no_session'] = '1'
241 | return redirect('faculty')
242 |
243 |
244 | @csrf_exempt
245 | def create_course(request):
246 | if request.session.get('f_email', None) and request.method == 'POST':
247 | lv_name = request.POST.get("name")
248 | dbQuery = Course.objects.filter(co_name=lv_name)
249 | if dbQuery.count() > 0:
250 | print(">>>>> [ERROR] already exists -> ", lv_name)
251 | request.session['flag'] = 1
252 | request.session['message_code'] = 3
253 | return redirect('course_list')
254 | elif dbQuery.count() == 0:
255 | c1 = Course(co_name=lv_name)
256 | c1.save()
257 | dbQuery = Course.objects.filter(co_name=lv_name)
258 | if dbQuery.count()==1:
259 | request.session['message_code'] = 1
260 | request.session['flag'] = 1
261 | return redirect('course_list')
262 | else:
263 | request.session['message_code'] = 2
264 | request.session['flag'] = 1
265 | return redirect('course_list')
266 | else:
267 | return redirect('faculty')
268 |
269 |
270 | def subject_list(request):
271 | if request.session.get('f_email', None):
272 | try:
273 | if request.session['message_code']:
274 | pass
275 | except:
276 | request.session['message_code'] = 0
277 | lv_dbdata = Subject.objects.all()
278 | lv_courses = Course.objects.all()
279 | lv_userdata = Faculty.objects.get(email=request.session.get('f_email', None))
280 | context = {'subject_list': lv_dbdata,
281 | 'course_list': lv_courses,
282 | 'message_code': request.session['message_code'],
283 | 'username': lv_userdata.fname,
284 | 'admin': lv_userdata.admin}
285 | if request.session.get('flag', None) == 1:
286 | request.session['message_code'] = 0
287 | return render(request, 'fsubject_list.html', context)
288 | else:
289 | request.session['no_session'] = '1'
290 | return redirect('faculty')
291 |
292 |
293 | @csrf_exempt
294 | def create_subject(request):
295 | if request.session.get('f_email', None) and request.method == 'POST':
296 | lv_name = request.POST.get("name")
297 | lv_course = request.POST.get("course_id")
298 | dbQuery = Subject.objects.filter(sub_name=lv_name)
299 | if dbQuery.count() > 0:
300 | print(">>>>> [ERROR] already exists -> ", lv_name)
301 | request.session['flag'] = 1
302 | request.session['message_code'] = 3
303 | return redirect('subject_list')
304 | elif dbQuery.count() == 0:
305 | sub1 = Subject(sub_name=lv_name, co_name=lv_course)
306 | sub1.save()
307 | dbQuery = Subject.objects.filter(sub_name=lv_name)
308 | if dbQuery.count()==1:
309 | request.session['message_code'] = 1
310 | request.session['flag'] = 1
311 | return redirect('subject_list')
312 | else:
313 | request.session['message_code'] = 2
314 | request.session['flag'] = 1
315 | return redirect('subject_list')
316 | else:
317 | return redirect('faculty')
318 |
319 |
320 |
321 | def test_list(request):
322 | if request.session.get('f_email', None):
323 | try:
324 | if request.session['message_code']:
325 | pass
326 | except:
327 | request.session['message_code'] = 0
328 | lv_dbdata = Subject.objects.all()
329 | lv_courses = Course.objects.all()
330 | lv_tests = Test.objects.all()
331 | lv_userdata = Faculty.objects.get(email=request.session.get('f_email', None))
332 | context = {'subject_list': lv_dbdata,
333 | 'test_list': lv_tests,
334 | 'course_list': lv_courses,
335 | 'message_code': request.session['message_code'],
336 | 'username': lv_userdata.fname,
337 | 'admin': lv_userdata.admin}
338 | if request.session.get('flag', None) == 1:
339 | request.session['message_code'] = 0
340 | return render(request, 'ftest_list.html', context)
341 | else:
342 | request.session['no_session'] = '1'
343 | return redirect('faculty')
344 |
345 |
346 | @csrf_exempt
347 | def create_test(request):
348 | if request.session.get('f_email', None) and request.method == 'POST':
349 | lv_name = request.POST.get("name")
350 | lv_course = request.POST.get("course_id")
351 | lv_subject = request.POST.get("subject_id")
352 | dbQuery = Test.objects.filter(test_name=lv_name)
353 | if dbQuery.count() > 0:
354 | print(">>>>> [ERROR] already exists -> ", lv_name)
355 | request.session['flag'] = 1
356 | request.session['message_code'] = 3
357 | return redirect('test_list')
358 | elif dbQuery.count() == 0:
359 | test1 = Test(test_name=lv_name, sub_name=lv_subject, co_name=lv_course)
360 | test1.save()
361 | dbQuery = Test.objects.filter(test_name=lv_name)
362 | if dbQuery.count()==1:
363 | request.session['message_code'] = 1
364 | request.session['flag'] = 1
365 | return redirect('test_list')
366 | else:
367 | request.session['message_code'] = 2
368 | request.session['flag'] = 1
369 | return redirect('test_list')
370 | else:
371 | return redirect('faculty')
372 |
373 |
--------------------------------------------------------------------------------