diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..997aced --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot +*.sqlite3 +# Sphinx documentation +docs/_build/ \ No newline at end of file diff --git a/django_school/classroom/__pycache__/__init__.cpython-36.pyc b/django_school/classroom/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 1457f58..0000000 Binary files a/django_school/classroom/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/__pycache__/__init__.cpython-37.pyc b/django_school/classroom/__pycache__/__init__.cpython-37.pyc index 6570383..325f1dc 100644 Binary files a/django_school/classroom/__pycache__/__init__.cpython-37.pyc and b/django_school/classroom/__pycache__/__init__.cpython-37.pyc differ diff --git a/django_school/classroom/__pycache__/admin.cpython-36.pyc b/django_school/classroom/__pycache__/admin.cpython-36.pyc deleted file mode 100644 index 361d2c6..0000000 Binary files a/django_school/classroom/__pycache__/admin.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/__pycache__/admin.cpython-37.pyc b/django_school/classroom/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..3c9a0d5 Binary files /dev/null and b/django_school/classroom/__pycache__/admin.cpython-37.pyc differ diff --git a/django_school/classroom/__pycache__/decorators.cpython-36.pyc b/django_school/classroom/__pycache__/decorators.cpython-36.pyc deleted file mode 100644 index 7b34c9d..0000000 Binary files a/django_school/classroom/__pycache__/decorators.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/__pycache__/decorators.cpython-37.pyc b/django_school/classroom/__pycache__/decorators.cpython-37.pyc index 85063f8..79f1ff4 100644 Binary files a/django_school/classroom/__pycache__/decorators.cpython-37.pyc and b/django_school/classroom/__pycache__/decorators.cpython-37.pyc differ diff --git a/django_school/classroom/__pycache__/forms.cpython-36.pyc b/django_school/classroom/__pycache__/forms.cpython-36.pyc deleted file mode 100644 index da8b2e2..0000000 Binary files a/django_school/classroom/__pycache__/forms.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/__pycache__/forms.cpython-37.pyc b/django_school/classroom/__pycache__/forms.cpython-37.pyc index 0a6ffc4..f2de822 100644 Binary files a/django_school/classroom/__pycache__/forms.cpython-37.pyc and b/django_school/classroom/__pycache__/forms.cpython-37.pyc differ diff --git a/django_school/classroom/__pycache__/models.cpython-36.pyc b/django_school/classroom/__pycache__/models.cpython-36.pyc deleted file mode 100644 index 3e8103e..0000000 Binary files a/django_school/classroom/__pycache__/models.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/__pycache__/models.cpython-37.pyc b/django_school/classroom/__pycache__/models.cpython-37.pyc index dc88bfa..4f640b7 100644 Binary files a/django_school/classroom/__pycache__/models.cpython-37.pyc and b/django_school/classroom/__pycache__/models.cpython-37.pyc differ diff --git a/django_school/classroom/__pycache__/urls.cpython-36.pyc b/django_school/classroom/__pycache__/urls.cpython-36.pyc deleted file mode 100644 index 275080f..0000000 Binary files a/django_school/classroom/__pycache__/urls.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/__pycache__/urls.cpython-37.pyc b/django_school/classroom/__pycache__/urls.cpython-37.pyc index bacdcab..c76a41a 100644 Binary files a/django_school/classroom/__pycache__/urls.cpython-37.pyc and b/django_school/classroom/__pycache__/urls.cpython-37.pyc differ diff --git a/django_school/classroom/admin.py b/django_school/classroom/admin.py index 44e3a69..59fbd94 100644 --- a/django_school/classroom/admin.py +++ b/django_school/classroom/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from classroom.models import User, Subject, Quiz, Question, Answer, Student, TakenQuiz, StudentAnswer +from classroom.models import User, Subject, Quiz, Question, Answer, Student, TakenQuiz, StudentAnswer, Selected_lists, Placement admin.site.register(User) admin.site.register(Subject) @@ -9,3 +9,5 @@ admin.site.register(Student) admin.site.register(TakenQuiz) admin.site.register(StudentAnswer) +admin.site.register(Placement) +admin.site.register(Selected_lists) diff --git a/django_school/classroom/forms.py b/django_school/classroom/forms.py index c7bdc0c..6f214fa 100644 --- a/django_school/classroom/forms.py +++ b/django_school/classroom/forms.py @@ -8,8 +8,12 @@ class TeacherSignUpForm(UserCreationForm): + first_name = forms.CharField(max_length=30, required=False) + last_name = forms.CharField(max_length=30, required=False) + email = forms.EmailField(max_length=254) class Meta(UserCreationForm.Meta): model = User + fields = ('email', 'username', 'first_name', 'last_name') def save(self, commit=True): user = super().save(commit=False) @@ -20,6 +24,9 @@ def save(self, commit=True): class StudentSignUpForm(UserCreationForm): + first_name = forms.CharField(max_length=30, required=False) + last_name = forms.CharField(max_length=30, required=False) + email = forms.EmailField(max_length=254) interests = forms.ModelMultipleChoiceField( queryset=Subject.objects.all(), widget=forms.CheckboxSelectMultiple, @@ -28,6 +35,7 @@ class StudentSignUpForm(UserCreationForm): class Meta(UserCreationForm.Meta): model = User + fields = ('email', 'username', 'first_name', 'last_name') @transaction.atomic def save(self): diff --git a/django_school/classroom/migrations/0001_initial.py b/django_school/classroom/migrations/0001_initial.py deleted file mode 100644 index eb439f8..0000000 --- a/django_school/classroom/migrations/0001_initial.py +++ /dev/null @@ -1,144 +0,0 @@ -# Generated by Django 2.0.1 on 2019-03-14 12:41 - -from django.conf import settings -import django.contrib.auth.models -import django.contrib.auth.validators -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('auth', '0009_alter_user_last_name_max_length'), - ] - - operations = [ - migrations.CreateModel( - name='User', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), - ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), - ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), - ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), - ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('is_student', models.BooleanField(default=False)), - ('is_teacher', models.BooleanField(default=False)), - ], - options={ - 'verbose_name': 'user', - 'verbose_name_plural': 'users', - 'abstract': False, - }, - managers=[ - ('objects', django.contrib.auth.models.UserManager()), - ], - ), - migrations.CreateModel( - name='Answer', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('text', models.CharField(max_length=255, verbose_name='Answer')), - ('is_correct', models.BooleanField(default=False, verbose_name='Correct answer')), - ], - ), - migrations.CreateModel( - name='Question', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('text', models.CharField(max_length=255, verbose_name='Question')), - ], - ), - migrations.CreateModel( - name='Quiz', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=255)), - ], - ), - migrations.CreateModel( - name='StudentAnswer', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('answer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='classroom.Answer')), - ], - ), - migrations.CreateModel( - name='Subject', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=30)), - ('color', models.CharField(default='#007bff', max_length=7)), - ], - ), - migrations.CreateModel( - name='TakenQuiz', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('score', models.FloatField()), - ('date', models.DateTimeField(auto_now_add=True)), - ('quiz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taken_quizzes', to='classroom.Quiz')), - ], - ), - migrations.CreateModel( - name='Student', - fields=[ - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), - ('interests', models.ManyToManyField(related_name='interested_students', to='classroom.Subject')), - ], - ), - migrations.AddField( - model_name='quiz', - name='owner', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quizzes', to=settings.AUTH_USER_MODEL), - ), - migrations.AddField( - model_name='quiz', - name='subject', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quizzes', to='classroom.Subject'), - ), - migrations.AddField( - model_name='question', - name='quiz', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='classroom.Quiz'), - ), - migrations.AddField( - model_name='answer', - name='question', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='classroom.Question'), - ), - migrations.AddField( - model_name='user', - name='groups', - field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups'), - ), - migrations.AddField( - model_name='user', - name='user_permissions', - field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'), - ), - migrations.AddField( - model_name='takenquiz', - name='student', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taken_quizzes', to='classroom.Student'), - ), - migrations.AddField( - model_name='studentanswer', - name='student', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quiz_answers', to='classroom.Student'), - ), - migrations.AddField( - model_name='student', - name='quizzes', - field=models.ManyToManyField(through='classroom.TakenQuiz', to='classroom.Quiz'), - ), - ] diff --git a/django_school/classroom/migrations/__pycache__/0001_initial.cpython-36.pyc b/django_school/classroom/migrations/__pycache__/0001_initial.cpython-36.pyc deleted file mode 100644 index 67651a5..0000000 Binary files a/django_school/classroom/migrations/__pycache__/0001_initial.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/migrations/__pycache__/0001_initial.cpython-37.pyc b/django_school/classroom/migrations/__pycache__/0001_initial.cpython-37.pyc index a4ef560..7a02be5 100644 Binary files a/django_school/classroom/migrations/__pycache__/0001_initial.cpython-37.pyc and b/django_school/classroom/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/django_school/classroom/migrations/__pycache__/__init__.cpython-36.pyc b/django_school/classroom/migrations/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 9e543e2..0000000 Binary files a/django_school/classroom/migrations/__pycache__/__init__.cpython-36.pyc and /dev/null differ diff --git a/django_school/classroom/migrations/__pycache__/__init__.cpython-37.pyc b/django_school/classroom/migrations/__pycache__/__init__.cpython-37.pyc index aa4dd03..cb7c0e9 100644 Binary files a/django_school/classroom/migrations/__pycache__/__init__.cpython-37.pyc and b/django_school/classroom/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/django_school/classroom/models.py b/django_school/classroom/models.py index 31fa36d..876ddf7 100644 --- a/django_school/classroom/models.py +++ b/django_school/classroom/models.py @@ -30,6 +30,13 @@ class Quiz(models.Model): def __str__(self): return self.name +class Placement(models.Model): + owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name='placements') + company_name = models.CharField(max_length=255) + package = models.FloatField() + + def __str__(self): + return self.company_name class Question(models.Model): quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='questions') @@ -38,7 +45,14 @@ class Question(models.Model): def __str__(self): return self.text +class Selected_lists(models.Model): + placement = models.ForeignKey(Placement, on_delete=models.CASCADE, related_name='selected_lists') + roll_no = models.CharField(max_length=10) + name = models.CharField(max_length=255) + def __str__(self): + return self.name + class Answer(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name='answers') text = models.CharField('Answer', max_length=255) diff --git a/django_school/classroom/templates/classroom/teachers/Charts/chartjs.html b/django_school/classroom/templates/classroom/teachers/Charts/chartjs.html new file mode 100644 index 0000000..b5b44d0 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Charts/chartjs.html @@ -0,0 +1,62 @@ +{% extends 'base_teacher.html' %} +{% load static%} + + + + + {% block content %} +
+
+
+
+

Line chart

+ +
+
+
+
+
+
+

Bar chart

+ +
+
+
+
+
+
+
+
+

Area chart

+ +
+
+
+
+
+
+

Doughnut chart

+ +
+
+
+
+
+
+
+
+

Pie chart

+ +
+
+
+
+
+
+

Scatter chart

+ +
+
+
+
+ {% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Dashboard/Dashboard.html b/django_school/classroom/templates/classroom/teachers/Dashboard/Dashboard.html new file mode 100644 index 0000000..4c2e717 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Dashboard/Dashboard.html @@ -0,0 +1,5 @@ +{% extends 'base_teacher.html' %} + +{% block content %} +Hello, This is a dashboard.!! +{% endblock %} \ No newline at end of file diff --git a/django_school/classroom/templates/classroom/teachers/Placement/list_add_form.html b/django_school/classroom/templates/classroom/teachers/Placement/list_add_form.html new file mode 100644 index 0000000..845323c --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/list_add_form.html @@ -0,0 +1,30 @@ +{% extends 'base_teacher.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + + {% if messages %} + {% for messages in messages %} +
+ {{message|safe}} +
+ {% endfor %} + {% else %} +

Upload the selection list

+

{{order}}

+
+ {% csrf_token %} + + + + Nevermind +
+ {% endif %} +{% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Placement/placement_add_form.html b/django_school/classroom/templates/classroom/teachers/Placement/placement_add_form.html new file mode 100644 index 0000000..0205dc1 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/placement_add_form.html @@ -0,0 +1,23 @@ +{% extends 'base_teacher.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + +

Add a new placement

+
+
+
+ {% csrf_token %} + {{ form|crispy }} + + Nevermind +
+
+
+{% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Placement/placement_change_form.html b/django_school/classroom/templates/classroom/teachers/Placement/placement_change_form.html new file mode 100644 index 0000000..fbda537 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/placement_change_form.html @@ -0,0 +1,58 @@ +{% extends 'base_teacher.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + +

+ {{ placement.company_name }} +

+
+
+
+ {% csrf_token %} + {{ form|crispy }} + + Nevermind + Delete +
+
+
+
+
+
+
+ Roll No +
+
+ Name +
+
+
+
+ {% for selected in selected_lists %} +
+
+ +
+ {{ selected.name }} +
+
+
+ {% empty %} +
+

You haven't added any list yet. Go ahead and add the placement list.

+
+ {% endfor %} +
+
+{% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Placement/placement_change_list.html b/django_school/classroom/templates/classroom/teachers/Placement/placement_change_list.html new file mode 100644 index 0000000..3ba2302 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/placement_change_list.html @@ -0,0 +1,38 @@ +{% extends 'base_teacher.html' %} + +{% block content %} + +

My Placements

+ Add Placement +
+ + + + + + + + + + + + {% for placement in placements %} + + + + + + + {% empty %} + + + + {% endfor %} + +
Company NamePackageApplied StudentsSelected Students
{{ placement.company_name }}{{ placement.package}}{{ placement.selected_count }}
You haven't had any placement yet.
+
+{% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Placement/placement_delete_confirm.html b/django_school/classroom/templates/classroom/teachers/Placement/placement_delete_confirm.html new file mode 100644 index 0000000..302e936 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/placement_delete_confirm.html @@ -0,0 +1,20 @@ +{% extends 'base_teacher.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + +

Confirm deletion

+

Are you sure you want to delete the placement "{{ placement.company_name }}"? There is no going back.

+
+ {% csrf_token %} + + Nevermind +
+{% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Placement/student_change_form.html b/django_school/classroom/templates/classroom/teachers/Placement/student_change_form.html new file mode 100644 index 0000000..b50bd8b --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/student_change_form.html @@ -0,0 +1,64 @@ +{% extends 'base_teacher.html' %} + +{% load crispy_forms_tags crispy_forms_filters %} + +{% block content %} + +

{{ question.txt }}

+
+ {% csrf_token %} + {{ formset.management_form }} + {{ form|crispy }} +
+
+
+
+ Answers +
+
+ Correct? +
+
+ Delete? +
+
+
+ {% for error in formset.non_form_errors %} +
{{ error }}
+ {% endfor %} +
+ {% for form in formset %} +
+
+
+ {% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %} + {{ form.text|as_crispy_field }} + {% if form.instance.pk and form.text.value != form.instance.text %}

Old answer: {{ form.instance.text }}

{% endif %} +
+
+ {{ form.is_correct }} +
+
+ {% if form.instance.pk %} + {{ form.DELETE }} + {% endif %} +
+
+
+ {% endfor %} +
+
+

+ Your question may have at least 2 answers and maximum 10 answers. Select at least one correct answer. +

+ + Nevermind + Delete +
+{% endblock %} diff --git a/django_school/classroom/templates/classroom/teachers/Placement/student_delete_confirm.html b/django_school/classroom/templates/classroom/teachers/Placement/student_delete_confirm.html new file mode 100644 index 0000000..6750b51 --- /dev/null +++ b/django_school/classroom/templates/classroom/teachers/Placement/student_delete_confirm.html @@ -0,0 +1,21 @@ +{% extends 'base_teacher.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + +

Confirm deletion

+

Are you sure you want to delete the student "{{ selected.name }} with roll no. {{selected.roll_no}} "? There is no going back.

+
+ {% csrf_token %} + + Nevermind +
+{% endblock %} diff --git a/django_school/classroom/urls.py b/django_school/classroom/urls.py index 078c5fb..09f154e 100644 --- a/django_school/classroom/urls.py +++ b/django_school/classroom/urls.py @@ -13,13 +13,21 @@ ], 'classroom'), namespace='students')), path('teachers/', include(([ - path('', teachers.QuizListView.as_view(), name='quiz_change_list'), + path('', teachers.dashboard, name='dashboard'), + path('charts/', teachers.charts, name='charts'), + path('placement/', teachers.PlacementListView.as_view(), name='placement_change_list'), + path('list/', teachers.QuizListView.as_view(), name='quiz_change_list'), + path('placement/add/', teachers.PlacementCreateView.as_view(), name='placement_add'), path('quiz/add/', teachers.QuizCreateView.as_view(), name='quiz_add'), + path('placement//', teachers.PlacementUpdateView.as_view(), name='placement_change'), path('quiz//', teachers.QuizUpdateView.as_view(), name='quiz_change'), + path('placement//delete/', teachers.PlacementDeleteView.as_view(), name='placement_delete'), path('quiz//delete/', teachers.QuizDeleteView.as_view(), name='quiz_delete'), path('quiz//results/', teachers.QuizResultsView.as_view(), name='quiz_results'), + path('placement//list/add/', teachers.upload_csv, name='list_add'), path('quiz//question/add/', teachers.question_add, name='question_add'), path('quiz//question//', teachers.question_change, name='question_change'), + path('placement//selected_lists//delete/', teachers.StudentDeleteView.as_view(), name='student_delete'), path('quiz//question//delete/', teachers.QuestionDeleteView.as_view(), name='question_delete'), ], 'classroom'), namespace='teachers')), ] diff --git a/django_school/classroom/views/__pycache__/__init__.cpython-37.pyc b/django_school/classroom/views/__pycache__/__init__.cpython-37.pyc index 5031bcf..af079a6 100644 Binary files a/django_school/classroom/views/__pycache__/__init__.cpython-37.pyc and b/django_school/classroom/views/__pycache__/__init__.cpython-37.pyc differ diff --git a/django_school/classroom/views/__pycache__/classroom.cpython-37.pyc b/django_school/classroom/views/__pycache__/classroom.cpython-37.pyc index 47a62b6..d943e0f 100644 Binary files a/django_school/classroom/views/__pycache__/classroom.cpython-37.pyc and b/django_school/classroom/views/__pycache__/classroom.cpython-37.pyc differ diff --git a/django_school/classroom/views/__pycache__/students.cpython-37.pyc b/django_school/classroom/views/__pycache__/students.cpython-37.pyc index e31b582..1d960a9 100644 Binary files a/django_school/classroom/views/__pycache__/students.cpython-37.pyc and b/django_school/classroom/views/__pycache__/students.cpython-37.pyc differ diff --git a/django_school/classroom/views/__pycache__/teachers.cpython-37.pyc b/django_school/classroom/views/__pycache__/teachers.cpython-37.pyc index 0751427..42844cf 100644 Binary files a/django_school/classroom/views/__pycache__/teachers.cpython-37.pyc and b/django_school/classroom/views/__pycache__/teachers.cpython-37.pyc differ diff --git a/django_school/classroom/views/classroom.py b/django_school/classroom/views/classroom.py index 1b687d5..023d93b 100644 --- a/django_school/classroom/views/classroom.py +++ b/django_school/classroom/views/classroom.py @@ -9,7 +9,7 @@ class SignUpView(TemplateView): def home(request): if request.user.is_authenticated: if request.user.is_teacher: - return redirect('teachers:quiz_change_list') + return redirect('teachers:placement_change_list') else: return redirect('students:quiz_list') return render(request, 'classroom/home.html') diff --git a/django_school/classroom/views/teachers.py b/django_school/classroom/views/teachers.py index 9237f2f..976c41d 100644 --- a/django_school/classroom/views/teachers.py +++ b/django_school/classroom/views/teachers.py @@ -1,3 +1,4 @@ +import csv,io from django.contrib import messages from django.contrib.auth import login from django.contrib.auth.decorators import login_required @@ -7,12 +8,10 @@ from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse, reverse_lazy from django.utils.decorators import method_decorator -from django.views.generic import (CreateView, DeleteView, DetailView, ListView, - UpdateView) - +from django.views.generic import (CreateView, DeleteView, DetailView, ListView, UpdateView) from ..decorators import teacher_required from ..forms import BaseAnswerInlineFormSet, QuestionForm, TeacherSignUpForm -from ..models import Answer, Question, Quiz, User +from ..models import Answer, Question, Quiz, User, Placement, Selected_lists class TeacherSignUpView(CreateView): @@ -29,6 +28,19 @@ def form_valid(self, form): login(self.request, user) return redirect('teachers:quiz_change_list') +@login_required +@teacher_required +def dashboard(request): + return render(request,'classroom/teachers/dashboard/dashboard.html') + + +@login_required +@teacher_required +def charts(request): + return render(request,'classroom/teachers/Charts/chartjs.html') + + + @method_decorator([login_required, teacher_required], name='dispatch') class QuizListView(ListView): @@ -44,6 +56,18 @@ def get_queryset(self): .annotate(taken_count=Count('taken_quizzes', distinct=True)) return queryset +@method_decorator([login_required, teacher_required], name='dispatch') +class PlacementListView(ListView): + model = Placement + ordering = ('company_name', 'package' ) + context_object_name = 'placements' + template_name = 'classroom/teachers/Placement/placement_change_list.html' + + def get_queryset(self): + queryset = self.request.user.placements \ + .annotate(selected_count=Count('selected_lists', distinct=True)) + return queryset + @method_decorator([login_required, teacher_required], name='dispatch') class QuizCreateView(CreateView): @@ -58,6 +82,19 @@ def form_valid(self, form): messages.success(self.request, 'The quiz was created with success! Go ahead and add some questions now.') return redirect('teachers:quiz_change', quiz.pk) +@method_decorator([login_required, teacher_required], name='dispatch') +class PlacementCreateView(CreateView): + model = Placement + fields = ('company_name', 'package') + template_name = 'classroom/teachers/Placement/placement_add_form.html' + + def form_valid(self, form): + placement = form.save(commit=False) + placement.owner = self.request.user + placement.save() + messages.success(self.request, 'The company detail was created with success! Go ahead and add list of selected students now.') + return redirect('teachers:placement_change', placement.pk) + @method_decorator([login_required, teacher_required], name='dispatch') class QuizUpdateView(UpdateView): @@ -81,6 +118,29 @@ def get_queryset(self): def get_success_url(self): return reverse('teachers:quiz_change', kwargs={'pk': self.object.pk}) +@method_decorator([login_required, teacher_required], name='dispatch') +class PlacementUpdateView(UpdateView): + model = Placement + fields = ('company_name', 'package') + context_object_name = 'placement' + template_name = 'classroom/teachers/Placement/placement_change_form.html' + + def get_context_data(self, **kwargs): + kwargs['selected_lists'] = self.get_object().selected_lists.all() + return super().get_context_data(**kwargs) + + def get_queryset(self): + ''' + This method is an implicit object-level permission management + This view will only match the ids of existing quizzes that belongs + to the logged in user. + ''' + + return self.request.user.placements.all() + + def get_success_url(self): + return reverse('teachers:placement_change', kwargs={'pk': self.object.pk}) + @method_decorator([login_required, teacher_required], name='dispatch') class QuizDeleteView(DeleteView): @@ -97,6 +157,23 @@ def delete(self, request, *args, **kwargs): def get_queryset(self): return self.request.user.quizzes.all() +@method_decorator([login_required, teacher_required], name='dispatch') +class PlacementDeleteView(DeleteView): + model = Placement + context_object_name = 'placement' + template_name = 'classroom/teachers/Placement/placement_delete_confirm.html' + success_url = reverse_lazy('teachers:placement_change_list') + + def delete(self, request, *args, **kwargs): + placement = self.get_object() + messages.success(request, 'The placement %s was deleted with success!' % placement.company_name) + return super().delete(request, *args, **kwargs) + + def get_queryset(self): + return self.request.user.placements.all() + + + @method_decorator([login_required, teacher_required], name='dispatch') class QuizResultsView(DetailView): @@ -143,6 +220,39 @@ def question_add(request, pk): return render(request, 'classroom/teachers/question_add_form.html', {'quiz': quiz, 'form': form}) +@login_required +@teacher_required +def upload_csv(request, pk): + # By filtering the quiz by the url keyword argument `pk` and + # by the owner, which is the logged in user, we are protecting + # this view at the object-level. Meaning only the owner of + # quiz will be able to add questions to it. + placement = get_object_or_404(Placement, pk=pk, owner=request.user) + prompt = { + 'order' : 'Order of CSV should be Roll No, Name', + 'placement' : placement + } + + if request.method == 'GET': + return render(request, 'classroom/teachers/Placement/list_add_form.html',prompt) + if request.method == 'POST': + csv_file = request.FILES['file'] + + if not csv_file.name.endswith('.csv'): + messages.error(request, 'This is not a CSV file') + + data_set = csv_file.read().decode('UTF-8') + io_string = io.StringIO(data_set) + next(io_string) + for column in csv.reader(io_string, delimiter=',', quotechar='|'): + print(column[0],column[1]) + b = Selected_lists(placement=placement, roll_no=column[0], name=column[1]) + b.save() + + return render(request, 'classroom/teachers/Placement/list_add_form.html', {'placement': placement}) + + + @login_required @teacher_required @@ -211,3 +321,27 @@ def get_queryset(self): def get_success_url(self): question = self.get_object() return reverse('teachers:quiz_change', kwargs={'pk': question.quiz_id}) + +@method_decorator([login_required, teacher_required], name='dispatch') +class StudentDeleteView(DeleteView): + model = Selected_lists + context_object_name = 'selected' + template_name = 'classroom/teachers/Placement/student_delete_confirm.html' + pk_url_kwarg = 'selected_lists_pk' + + def get_context_data(self, **kwargs): + selected = self.get_object() + kwargs['placement'] = selected.placement + return super().get_context_data(**kwargs) + + def delete(self, request, *args, **kwargs): + selected = self.get_object() + messages.success(request, 'The question %s was deleted with success!' % selected.name) + return super().delete(request, *args, **kwargs) + + def get_queryset(self): + return Selected_lists.objects.filter(placement__owner=self.request.user) + + def get_success_url(self): + selected = self.get_object() + return reverse('teachers:placement_change', kwargs={'pk': selected.placement_id}) \ No newline at end of file diff --git a/django_school/db.sqlite3 b/django_school/db.sqlite3 index 0ccc0d5..bee6391 100644 Binary files a/django_school/db.sqlite3 and b/django_school/db.sqlite3 differ diff --git a/django_school/django_school/__pycache__/__init__.cpython-37.pyc b/django_school/django_school/__pycache__/__init__.cpython-37.pyc index e56c0aa..ea3028d 100644 Binary files a/django_school/django_school/__pycache__/__init__.cpython-37.pyc and b/django_school/django_school/__pycache__/__init__.cpython-37.pyc differ diff --git a/django_school/django_school/__pycache__/settings.cpython-37.pyc b/django_school/django_school/__pycache__/settings.cpython-37.pyc index 2b9f3f6..42d350d 100644 Binary files a/django_school/django_school/__pycache__/settings.cpython-37.pyc and b/django_school/django_school/__pycache__/settings.cpython-37.pyc differ diff --git a/django_school/django_school/__pycache__/urls.cpython-37.pyc b/django_school/django_school/__pycache__/urls.cpython-37.pyc index 329fe5c..bc260cd 100644 Binary files a/django_school/django_school/__pycache__/urls.cpython-37.pyc and b/django_school/django_school/__pycache__/urls.cpython-37.pyc differ diff --git a/django_school/django_school/__pycache__/wsgi.cpython-37.pyc b/django_school/django_school/__pycache__/wsgi.cpython-37.pyc index 6edaee8..b7a8032 100644 Binary files a/django_school/django_school/__pycache__/wsgi.cpython-37.pyc and b/django_school/django_school/__pycache__/wsgi.cpython-37.pyc differ diff --git a/django_school/templates/base_student.html b/django_school/templates/base_student.html index e747358..9d90231 100644 --- a/django_school/templates/base_student.html +++ b/django_school/templates/base_student.html @@ -25,14 +25,14 @@
- +
@@ -869,7 +870,7 @@
Manage Tickets
- +
@@ -885,22 +886,7 @@
Manage Tickets
- + diff --git a/django_school/templates/base_teacher.html b/django_school/templates/base_teacher.html index ff9f9c8..91f9f52 100644 --- a/django_school/templates/base_teacher.html +++ b/django_school/templates/base_teacher.html @@ -2,831 +2,345 @@ - + - - - - - SB Admin - Dashboard - - - - - - - - - - - {% if user.is_authenticated and user.is_teacher %} - - {% else %} - - {% endif %} - + Student Dashboard + + + + + + + + + + + - - - - -
- - - - -
- -
- - -
+ -
- -
- -
- - - -
-
- - - - -
-
- - Area Chart Example
-
- -
- -
- - -
-
- - Data Table Example
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NamePositionOfficeAgeStart dateSalary
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
Paul ByrdChief Financial Officer (CFO)New York642010/06/09$725,000
Gloria LittleSystems AdministratorNew York592009/04/10$237,500
Bradley GreerSoftware EngineerLondon412012/10/13$132,000
Dai RiosPersonnel LeadEdinburgh352012/09/26$217,500
Jenette CaldwellDevelopment LeadNew York302011/09/03$345,000
Yuri BerryChief Marketing Officer (CMO)New York402009/06/25$675,000
Caesar VancePre-Sales SupportNew York212011/12/12$106,450
Doris WilderSales AssistantSidney232010/09/20$85,600
Angelica RamosChief Executive Officer (CEO)London472009/10/09$1,200,000
Gavin JoyceDeveloperEdinburgh422010/12/22$92,575
Jennifer ChangRegional DirectorSingapore282010/11/14$357,650
Brenden WagnerSoftware EngineerSan Francisco282011/06/07$206,850
Fiona GreenChief Operating Officer (COO)San Francisco482010/03/11$850,000
Shou ItouRegional MarketingTokyo202011/08/14$163,000
Michelle HouseIntegration SpecialistSidney372011/06/02$95,400
Suki BurksDeveloperLondon532009/10/22$114,500
Prescott BartlettTechnical AuthorLondon272011/05/07$145,000
Gavin CortezTeam LeaderSan Francisco222008/10/26$235,500
Martena MccrayPost-Sales supportEdinburgh462011/03/09$324,050
Unity ButlerMarketing DesignerSan Francisco472009/12/09$85,675
Howard HatfieldOffice ManagerSan Francisco512008/12/16$164,500
Hope FuentesSecretarySan Francisco412010/02/12$109,850
Vivian HarrellFinancial ControllerSan Francisco622009/02/14$452,500
Timothy MooneyOffice ManagerLondon372008/12/11$136,200
Jackson BradshawDirectorNew York652008/09/26$645,750
Olivia LiangSupport EngineerSingapore642011/02/03$234,500
Bruno NashSoftware EngineerLondon382011/05/03$163,500
Sakura YamamotoSupport EngineerTokyo372009/08/19$139,575
Thor WaltonDeveloperNew York612013/08/11$98,540
Finn CamachoSupport EngineerSan Francisco472009/07/07$87,500
Serge BaldwinData CoordinatorSingapore642012/04/09$138,575
Zenaida FrankSoftware EngineerNew York632010/01/04$125,250
Zorita SerranoSoftware EngineerSan Francisco562012/06/01$115,000
Jennifer AcostaJunior Javascript DeveloperEdinburgh432013/02/01$75,650
Cara StevensSales AssistantNew York462011/12/06$145,600
Hermione ButlerRegional DirectorLondon472011/03/21$356,250
Lael GreerSystems AdministratorLondon212009/02/27$103,500
Jonas AlexanderDeveloperSan Francisco302010/07/14$86,500
Shad DeckerRegional DirectorEdinburgh512008/11/13$183,000
Michael BruceJavascript DeveloperSingapore292011/06/27$183,000
Donna SniderCustomer SupportNew York272011/01/25$112,000
+ + +
+ +
- -
- + + + + + + + + + + + + +
+
+ {% block content %} + {% endblock %} + +
- - - -
-
- -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + \ No newline at end of file