Teachers App

This app handles the teachers side of the project.

Templates:

All these pages are not visible to anyone that is not logged in and the accounts with ‘student’ status are not allowed to use them.

HTML




<!-- Announcement.html-->
{% load static %}
<!DOCTYPE html>
<html>
   {% if user.is_authenticated %}
   <head>
      <title>Create Announcement</title>
      <link rel="stylesheet" type="text/css" href="{% static 'Teacher/css/announcement.css' %}">
      <link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet">
   </head>
   <body>
      <div class="main">
         <div class="aanounce">
            <label for="chk" aria-hidden="true">Announcement</label>
            <form method="POST" action="/announcement/">
               {% csrf_token %}
               <div class="input">
                  {{form.text}}
               </div>
               <br>
                 
  
<p>Tick this to send message
                  {{form.check}}
               </p>
  
  
               <br>
               <br>
               <button type="submit",name="save"> Send </button>
            </form>
         </div>
      </div>
      <style>
         .main{
         width: 350px;
         height: 500px;
         background: red;
         overflow: hidden;
         background: url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
         border-radius: 10px;
         box-shadow: 5px 20px 50px #000;
         }
      </style>
      <script>
         var form_fields = document.getElementsByTagName('input')
         form_fields[1].placeholder='Write your announcement';      
           
      </script>
   </body>
   {% else %}
   <html>
      <head>
         <title>
            {% block title %}Please Login {% endblock %}
         </title>
      </head>
      <body class="main">
         <h1 class="ml5">
            <span class="text-wrapper">
            <span class="line line1"></span>
            <span class="letters letters-left">HAUS</span>
            <span class="letters ampersand">~</span>
            <span class="letters letters-right">Connect</span>
            <span class="line line2"></span>
            </span>
         </h1>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>        
         <center>
         <p style="color:#f2f2f4">Sadly you are not logged in</p>
  
  
           </center>
         <center>
         <h2><a href="/login" style="color:#f2f2f4"> Login Here</a></h2>
           </center>
      </body>
      <link rel="stylesheet" href="{% static 'Teacher/css/base.css' %}">
      <script type="text/javascript" src="{% static 'Teacher/js/base.js' %}"></script>
      <style>
         .main{
         background:  url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
         }
      </style>
   </html>
   {% endif %} 
</html>


HTML




<!-- Base.html-->
{% load static %}
<html>
    <head>
        <title>
            {% block title %}Please Login {% endblock %}
        </title>
    </head>
  
    <body class="main">
        <h1 class="ml5">
            <span class="text-wrapper">
              <span class="line line1"></span>
              <span class="letters letters-left">HAUS</span>
              <span class="letters ampersand">~</span>
              <span class="letters letters-right">Connect</span>
              <span class="line line2"></span>
            </span>
          </h1>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>        
          
        <center><p style="color:#f2f2f4">You dont have authorization to access this page. </p>
  
  </center>
        <center><p style="color:#f2f2f4">If you are a professor contact administrator. </p>
  
  </center>
        <center>  <h2 style="color:#f2f2f4"><a href="/student_home" style="color:#f2f2f4">Click here</a> if you are a student</h2></center>
        
  
    </body>
    <link rel="stylesheet" href="{% static 'Teacher/css/base.css' %}">
    <script type="text/javascript" src="{% static 'Teacher/js/base.js' %}"></script>
    <style>
        .main{
  background:  url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
            }
    </style>
</html>


HTML




<!-- Class.html-->
{% load static %}
<!DOCTYPE html>
<html>
    {% if user.is_authenticated %}
      
<head>
    <title>Schedule Class</title>
    <link rel="stylesheet" type="text/css" href="{% static 'Teacher/css/class.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet">
</head>
<body>
    <div class="main">      
          
          
        <form method="POST" action="/class/">
            <br>
            <br>
            <label for="chk" aria-hidden="true">Class</label>
            {% csrf_token %}
            <br>
              
  
<p>
            {{form.subject.label}}
            {{form.subject}}
            </p>
  
  
              
              
  
<p>
                {{form.date.label}}
                {{form.date}}
            </p>
  
  
          
              
  
<p>
            {{form.time_start.label}}
            {{form.time_start}}
        </p>
  
  
          
  
<p>
            {{form.time_end.label}}
            {{form.time_end}}
        </p>
  
  
          
          
  
<p>
            {{form.check.label}}
            {{form.check}}
        </p>
  
  
          
            <button type="submit",name="save"> Schedule Class </button>
          
        </form>
              
    </div>
  
    <style>
        .main{
    width: 350px;
    height: 590px;
    background: red;
    overflow: hidden;
    background:  url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
    border-radius: 10px;
    box-shadow: 5px 20px 50px #000;
}
    </style>
    <script>
  
        var form_fields = document.getElementsByTagName('input')
        form_fields[1].placeholder='Subjcet';
        form_fields[2].placeholder='DD/MM/YY';     
        form_fields[3].placeholder='HH:MM AM/PM'; 
        form_fields[4].placeholder='HH:MM AM/PM';           
      
    </script>
</body>
{% else %}
<html>
    <head>
        <title>
            {% block title %}Please Login {% endblock %}
        </title>
    </head>
  
    <body class="main">
        <h1 class="ml5">
            <span class="text-wrapper">
              <span class="line line1"></span>
              <span class="letters letters-left">HAUS</span>
              <span class="letters ampersand">~</span>
              <span class="letters letters-right">Connect</span>
              <span class="line line2"></span>
            </span>
          </h1>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>        
          
        <center><p style="color:#f2f2f4">Sadly you are not logged in</p>
  
  </center>
        <center>  <h2><a href="/login" style="color:#f2f2f4"> Login Here</a></h2></center>
          
    </body>
    <link rel="stylesheet" href="{% static 'Teacher/css/base.css' %}">
    <script type="text/javascript" src="{% static 'Teacher/js/base.js' %}"></script>
    <style>
        .main{
  background:  url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
            }
    </style>
</html>
  
{% endif %} 
</html>


HTML




<!-- Exam.html -->
{% load static %}
<!DOCTYPE html>
<html>
    {% if user.is_authenticated %}
      
<head>
    <title>Schedule Exam</title>
    <link rel="stylesheet" type="text/css" href="{% static 'Teacher/css/exam.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet">
</head>
<body>
    <div class="main">      
          
      
    <form method="POST" action="/exam/">
        <br>
        <label for="chk" aria-hidden="true">Exam</label>
        {% csrf_token %}
        <br>
          
  
<p>
        {{form.subject.label}}
        {{form.subject}}
        </p>
  
  
          
          
  
<p>
            {{form.date.label}}
            {{form.date}}
        </p>
  
  
      
          
  
<p>
        {{form.time_start.label}}
        {{form.time_start}}
    </p>
  
  
      
  
<p>
        {{form.time_end.label}}
        {{form.time_end}}
    </p>
  
  
      
      
  
<p>
        {{form.check.label}}
        {{form.check}}
    </p>
  
  
    <br>
        <button type="submit",name="save"> Schedule Exam </button>
      
    </form>
  
              
    </div>
</body>
  
<style>
    .main{
    width: 350px;
    height: 590px;
    background: red;
    overflow: hidden;
    background: url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
    border-radius: 10px;
    box-shadow: 5px 20px 50px #000;
}
</style>
{% else %}
      <html>
        <head>
            <title>
                {% block title %}Please Login {% endblock %}
            </title>
        </head>
      
        <body class="main">
            <h1 class="ml5">
                <span class="text-wrapper">
                  <span class="line line1"></span>
                  <span class="letters letters-left">HAUS</span>
                  <span class="letters ampersand">~</span>
                  <span class="letters letters-right">Connect</span>
                  <span class="line line2"></span>
                </span>
              </h1>
              <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>        
              
            <center><p style="color:#f2f2f4">Sadly you are not logged in</p>
  
  </center>
            <center>  <h2><a href="/login" style="color:#f2f2f4"> Login Here</a></h2></center>
              
        </body>
        <link rel="stylesheet" href="{% static 'Teacher/css/base.css' %}">
        <script type="text/javascript" src="{% static 'Teacher/js/base.js' %}"></script>
        <style>
            .main{
      background:  url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
                }
        </style>
    </html>
  
  {% endif %} 
</html>


HTML




<!-- home.html -->
{% load static %}
<!DOCTYPE html>
<html lang="en">
   {% if user.is_authenticated %}
   <head>
      <meta charset="UTF-8" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <link
         rel="stylesheet"
         href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"
         integrity="sha512-HK5fgLBL+xu6dm/Ii3z4xhlSUyZgTT9tuc/hSrtw6uzJOvgRr2a9jyxxT1ely+B+xFAmJKVSTbpM/CuL7qxO8w=="
         crossorigin="anonymous"
         />
      <link rel="stylesheet" href="{% static 'Teacher/css/style.css' %}" />
      <title>Teacher's Portal</title>
      <img class="pdeu" src="{% static 'Teacher/images/h1.png' %}" alt="PDEU">
   </head>
   <body>
      <!------------------------------------------------------>
      {% include 'Teacher/messages.html' %}
      <!------------------------------------------------------>   
      <div class="container">
         <div class="content">
            <h1>HAUS-Connect</h1>
            <small>Teacher's Portal</small>
              
  
<p>
               Basically, here all Faculty's can send notice , Schedule Exam and Schedule Lectures. Any action performed by Faculty will send a text message to all students informing them about any upcoming events. HAUS-Connect aims to decrease the ridge between Student and Faculty.It is a firm of the Students,by the Students, for the Students.   
            </p>
  
  
            <h2>TimeTable</h2>
            <small>*Note this is fixed timetable provided by the institution </small>
            <div class="container1">
               <div
                  class="panel active"
                  style="
                  background-image: url(https://drive.google.com/uc?export=view&id=1EYoNIJNZe7s7cFA3rBvNxesi-TZONIoe);
                  "
                  >
               </div>
               <div
                  class="panel"
                  style="
                  background-image: url(https://drive.google.com/uc?export=view&id=1MKpz6fFHogku_2f-9JUOkqBwT36VgITb);
                  "
                  >
               </div>
               <div
                  class="panel"
                  style="
                  background-image: url(https://drive.google.com/uc?export=view&id=1Jytl4YnqtN5-hVqmciOVy-WQc5UfUuyB);
                  "
                  >
               </div>
               <div
                  class="panel"
                  style="
                  background-image: url(https://drive.google.com/uc?export=view&id=1KB4D5-qJUelFc_Xa6ZmfTmKdM_zD6f52);
                  "
                  >
               </div>
               <div
                  class="panel"
                  style="
                  background-image: url(https://drive.google.com/uc?export=view&id=1-VDdpedgkyjlYWMrraIcafjC-YTduY0O);
                  "
                  >
               </div>
            </div>
              
  
<p>
               We the students of PDEU CE`20 batch, appreciate you for putting all your efforts  and helping us throughout the day from solving our 'silly' doubts to help us in any problem which we faced during college. 
            </p>
  
  
            <small>-Thanking You.</small>
            <div class="copyright">
               <hr>
               <h3>
                  © 2021 HAUS - All Rights Reserved
               </h3>
            </div>
         </div>
      </div>
      <div class="circle-container">
         <div class="circle">
            <button id="close">
            <i class="fas fa-times"></i>
            </button>
            <button id="open">
            <i class="fas fa-bars"></i>
            </button>
         </div>
      </div>
      <nav>
         <ul>
            <li>
               <a href="{% url 'Announcement'%}" title=""  rel="noopener noreferrer"><i class="fas fa-bullhorn"></i>Notice</a>
            </li>
            <li>
               <a href="{% url 'Extra Class'%}"  rel="noopener noreferrer"><i class="fas fa-book"></i>Class</a>
            </li>
            <li>
               <a href="{% url 'Exams'%}"  rel="noopener noreferrer"><i class="fas  fa-graduation-cap"></i>Exam</a>
            </li>
            <li >
               <a href="{% url 'logout'%}"  rel="noopener noreferrer"><i class="fas fa-sign-out-alt" aria-hidden="true"></i>Logout</a>
            </li>
         </ul>
      </nav>
      <script src="{% static 'Teacher/js/app.js' %}"></script>
      <script src="{% static 'Teacher/js/app1.js' %}"></script>
   </body>
</html>
{% else %}
<html>
   <head>
      <title>
         {% block title %}Please Login {% endblock %}
      </title>
   </head>
   <body class="main">
      <h1 class="ml5">
         <span class="text-wrapper">
         <span class="line line1"></span>
         <span class="letters letters-left">HAUS</span>
         <span class="letters ampersand">~</span>
         <span class="letters letters-right">Connect</span>
         <span class="line line2"></span>
         </span>
      </h1>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>        
      <center>
         <p style="color:#f2f2f4">Sadly you are not logged in</p>
  
  
      </center>
      <center>
         <h2><a href="/login" style="color:#f2f2f4"> Login Here</a></h2>
      </center>
   </body>
   <link rel="stylesheet" href="{% static 'Teacher/css/base.css' %}">
   <script type="text/javascript" src="{% static 'Teacher/js/base.js' %}"></script>
   <style>
      .main{
      background:  url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover;
      }
   </style>
</html>
{% endif %}


HTML




<!--Logout.html-->
<html>
    <head>
        <title>
            Login here
        </title>
    </head>
{% load crispy_forms_tags %}
  
    <body>
        <h1>Register Here</h1>
  
        <form method="post" class="form-group">
            {% csrf_token %}
            {{ form|crispy }}
            <button type="submit" class="btn btn-success"> Log in </button>
              
              
  
<p>Dont have an account? Create one <a href="/register">here </a></p>
  
  
        </form>
    </body>
</html>


HTML




<!-- message.html-->
{% if messages %}
    {% for message in messages %}
    <div class="alert alert-{{ message.tags }} m-2" id='msg' role='alert'>
       <center>{{message}}</center
    </div>
    <script>
        setTimeout(function(){
          if ($('#msg').length>0){
            $('#msg').remove();
          }
        },2000)
      </script>
    {% endfor %}
{% endif %}


admin.py

This is used to register the models which will use database

Python3




from django.contrib import admin
from .models import *
# Register your models here.
  
admin.site.register(Announcements)
admin.site.register(Class)
admin.site.register(Exam)


 
 

apps.py

 

Register the app

 

Python3




from django.apps import AppConfig
  
class TeacherConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'Teacher'


decorator.py

This file enables us to restrict access to pages.

Python3




from django.http import HttpResponse
from django.shortcuts import redirect, render
  
  
def allowed_users(allowed_roles=[]):
    def decorator(view_func):
        def wrapper_func(request, *args, **kwargs):
            group = None
              
            if request.user.groups.exists():
                group = request.user.groups.all()[0].name
            if group in allowed_roles:
                return view_func(request, *args, **kwargs)
            else:
                return render(request, "Teacher/base.html", {})
                
        return wrapper_func
    return decorator'


forms.py

Creation of forms

Python3




from django import forms
  
  
class createnewannouncement(forms.Form):
    text = forms.CharField(label="Announcement", max_length=1000)
    check = forms.BooleanField(label="Send message", required=False)
  
  
class schedule_extra_class(forms.Form):
    subject = forms.CharField(label="Subject", max_length=20)
    date = forms.CharField(label="Date", max_length=20)
    time_start = forms.CharField(label="Starting Time", max_length=20)
    time_end = forms.CharField(label="Ending Time", max_length=20)
    check = forms.BooleanField(label="Send message", required=False)
  
  
class schedule_exam(forms.Form):
    subject = forms.CharField(label="Subject ", max_length=20)
    date = forms.CharField(label="Date", max_length=20)
    time_start = forms.CharField(label="Starting Time", max_length=20)
    time_end = forms.CharField(label="Ending Time", max_length=20)
    check = forms.BooleanField(label="Send message", required=False)


models.py

This sets up databases for the forms to save data in

Python3




from django.db import models
  
class Announcements(models.Model):
    text = models.TextField(max_length=500)
  
    def __str__(self):
        return self.text
  
  
class Class(models.Model):
    subject = models.TextField(max_length=50)
    date = models.TextField(max_length=50)
    time_start = models.TextField(max_length=5)
    time_end = models.TextField(max_length=5)
    message = "You have a {0} extra class on {1} from {2} to {3}".format(
        str(subject), str(date), str(time_start), str(time_end))
  
    def __str__(self):
        message = "You have a {0} extra class on {1} from {2} to {3}".format(
            str(self.subject), str(self.date), str(self.time_start), str(self.time_end))
        return self.message
  
  
class Exam(models.Model):
    subject = models.TextField(max_length=50)
    date = models.TextField(max_length=50)
    time_start = models.TextField(max_length=5)
    time_end = models.TextField(max_length=5)
    message = "You have a {0} exam on {1} from {2} to {3}".format(
        str(subject), str(date), str(time_start), str(time_end))
  
    def __str__(self):
        message = "You have a {0} exam on {1} from {2} to {3}".format(
            str(self.subject), str(self.date), str(self.time_start), str(self.time_end))
        return self.message


sending_messages.py

This file is responsible for sending messages to the provided numbers

Python3




def send_message(message):
    from twilio.rest import Client
  
    client = Client("Account SId", "Auth token")
  
    numbers = ["+916351816925", "+91xxxxxxxxxx",
               "+91xxxxxxxxxx", "+91xxxxxxxxxx"]
    names = ["Sarthak", "Hardeep", "Utsav", "Ahmed"]
  
    for i in range(4):
        m = ("Hello {} ".format(names[i]))+message
        client.messages.create(to=numbers[i],
                               from_="number provided by the api",
                               body=(m))


urls.py

Links templates to addresses

Python3




from django.urls import path
from . import views
  
urlpatterns = [
    path("", views.home, name="Home"),
    path("<int:id>", views.index, name="index"),
    path("announcement/", views.create_announcement, name="Announcement"),
    path("class/", views.create_class, name="Extra Class"),
    path("exam/", views.create_exam, name="Exams"),
    path("logout/", views.logout_request, name="logout"),
    path("base/", views.base, name="Base"),
  
  
]


views.py

This file lets us manage how the page will be displayed and who will be able to see the page. Also this is where we use the decorator.py to restrict access.

Python3




from datetime import date
from django.shortcuts import render
from django.contrib.auth import logout
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib import messages
from .decorator import allowed_users
  
from .models import *
from .forms import *
from .Sending_messages import *
  
  
def base(request):
    return render(request, "Teacher/base.html")
  
  
@allowed_users(allowed_roles=['admin', 'Professor'])
def home(response):
    return render(response, "Teacher/home.html")
  
  
def logout_request(request):
    logout(request)
    return render(request, "Teacher/home.html", {})
  
  
@allowed_users(allowed_roles=['admin', 'Professor'])
def index(response, id):
    a = Announcements.objects.get(id=id)
    return render(response, "Teacher/home.html", {})
  
  
@allowed_users(allowed_roles=['admin', 'Professor'])
def create_announcement(response):
    if response.method == "POST":
        form = createnewannouncement(response.POST)
  
        if form.is_valid():
            t = form.cleaned_data["text"]
            a = Announcements(text=t)
            a.save()
  
            if form.cleaned_data["check"] == True:
                send_message(t)
                messages.success(
                    response, 'Announcement was saved and messages are sent')
            else:
                messages.success(response, 'Announcement was saved')
            return render(response, "Teacher/home.html", {})
    else:
        form = createnewannouncement()
        return render(response, "Teacher/announcement.html", {"form": form})
  
  
@allowed_users(allowed_roles=['admin', 'Professor'])
def create_class(response):
    if response.method == "POST":
        form = schedule_extra_class(response.POST)
  
        if form.is_valid():
            c1 = form.cleaned_data["subject"]
            c2 = form.cleaned_data["date"]
            c3 = form.cleaned_data["time_start"]
            c4 = form.cleaned_data["time_end"]
            c = Class(subject=c1, date=c2, time_start=c3, time_end=c4)
            c.save()
            t = "You have a {0} extra class on {1} from {2} to {3}".format(
                str(c1), str(c2), str(c3), str(c4))
            if form.cleaned_data["check"] == True:
                send_message(t)
                messages.success(
                    response, 'Class is scheduled and messages are sent')
            else:
                messages.success(response, 'Class is scheduled')
            return render(response, "Teacher/home.html", {"text": t})
    else:
        form = schedule_extra_class()
        return render(response, "Teacher/class.html", {"form": form})
  
  
@allowed_users(allowed_roles=['admin', 'Professor'])
def create_exam(response):
    if response.method == "POST":
        form = schedule_exam(response.POST)
  
        if form.is_valid():
            e1 = form.cleaned_data["subject"]
            e2 = form.cleaned_data["date"]
            e3 = form.cleaned_data["time_start"]
            e4 = form.cleaned_data["time_end"]
            e = Exam(subject=e1, date=e2, time_start=e3, time_end=e4)
            e.save()
            t = "You have a {0} exam on {1} from {2} to {3}".format(
                str(e1), str(e2), str(e3), str(e4))
            if form.cleaned_data["check"] == True:
                send_message(t)
                messages.success(
                    response, 'Exam is scheduled and messages are sent')
            else:
                messages.success(response, 'Exam is scheduled')
            return render(response, "Teacher/home.html", {"text": t})
    else:
        form = schedule_exam()
        return render(response, "Teacher/exam.html", {"form": form})


 
 

HAUS Connect – Python Project

One of the most common problems faced by college students is that we have very erratic timetables and it is a cumbersome task to keep up with them, these issues have been amplified enormously during these pandemic times where everyone is on their own. The purpose of this application is to help students keep track of their classes, tests, and assignments as well as assist in streamlining communication between faculty and students. HAUS-Connect is a platform where faculty of college can schedule or reschedule the meetings or lectures, they also can set reminders for tests and upload study material too. A chatbot will help look for study material. Basically, we want to make sure that none of us miss any deadlines. At the moment this is for college students but its versatility is immense, it can be used on a large scale for communications throughout an enterprise, a single system that manages leaves granted, leave balance, pending work, etc.

Similar Reads

Features

Recorded lectures link, .ppt file, reference book pdf can be uploaded by the faculty. Time-Table modification access will be provided only to the faculty. A doubt section will be provided where a student has to upload a picture of his doubt and select the subject, a message on the faculty’s screen will pop and he further can send the solution of it. A chatbot will help look for study material A text message and email will be sent directly to all students if a faculty reschedules a particular meeting....

Tools Used:

Client-Side :...

Explanatory Diagram

Explanatory Diagram...

Login Diagram

Login Diagram...

Code flow

Code flow...

Step by Step Implementation

Broadcaster: This is the folder that contains the files for the main project....

Register App

...

Student App

...

Teachers App

This app handles the login and signup of users....

Output

...

Team members

...

Contact Us