Ejemplo n.º 1
0
def newcoursesedit(request):
    if request.user.is_authenticated:
        id = request.GET.get("id", None)
        if id != None:
            instance = Course.objects.get(id=id)
            form = newCourseForm(instance=instance)
            context = {
                'form': form,
                'submiturl': 'updatecourses',
                'coursesForm': True,
                'semesterRequire': not (Functions.getSemesterReq()),
                'modal': {
                    'modalicon': 'text-subject',
                    'title': 'Update Course',
                    'button': 'Update Course',
                    'style': '',
                }
            }
            return render(request,
                          'admin/includes/modalcontents/newfaculty.html',
                          context)

        #deleting record by id
        id = request.GET.get("delete", None)
        if id != None:
            instance = Course.objects.get(id=id)
            instance.delete()
            result = '<div class="alert alert-success col-12" role="alert"><i class="mdi mdi-checkbox-marked-circle-outline"></i> Course deleted successfully!</div>'
            return HttpResponse(result)

    else:
        return redirect('../login')
Ejemplo n.º 2
0
def manualscheduler(request):

    schedulerid = request.GET.get("scheduler", None)
    studentgroupid = request.GET.get("groupid", None)
    studentgroup = request.GET.get("studentgroup", None)
    print(schedulerid, ' - ', studentgroup)
    if schedulerid != None and studentgroup != None:
        instance = TablesGenerated.objects.get(groupid=studentgroupid)
        manualschedulerForm = manualSchedulerForm(instance=instance)
        result = '<div class="alert alert-danger col-12" role="alert" style="margin-bottom: 0;"><i class="mdi mdi-checkbox-marked-circle-outline"></i> Invalid request, please reload and try again!</div>'
        courseData = getCourseDataScheduler(studentgroupid)
        context = {
            'coursedata':
            courseData,
            'remarks':
            '',
            'generationForm_1':
            True,
            'generationForm':
            'True',
            'backtablescheduler':
            schedulerid,
            'backtablestudents':
            studentgroup,
            'timetabletitle':
            studentgroupid,
            'semesterRequire':
            Functions.getSemesterReq(),
            'manualschedulerForm':
            manualschedulerForm,
            'matchesSugestion':
            ManualScheduler.getAvailableMatches(schedulerid, studentgroupid,
                                                instance.venue),
            'pagedata': {
                'pageicon': 'timetable',
                # 'pagetitle': studentgroup,
            },
            'modal': {
                'modalicon': 'timetable',
                'title': 'TIMETABLE: ',  #+studentgroup,
                'button': 'Create Scheduler',
                'size': 'modal-lg'
            }
        }
        return render(request, 'admin/generator/manualscheduler.html', context)
    else:
        result = '<div class="alert alert-danger col-12" role="alert" style="margin-bottom: 0;"><i class="mdi mdi-checkbox-marked-circle-outline"></i> Invalid request, make sure Course has been scheduled and try again!</div>'
        return HttpResponse(result)
Ejemplo n.º 3
0
def index(request):
    if request.user.is_authenticated:
        form = AppSettingsForm(instance=appSettings.objects.get(id=1))
        appLecturer = list(staffTypes.objects.values())
        context = {
            'form': form,
            'appLecturer': appLecturer,
            'semesterRequire': Functions.getSemesterReq(),
            'pagedata': {
                'pageicon': 'settings-outline',
                'pagetitle': 'Other Settings',
            }
        }
        return render(request, 'admin/appsettings/index.html', context)
    else:
        return redirect('../login')
Ejemplo n.º 4
0
def openscheduler(request):
    if request.user.is_authenticated:
        id = request.GET.get("id", None)
        if id != None:
            instance = TableRegister.objects.get(code=id)
            form = generateForm(instance=instance)
            tableData = {
                'id': id,
                'gendate': getTableRegistry(id, 'gendate'),
                'semester': getTableRegistry(id, 'semestername'),
                'totalgen': getTableRegistry(id, 'totalgen'),
            }
            context = {
                'form': form,
                'tableData': tableData,
                'generationForm': True,
                'generationForm_1': True,
                'genFormDisplay': 'none',
                'genFormCardStyle': {
                    'modalbody': 'padding-bottom: 0;margin-bottom: -1px;',
                    'cardbody': 'padding-bottom: 0;',
                },
                'semesterRequire': not (Functions.getSemesterReq()),
                'submiturl': 'startgeneration',
                'modal': {
                    'modalicon': 'animation',
                    'title': 'Generate Timetable',
                    'button': 'Generate Timetables',
                }
            }

            return render(request,
                          'admin/includes/modalcontents/newfaculty.html',
                          context)

        #deleting record by id
        id = request.GET.get("delete", None)
        if id != None:
            instance = TableRegister.objects.get(code=id)
            instance.delete()
            result = '<div class="alert alert-success col-12" role="alert" style="margin-bottom: 0;"><i class="mdi mdi-checkbox-marked-circle-outline"></i> Scheduler: ' + str(
                instance) + ' deleted successfully!</div>'
            return HttpResponse(result)

    else:
        return redirect('../login')
Ejemplo n.º 5
0
def newRegistration(request):
    if request.user.is_authenticated:
        form = EnrolmentForm()
        context = {
            'form': form,
            'registrationForm': True,
            'semesterRequire': Functions.getSemesterReq(),
            'submiturl':'addRegistration',
            'modal':{
                'modalicon': 'table-row-plus-before',
                'title': 'New Course Registration',
                'button': 'Save Registration',
            }
        }
        return render(request, 'admin/includes/modalcontents/newfaculty.html', context)
    else:
        return redirect('../login')
Ejemplo n.º 6
0
def newcourses(request):
    if request.user.is_authenticated:
        form = newCourseForm()
        context = {
            'form': form,
            'coursesForm': True,
            'semesterRequire': not (Functions.getSemesterReq()),
            'submiturl': 'addcourses',
            'modal': {
                'modalicon': 'text-subject',
                'title': 'New Course',
                'button': 'Save Course',
            }
        }
        return render(request, 'admin/includes/modalcontents/newfaculty.html',
                      context)
    else:
        return redirect('../login')
Ejemplo n.º 7
0
def newgenerator(request):
    if request.user.is_authenticated:
        form = generateForm()
        context = {
            'form': form,
            'generationForm': True,
            'semesterRequire': not (Functions.getSemesterReq()),
            'genFormDisplay': '',
            'submiturl': 'addgenerator',
            'modal': {
                'modalicon': 'animation',
                'title': 'Create Scheduler',
                'button': 'Create Scheduler'
            }
        }
        return render(request, 'admin/includes/modalcontents/newfaculty.html',
                      context)
    else:
        return redirect('../login')
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        SUBJECTTYPE = Functions.subjectType()
        self.fields["subjecttype"] = forms.ChoiceField(
            label='Subject Type',
            choices=SUBJECTTYPE,
            required=True,
            widget=forms.Select(attrs={'class': 'form-control p-input'}))

        SEMESTER = Functions.getSemestersList()
        self.fields["semester"] = forms.ChoiceField(
            label='Semester',
            choices=SEMESTER,
            required=Functions.getSemesterReq(),
            widget=forms.Select(attrs={'class': 'form-control p-input'}))

        DEPARTMENTS = Functions.getDepartmentList()
        self.fields["departments"] = forms.MultipleChoiceField(
            label='Department(s)',
            choices=DEPARTMENTS,
            required=True,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'form-control p-input populate-drop',
                    'singular': '0',
                    'data-source': 'department',
                    'data-link': 'lecturers',
                    'data-live-search': 'true',
                }))

        LECTURERS = Functions.getLecturerList(
        )  #Functions.getLectConfirm(Functions.getLecturerList(), Course)
        self.fields["lecturers"] = forms.MultipleChoiceField(
            label='Lecturer(s)',
            choices=LECTURERS,
            required=False,
            widget=forms.SelectMultiple(attrs={
                'class': 'form-control p-input',
                'data-live-search': 'true'
            }))
Ejemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        newid =  Functions.getNewId(TableRegister, 'TBL', "{:07}")
        self.fields["code"].initial = newid

        SESSION = Functions.SessionList()
        self.fields["session"] = forms.ChoiceField(initial=Functions.getSettingsData('session'), choices=SESSION, required=True, widget=forms.Select(attrs={'class':'form-control p-input'}))

        SEMESTERNAME = Functions.getSemesterAlias()
        self.fields["semestername"] = forms.ChoiceField(label='Semester', initial=Functions.getSettingsData('semname'), choices=SEMESTERNAME, required=not(Functions.getSemesterReq()), widget=forms.Select(attrs={'class':'form-control p-input'}))

        SEMESTERTYPE = Functions.getSemestersList()
        self.fields["semestertype"] = forms.ChoiceField(label='Semester', initial=Functions.getSettingsData('semtype'), choices=SEMESTERTYPE, required=Functions.getSemesterReq(), widget=forms.Select(attrs={'class':'form-control p-input'}))
Ejemplo n.º 10
0
def index(request):
    if request.user.is_authenticated:

        context = {}

        scheduler = request.GET.get("viewscheduler", None)
        if scheduler == None:
            table_groups = list(TableRegister.objects.values())
            group_list = []
            rownumber = 1
            for table in table_groups:
                table['row'] = rownumber
                table['count'] = 20
                table[
                    'status'] = '<i class="mdi mdi-alert-circle text-warning"></i>'
                table['semestertype'] = Functions.getSemesterName(
                    table['semestertype'])
                group_list.append(table)
                rownumber += 1

            context = {
                'table_groups': group_list,
                'semesterRequire': Functions.getSemesterReq(),
                'pagedata': {
                    'pageicon': 'animation',
                    'pagetitle': 'Home: Schedulers',
                }
            }
            return render(request, 'admin/generator/index.html', context)

        else:
            studentgroup = request.GET.get("studentgroup", None)
            if studentgroup == None:
                style = request.GET.get("viewstyle", None)
                if style == None:
                    dfmain = pd.DataFrame(
                        list(
                            TablesGenerated.objects.values(
                                'students', 'department_id').filter(
                                    code=scheduler).order_by('department_id')))
                    df = dfmain[['students', 'department_id'
                                 ]].groupby(['students'
                                             ]).apply(lambda x: x.tail(1))
                    df['totalstudents'] = list(
                        dfmain['students'].value_counts().sort_index())
                    # print(df)
                    groupListString = ''
                    groupList = list(
                        TablesGenerated.objects.values(
                            'students',
                            'department_id').filter(code=scheduler))
                    for grp in groupList:
                        groupListString = groupListString + ',' + grp[
                            'students']
                        # print(grp)
                    groupListString = groupListString.split(",")
                    groupListString = list(sorted(set(groupListString)))
                    groupListString = filter(None, groupListString)
                    group_list = []
                    rownumber = 1

                    for group in groupListString:
                        print(group)
                        table = {}
                        table['row'] = rownumber
                        table['scheduler'] = scheduler
                        table['students'] = group
                        table['faculty'] = getTableDepartment(
                            group.split("-")[0], 'fac')
                        table['department'] = getTableDepartment(
                            group.split("-")[0], 'name')
                        table['level'] = group.split("-")[1] + '-Level'
                        table['courses'] = countStudentsGroupCourses(
                            group)['courses']
                        table['scheduled'] = countStudentsGroupCourses(
                            group)['scheduled']
                        table[
                            'status'] = '<i class="mdi mdi-alert-circle text-danger"></i>'
                        if table['scheduled'] == table['courses']:
                            table[
                                'status'] = '<i class="mdi mdi-checkbox-marked-circle text-success"><span style="display:none">4</span></i>'
                        elif table['scheduled'] / table['courses'] > 0.6:
                            table[
                                'status'] = '<i class="mdi mdi-alert-circle text-warning"><span style="display:none">3</span></i>'
                        #
                        table[
                            'semester'] = '<i class="mdi mdi-numeric-2-circle text-info" style="font-size: 20px;"><span style="display:none">2</span></>'
                        if group.split("-")[2] == '1':
                            table[
                                'semester'] = '<i class="mdi mdi-numeric-1-circle text-primary" style="font-size: 20px;"><span style="display:none">1</span></>'

                        # table['semestertype'] = Functions.getSemesterName(table['semestertype'])
                        group_list.append(table)
                        rownumber += 1

                    context = {
                        'table_groups_dpt': group_list,
                        'semesterRequire': Functions.getSemesterReq(),
                        'pagedata': {
                            'pageicon': 'animation',
                            'pagetitle': 'Timetable Generator',
                        }
                    }
                    return render(request, 'admin/generator/index.html',
                                  context)
                else:
                    dfmain = pd.DataFrame(
                        list(
                            TablesGenerated.objects.values(
                                'groupid', 'totalenrol', 'students',
                                'starttime', 'endtime', 'lecturers',
                                'lectureday', 'venue', 'course', 'remarks',
                                'status', 'department_id').filter(
                                    code=scheduler).order_by('department_id')))
                    group_list = []
                    rownumber = 1
                    # print(dfmain)
                    for group in dfmain.itertuples():
                        # print(group.course)
                        table = {}
                        table['row'] = rownumber
                        table['scheduler'] = group.groupid
                        table['student'] = []

                        Students = filter(None, group.students.split(","))
                        for stdgrp in Students:
                            StudentList = {
                                'scheduler':
                                scheduler,
                                'stdgrp':
                                stdgrp,
                                'name':
                                str(stdgrp.split("-")[1]) + '-' +
                                getTableDepartment(
                                    stdgrp.split("-")[0], 'name'),
                            }
                            table['student'].append(StudentList)

                        table['coursecode'] = getCourseData(
                            group.course, 'title'
                        ).title(
                        ) + '[' + group.course + ']'  #.code +'-'+group.course.name
                        table[
                            'lecturer'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                        if group.lecturers != '':
                            table['lecturer'] = getCourseLecturer(
                                str(group.lecturers), 'title').title(
                                ) + ' (' + group.lecturers.upper() + ')'

                        table['day'] = getFullDay(group.lectureday)
                        table['starttime'] = formatTime(group.starttime)
                        table['endtime'] = formatTime(group.endtime)
                        table[
                            'venue'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                        if group.venue != None:
                            table['venue'] = getCourseVenue(
                                group.venue, 'title').title(
                                ) + ' (' + group.venue.upper() + ')'
                        table['remarks'] = getRemarks(group.remarks,
                                                      group.status,
                                                      group.venue)
                        table[
                            'link'] = 'scheduler=' + scheduler + '&groupid=' + group.groupid + '&studentgroup=ALL'
                        group_list.append(table)
                        rownumber += 1

                    context = {
                        'table_groups_scheduler': group_list,
                        'semesterRequire': Functions.getSemesterReq(),
                        'pagedata': {
                            'pageicon': 'animation',
                            'pagetitle': 'All Schedules',
                        }
                    }
                    return render(request, 'admin/generator/index.html',
                                  context)
            else:
                dfmain = pd.DataFrame(
                    list(
                        TablesGenerated.objects.values(
                            'groupid', 'totalenrol', 'starttime', 'endtime',
                            'lecturers', 'lectureday', 'venue', 'course',
                            'remarks', 'status', 'department_id').filter(
                                code=scheduler,
                                students__contains=studentgroup).order_by(
                                    'students')))
                group_list = []
                rownumber = 1
                # tablesession = getTableData(scheduler)
                department = dfmain[['department_id']].iloc[0].department_id
                department = Functions.getDptName(
                    studentgroup.split('-')[0]).upper()
                timetabletitle = '' + studentgroup.split("-")[
                    1] + '-LEVEL ' + department + ' <br> ' + getTableRegistry(
                        scheduler, 'session') + ' [' + getTableRegistry(
                            scheduler, 'semestername') + ' ' + getSemester(
                                studentgroup.split("-")
                                [2]) + ' SEMESTER] TIMETABLE'
                for row in dfmain.itertuples():
                    table = {}
                    table['row'] = rownumber
                    table['coursecode'] = row.course
                    table['coursetitle'] = getCourseData(row.course,
                                                         'title').title()
                    table['day'] = getFullDay(row.lectureday)
                    table['start'] = formatTime(row.starttime)
                    table['end'] = formatTime(row.endtime)
                    table[
                        'lecturer'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                    if row.lecturers != '':
                        table['lecturer'] = getCourseLecturer(
                            str(row.lecturers), 'title').title(
                            ) + ' (' + row.lecturers.upper() + ')'
                    table[
                        'venue'] = '<i class="mdi mdi-alert-decagram-outline text-danger"></i>'
                    if row.venue != None:
                        table['venue'] = getCourseVenue(
                            row.venue,
                            'title').title() + ' (' + row.venue.upper() + ')'
                    table['remark'] = getRemarks(row.remarks, row.status,
                                                 row.venue)
                    table[
                        'link'] = 'scheduler=' + scheduler + '&groupid=' + row.groupid + '&studentgroup=' + studentgroup

                    # table['semestertype'] = Functions.getSemesterName(table['semestertype'])
                    group_list.append(table)
                    rownumber += 1

                context = {
                    'table_groups_dpt_view': group_list,
                    'generationForm_1': True,
                    'viewgrouptabledata': 'True',
                    'timetabletitle': timetabletitle,
                    'semesterRequire': Functions.getSemesterReq(),
                    'pagedata': {
                        'pageicon': 'timetable',
                        'pagetitle': studentgroup,
                    },
                    'modal': {
                        'modalicon': 'timetable',
                        'title': 'TIMETABLE: ' + studentgroup,
                        'button': 'Create Scheduler',
                        'size': 'modal-lg'
                    }
                }
                return render(request, 'admin/generator/viewtimetable.html',
                              context)
    else:
        return redirect('../login')