Exemple #1
0
    def setExamResults(self, data=None):

        columns_array = [
            ColumnDefn("ID", "center", 45, "exam_result_id"),
            ColumnDefn("STUDENT", "left", 130, "names"),
            ColumnDefn("CLASS", "left", 50, "form"),
        ]

        if self.parent.exam_data['subject_alias'] != "":
            if self.parent.exam_data['subject_alias'] == "All":
                subjects = getActiveSubjectAliases()
                subjects = subjects['aliases']
            else:
                subjects = [self.parent.exam_data['subject_alias']]

            for i, val in enumerate(subjects):  # adding columns dynamically
                col = ColumnDefn(subjects[i].upper(), "left", 55, subjects[i])
                columns_array.append(col)

            if self.parent.exam_data['subject_alias'] == "All":
                mean = ColumnDefn("MEAN", "left", 55, "student_mean")
                columns_array.append(mean)

        self.resultsOLV.SetColumns(columns_array)

        self.resultsOLV.SetObjects(self.results)
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.parent = parent

        subject_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.subject_label = wx.StaticText(self, wx.ID_ANY, u"Select Subject",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.subject_label.Wrap(-1)
        subject_sizer.Add(self.subject_label, 1, wx.ALL, 5)

        self.subjects = getActiveSubjectAliases()

        subject_choices = self.subjects['names']
        subject_choices.append("All Subjects")

        self.subject_name = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString,
                                        wx.DefaultPosition, wx.DefaultSize,
                                        subject_choices, wx.CB_READONLY)
        subject_sizer.Add(self.subject_name, 2, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(subject_sizer)
        self.Layout()

        # Connect Events
        self.subject_name.Bind(wx.EVT_COMBOBOX, self.parent.subjectSelected)
Exemple #3
0
    def updateResultsOLV(self, event):
        subjects = []
        if self.parent.exam_data['subject_alias'] != "":
            if self.parent.exam_data['subject_alias'] == "All":
                subjects = getActiveSubjectAliases()
                subjects = subjects['aliases']
            else:
                subjects = [self.parent.exam_data['subject_alias']]

        data = getExamResults(self.parent.exam_data, subjects)
        self.resultsOLV.SetObjects(data)
    def setExamResults(self, data=None):

        columns_array = [
            ColumnDefn("Mean/Deviation", "left", 250, "subject"),
        ]

        if self.parent.exam_data['subject_alias'] != "":
            if self.parent.exam_data['subject_alias'] == "All":
                subjects = getActiveSubjectAliases()
                subjects = subjects['aliases']
            else:
                subjects = [self.parent.exam_data['subject_alias']]

            for i, val in enumerate(subjects):  # adding columns dynamically
                col = ColumnDefn(subjects[i].upper(), "left", 55, subjects[i])
                columns_array.append(col)

            if self.parent.exam_data['subject_alias'] == "All":
                mean = ColumnDefn("MEAN GRADE", "left", 100, "mean_grade")
                columns_array.append(mean)

        self.resultsOLV.SetColumns(columns_array)

        self.resultsOLV.SetObjects(self.results)
    def __init__(self, parent, mean, exam_data, deviation):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        self.parent = parent
        self.mean = mean
        self.exam_data = exam_data
        self.deviation = deviation

        if self.exam_data['class_id'] == 0:
            exam_title = "FORM " + str(
                self.exam_data['form']
            ) + ", " + self.exam_data['exam_name'] + " Exam"
        else:
            exam_title = "FORM " + str(
                self.exam_data['form']
            ) + " " + self.exam_data['class_name'] + ", " + self.exam_data[
                'exam_name'] + " Exam"

        self.exam_title = exam_title.upper()
        self.term = "TERM " + self.exam_data['term'].upper()
        self.year = str(self.exam_data['year'])

        self.class_id = ""

        if self.parent.exam_data['subject_alias'] == "":
            self.subjects = []
        elif self.parent.exam_data['subject_alias'] == "All":
            subjects = getActiveSubjectAliases()
            self.subjects = subjects['aliases']
        else:
            self.subjects = [self.parent.exam_data['subject_alias']]

        self.results = allSubjectsMean(self.parent.exam_data, self.subjects,
                                       self.parent.prev_exam_data)

        self.resultsOLV = ObjectListView(self,
                                         wx.ID_ANY,
                                         style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.setExamResults()

        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # Sizer that contains titles at the top
        title_sizer = wx.BoxSizer(wx.HORIZONTAL)

        # space before title starts
        self.spacer_title = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.spacer_title.Wrap(-1)
        self.spacer_title.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.spacer_title, 1, wx.ALL, 5)

        # Exam name
        self.exam_title_text = wx.StaticText(self, wx.ID_ANY, self.exam_title,
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.exam_title_text.Wrap(-1)
        self.exam_title_text.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.exam_title_text, 0, wx.ALL, 5)

        # Term exam was taken
        self.term_title = wx.StaticText(self, wx.ID_ANY, self.term,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.term_title.Wrap(-1)
        self.term_title.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.term_title, 0, wx.ALL, 5)

        # Year exam was taken
        self.year_title = wx.StaticText(self, wx.ID_ANY, self.year,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.year_title.Wrap(-1)
        self.year_title.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.year_title, 0, wx.ALL, 5)

        # space after title ends
        self.right_spacer_title = wx.StaticText(self, wx.ID_ANY,
                                                wx.EmptyString,
                                                wx.DefaultPosition,
                                                wx.DefaultSize, 0)
        self.right_spacer_title.Wrap(-1)
        self.right_spacer_title.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.right_spacer_title, 1, wx.ALL, 5)

        mainSizer.Add(title_sizer, 0, wx.EXPAND, 5)

        #
        #
        mainSizer.Add(self.resultsOLV, 0, wx.ALL | wx.EXPAND, 5)

        examStatsSizer = wx.BoxSizer(wx.VERTICAL)

        #
        # MEAN SIZER
        mean_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.mean_label = wx.StaticText(self, wx.ID_ANY, u"Class Mean:",
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.mean_label.Wrap(-1)
        self.mean_label.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        mean_sizer.Add(self.mean_label, 1, wx.ALL, 5)

        self.mean_text = wx.StaticText(self, wx.ID_ANY, self.mean,
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        self.mean_text.Wrap(-1)
        self.mean_text.SetFont(wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        mean_sizer.Add(self.mean_text, 2, wx.ALL, 5)

        examStatsSizer.Add(mean_sizer, 0, wx.EXPAND, 5)

        #
        # DEVIATION
        deviation_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.dev_label = wx.StaticText(self, wx.ID_ANY, u"Deviation:",
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        self.dev_label.Wrap(-1)
        self.dev_label.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        deviation_sizer.Add(self.dev_label, 1, wx.ALL, 5)

        self.dev_text = wx.StaticText(self, wx.ID_ANY, str(self.deviation),
                                      wx.DefaultPosition, wx.DefaultSize, 0)
        self.dev_text.Wrap(-1)
        self.dev_text.SetFont(wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        deviation_sizer.Add(self.dev_text, 2, wx.ALL, 5)

        examStatsSizer.Add(deviation_sizer, 0, wx.EXPAND, 5)

        mainSizer.Add(examStatsSizer, 1, wx.EXPAND, 5)

        self.SetSizer(mainSizer)
    def getResults(self, event):
        # To get mean of most previous exam

        # 1. Get previous exam's details if comparison exam not selected

        if self.comparison_panel.comparison_exam_name.GetCurrentSelection(
        ) == -1:  # Not selected
            prev_exam_details = getPreviousExam(self.exam_data)

            if prev_exam_details:
                self.prev_exam_data = {
                    "year": prev_exam_details['year'],
                    "term": prev_exam_details['term'],
                    "exam_id": prev_exam_details['exam_id'],
                    "exam_name": prev_exam_details['exam_name'],
                    "form": prev_exam_details['form'],
                    "class_id": self.exam_data['class_id'],
                    "class_name": self.exam_data['class_name'],
                    "subject_alias": self.exam_data['subject_alias'],
                }

        else:
            self.prev_exam_data = {
                "year": self.prev_exam_data['year'],
                "term": self.prev_exam_data['term'],
                "exam_id": self.prev_exam_data['exam_id'],
                "exam_name": self.prev_exam_data['exam_name'],
                "form": self.prev_exam_data['form'],
                "class_id": self.exam_data['class_id'],
                "class_name": self.exam_data['class_name'],
                "subject_alias": self.exam_data['subject_alias'],
            }

        # check if there are results
        if self.exam_data["subject_alias"] == "All":
            subjects = getActiveSubjectAliases()
            subjects = subjects['aliases']

            mean = getClassMean(self.exam_data, subjects)

            prev_mean = getClassMean(self.prev_exam_data, subjects)

            # get deviation before concatenating grade to mean
            deviation = calculateDeviation(prev_mean, mean)

            mean = getGradePlusMark(mean)

        else:
            subjects = [self.exam_data["subject_alias"]]

            mean = getSubjectMean(self.exam_data)

            prev_mean = getSubjectMean(self.prev_exam_data)

            # get deviation before concatenating grade to mean
            deviation = calculateDeviation(prev_mean, mean)

            mean = getGradePlusMark(mean)

        exam_data = getExamResults(self.exam_data, subjects)

        # Check whether the main exam selected has results
        if exam_data:

            # check whether there's an prev exam id to compare results with
            if self.prev_exam_data['exam_id']:

                # Check whether the comparison exam selected has results
                if getExamResults(self.prev_exam_data, subjects):

                    if self.results_panel_created == 0:
                        self.show_results = ViewResults(
                            self, mean, self.exam_data, deviation)
                        self.right_container.Add(self.show_results, 1,
                                                 wx.ALL | wx.EXPAND, 15)

                        self.Layout()

                        self.results_panel_created = 1

                    else:
                        self.show_results.Destroy()
                        self.show_results = ViewResults(
                            self, mean, self.exam_data, deviation)
                        self.right_container.Add(self.show_results, 1,
                                                 wx.ALL | wx.EXPAND, 15)

                        self.Layout()

                    self.show_results.setExamResults()
                    self.show_results.updateResultsOLV("")

                else:
                    dlg = wx.MessageDialog(
                        None,
                        "No results in comparison exam. Try a different exam.",
                        'Error Message.', wx.OK | wx.ICON_ERROR)
                    dlg.ShowModal()
                    dlg.Destroy()

            else:
                # Ask user to select comparison exam if the drop down has data
                if len(self.comparison_panel.comparisonExamNames):  # Has data
                    dlg = wx.MessageDialog(
                        None, "Please select exam to compare results with.",
                        'Message.', wx.OK | wx.ICON_INFORMATION)
                    dlg.ShowModal()
                    dlg.Destroy()

                else:  # Else ask them to try a diff exam
                    dlg = wx.MessageDialog(
                        None,
                        "There is no exam to compare results with. \nTry a different exam.",
                        'Error Message.', wx.OK | wx.ICON_ERROR)
                    dlg.ShowModal()
                    dlg.Destroy()

        else:
            dlg = wx.MessageDialog(
                None, "No results found. Try a different class/exam.",
                'Error Message.', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
Exemple #7
0
    def downloadMarkSheet(self, event):
        # Set up the variables
        logo = u"images\\appIcon-96x96.bmp"
        school_name = "KANGANGU SECONDARY SCHOOL"
        po_box = "P.O. BOX 183 - 01020 KENOL"
        term = self.term
        year = self.year
        exam_name = self.exam_title
        # exam_name = "END TERM" + " REPORT" + "     " + term + "     " + year
        # exam_name = self.pdf_title
        #
        # if 'Form' in self.exam_data['class_name']:
        #     exam_name = " " + self.exam_data['exam_name'] + " RESULTS"
        # else:
        #     if self.exam_data['class_id'] == 0:
        #         exam_name = " " + self.exam_data['exam_name'] + " RESULTS"
        #     else:
        #         exam_name = str(self.exam_data['form']) + " " + self.exam_data['class_name'] + " " + self.exam_data[
        #             'exam_name'] + " RESULTS"

        file_name_exam_name = exam_name.title() + " " + term.title(
        ) + " " + year
        exam_name = exam_name.upper(
        ) + "               " + term + "      " + year

        #
        #
        #

        # Get path that the report card should be saved to
        path = os.path.join(os.environ['HOME'] + "\Downloads\\")
        download_file_name = file_name_exam_name + " Marksheet.pdf"

        full_name = path + download_file_name

        if os.path.isfile(full_name):
            expand = 0
            while True:
                expand += 1
                new_file_name = full_name.split(".pdf")[0] + "(" + str(
                    expand) + ").pdf"  # eg ..card(1).pdf
                if os.path.isfile(new_file_name):
                    continue
                else:
                    full_name = new_file_name
                    break

        #
        #
        #

        subjects = []
        if self.parent.exam_data['subject_alias'] != "":
            if self.parent.exam_data['subject_alias'] == "All":
                subjects = getActiveSubjectAliases()
                subjects = subjects['aliases']
            else:
                subjects = [self.parent.exam_data['subject_alias']]

        results = getExamResults(self.parent.exam_data, subjects)

        #
        # TABLE DATA
        #

        first_table_row = ['POS', 'ADM', 'STUDENT', 'CLASS']

        for subject in subjects:
            first_table_row.append(subject.upper())

        if len(subjects) > 1:
            first_table_row.append('MEAN')

        tableData = [first_table_row]

        for result in results:
            row = [
                result['number'], result['reg_no'], result['names'],
                result['form']
            ]

            for subject in subjects:
                row.append(result[subject])

            if len(subjects) > 1:
                row.append(result['student_mean'])

            tableData.append(row)

        #
        #
        #

        doc = SimpleDocTemplate(full_name,
                                pagesize=(11 * inch, 8.5 * inch),
                                rightMargin=72,
                                leftMargin=72,
                                topMargin=8,
                                bottomMargin=18)

        # Register Helvetica bold font
        helvetica_bold_font = r"F:/PythonApps/Kangangu/fonts/Helvetica Bold.ttf"
        pdfmetrics.registerFont(TTFont("Helvetica-Bold", helvetica_bold_font))

        # Register Helvetica normal font
        helvetica_normal_font = r"F:/PythonApps/Kangangu/fonts/Helvetica-Normal.ttf"
        pdfmetrics.registerFont(
            TTFont("Helvetica-Normal", helvetica_normal_font))

        Story = []

        im = Image(
            logo, 1 * inch,
            1 * inch)  # two inches from the top and two inches from the left.
        Story.append(im)

        styles = getSampleStyleSheet()
        styles.add(ParagraphStyle(name='Center', alignment=TA_CENTER))
        # bold_center = ParagraphStyle(name="myStyle", alignment="TA_CENTER", fontName="Helvetica-Bold")

        ptext = '<font name ="Helvetica-Bold" size=14>%s</font>' % school_name
        Story.append(Paragraph(ptext, style=styles['Center']))

        Story.append(Spacer(1, 10))
        ptext = '<font name ="Helvetica-Bold" size=12>%s</font>' % po_box
        Story.append(Paragraph(ptext, styles["Center"]))

        Story.append(Spacer(1, 10))
        ptext = '<font name ="Helvetica-Bold" size=12>%s</font>' % exam_name
        Story.append(Paragraph(ptext, styles["Center"]))
        Story.append(Spacer(1, 15))

        styleSheet = getSampleStyleSheet()

        style = [
            ('LINEABOVE', (0, 0), (-1, -1), 0.75, colors.black),
            ('LINEAFTER', (0, 0), (-1, -1), 0.75, colors.black),
            ('BOX', (0, 0), (-1, -1), 0.5, colors.black),
            # ('ALIGN', (1, 0), (-1, -1), 'CENTER'),
            ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'
             ),  # Make first row Bold
            ('LEFTPADDING', (0, 0), (-1, -1), 3),
            ('RIGHTPADDING', (0, 0), (-1, -1), 3),
        ]
        table = Table(tableData)
        table.setStyle(TableStyle(style))

        Story.append(table)

        doc.build(Story)

        dlg = wx.MessageDialog(None, "Marksheet saved in downloads folder.",
                               'Success Message', wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()
Exemple #8
0
    def editTeacher(self, event):
        self.edit_teacher.Enable(False)

        user_id = self.user_id.GetLineText(0)
        first_name = self.first_name.GetLineText(0)
        last_name = self.last_name.GetLineText(0)
        surname = self.surname.GetLineText(0)
        email = self.email.GetLineText(0)
        username = self.username.GetLineText(0)
        dob = self.dob.GetValue()
        genderIndex = self.gender.GetCurrentSelection()
        subjectOneIndex = self.subject.GetCurrentSelection()
        subjectTwoIndex = self.subject2.GetCurrentSelection()

        # Remove white spaces
        first_name = first_name.replace(" ", "")
        last_name = last_name.replace(" ", "")
        surname = surname.replace(" ", "")
        email = email.replace(" ", "")
        username = username.replace(" ", "")

        #
        # ---------- VALIDATION ----------
        error = ""

        if user_id == "":  # Check that a teacher has been selected before starting validation
            dlg = wx.MessageDialog(None, "Please select a teacher to edit.",
                                   'Validation Error', wx.OK | wx.ICON_WARNING)
            dlg.ShowModal()
            dlg.Destroy()

        else:
            if first_name == "" or last_name == "" or surname == "":
                error = error + "All name fields are required.\n"

            if self.hasNumbers(first_name) or self.hasNumbers(
                    last_name) or self.hasNumbers(surname):
                error = error + "Names cannot have numeric characters.\n"

            if email == "":
                error = error + "The Email Address field is required.\n"

            if not re.match(r"[^@]+@[^@]+\.[^@]+", email):
                error = error + "Enter a valid email address.\n"

            if username == "":
                error = error + "The Username field is required.\n"

            # check that date has been changed
            td = datetime.today()

            # get wxPython datetime format
            day = td.day
            month = td.month
            year = td.year

            # -1 because the month counts from 0, whereas people count January as month #1.
            tdFormatted = wx.DateTimeFromDMY(day, month - 1, year)
            if str(dob) == str(tdFormatted):
                error = error + "The Date of Birth field is required.\n"

            if genderIndex == -1:
                error = error + "The Gender field is required.\n"

            if subjectOneIndex == -1:
                error = error + "The Subject 1 field is required.\n"
            else:
                if subjectOneIndex == subjectTwoIndex:
                    error = error + "The Subject 2 field must be different from Subject 1 field .\n"

            if error:
                dlg = wx.MessageDialog(None, error, 'Validation Error',
                                       wx.OK | wx.ICON_WARNING)
                dlg.ShowModal()
                dlg.Destroy()

            else:
                dob = str(dob)[:-9]
                dob = datetime.strptime(dob, "%d/%m/%Y").date()

                gen = self.gender.GetString(genderIndex)

                if gen == "Male":
                    gender = "M"
                else:
                    gender = "F"

                subjects = getActiveSubjectAliases()
                subject_ids = subjects['ids']
                subjectOneid = subject_ids[subjectOneIndex]

                if subjectTwoIndex == -1:
                    subjectTwoid = None
                else:
                    subjectTwoid = subject_ids[subjectTwoIndex]

                data = {
                    "user_id": user_id,
                    "first_name": first_name.lower().capitalize(),
                    "last_name": last_name.lower().capitalize(),
                    "surname": surname.lower().capitalize(),
                    "email": email,
                    "username": username,
                    "dob": dob,
                    "gender": gender,
                    "subjectOneID": subjectOneid,
                    "subjectTwoID": subjectTwoid
                }

                if editTeacher(data):
                    dlg = wx.MessageDialog(None,
                                           "Teacher edited Successfully.",
                                           'Success Message',
                                           wx.OK | wx.ICON_INFORMATION)
                    dlg.ShowModal()
                    dlg.Destroy()
                    self.cancelEdit("")
                    self.updateControl("")
                else:
                    dlg = wx.MessageDialog(None, "Edit failed. Try Again.",
                                           'Failed', wx.OK | wx.ICON_ERROR)
                    dlg.ShowModal()
                    dlg.Destroy()

        self.edit_teacher.Enable(True)
Exemple #9
0
    def fetchExamResults(self, event):
        if not self.examsOLV.GetSelectedObject():
            dlg = wx.MessageDialog(
                None, "Click on a row first in order to view exam results.",
                'Error Message.', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
        else:
            rowObj = self.examsOLV.GetSelectedObject()

            form = getFormsInExam(rowObj['exam_id'])

            if form == "All":
                choices = [u"Form 1", u"Form 2", u"Form 3", u"Form 4"]

                formChosen = wx.GetSingleChoice(
                    message="Select Form to View Results",
                    caption="Exam Results.",
                    choices=choices,
                    parent=None)
            else:
                formChosen = form

            if formChosen == "Form 1" or formChosen == "One":
                formChosen = 1
            elif formChosen == "Form 2" or formChosen == "Two":
                formChosen = 2
            elif formChosen == "Form 3" or formChosen == "Three":
                formChosen = 3
            elif formChosen == "Form 4" or formChosen == "Four":
                formChosen = 4

            subjectChoices = getActiveSubjectAliases()
            subjectChoices = subjectChoices['aliases']
            subjectChoices.insert(0, "All Subjects")

            subjectChosen = wx.GetSingleChoice(message="Select Subject.",
                                               caption="Exam Results.",
                                               choices=subjectChoices,
                                               parent=None)

            if subjectChosen == "All Subjects":
                alias = "All"
                subjects = getActiveSubjectAliases()
                subjects = subjects['aliases']
            else:
                alias = subjectChosen
                subjects = [subjectChosen]

            self.exam_data = {
                "exam_id": rowObj['exam_id'],
                "class_id": 0,
                "form": formChosen,
                "subject_alias": alias,
                "year": rowObj['year'],
                "term": rowObj['term'],
                "exam_name": rowObj['exam_name'],
            }

            data = getExamResults(self.exam_data, subjects)
            if data:
                self.edit_exam_panel.Hide()
                # self.show_results.Hide()
                #
                # self.show_results = ViewResults(self, self.exam_data)
                # self.show_results.setExamResults()
                # self.show_results.updateResultsOLV("")
                # self.show_results.Show()
                #
                # self.Layout()

                if self.show_results_panel_added == 0:
                    self.show_results = ViewResults(self, self.exam_data)
                    self.right_sizer.Add(self.show_results, 1, wx.EXPAND)

                    self.Layout()

                    self.show_results_panel_added = 1
                else:
                    self.show_results.Destroy()
                    self.show_results = ViewResults(self, self.exam_data)
                    self.right_sizer.Add(self.show_results, 1, wx.EXPAND)

                    self.Layout()
            else:
                dlg = wx.MessageDialog(None, "No results for selected exam.",
                                       'Error Message.', wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()

                self.show_results.Hide()
                self.edit_exam_panel.Show()

                self.Layout()
Exemple #10
0
    def __init__(self, parent, student):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.Size(500, 300),
                          style=wx.TAB_TRAVERSAL)

        self.student = student

        container = wx.BoxSizer(wx.VERTICAL)

        # self.progress_report_label = wx.StaticText(self, wx.ID_ANY, u"Progress Report", wx.DefaultPosition,
        #                                            wx.DefaultSize, wx.ALIGN_CENTRE)
        # self.progress_report_label.Wrap(-1)
        # self.progress_report_label.SetFont(wx.Font(12, 70, 90, 92, False, wx.EmptyString))
        #
        # container.Add(self.progress_report_label, 0, wx.ALL | wx.EXPAND, 10)

        title_sizer = wx.BoxSizer(wx.HORIZONTAL)

        title_sizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)

        self.progress_report_label = wx.StaticText(self, wx.ID_ANY,
                                                   u"Progress Report",
                                                   wx.DefaultPosition,
                                                   wx.DefaultSize,
                                                   wx.ALIGN_CENTRE)
        self.progress_report_label.Wrap(-1)
        self.progress_report_label.SetFont(
            wx.Font(12, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.progress_report_label, 1, wx.TOP | wx.EXPAND, 5)

        self.download_btn = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(u"images/download_pdf.bmp", wx.BITMAP_TYPE_ANY),
            wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | wx.NO_BORDER)
        self.download_btn.SetDefault()
        title_sizer.Add(self.download_btn, 0, wx.TOP | wx.RIGHT | wx.LEFT, 10)

        container.Add(title_sizer, 0, wx.EXPAND, 5)

        outer_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.left_sizer = wx.BoxSizer(wx.VERTICAL)

        form_choices = []
        if student['form'] == 1:
            form_choices = [u"One"]
        elif student['form'] == 2:
            form_choices = [u"Two", u"One"]
        elif student['form'] == 3:
            form_choices = [u"Three", u"Two", u"One"]
        elif student['form'] == 4:
            form_choices = [u"Four", u"Three", u"Two", u"One"]

        self.select_form = SelectForm(self, form_choices)
        self.left_sizer.Add(self.select_form, 0, wx.EXPAND | wx.ALL, 5)

        self.select_exam_panel = SelectExam(self, student['form'],
                                            int(datetime.now().year))
        self.left_sizer.Add(self.select_exam_panel, 0, wx.EXPAND | wx.ALL, 5)

        self.exam_data = {
            "exam_id": 0,
            "exam_name": "",
            'term': "",
            'year': 0,
            'student_id': student['user_id'],
            "form": str(student['form']),
            'class_id': student['class_id'],
        }

        self.subjects = getActiveSubjectAliases()
        self.subjects_aliases = self.subjects['aliases']
        self.subjects_names = self.subjects['names']
        self.subjects_ids = self.subjects['ids']
        self.compulsory = self.subjects['compulsory']

        outer_sizer.Add(self.left_sizer, 0, wx.EXPAND, 5)

        right_sizer = wx.BoxSizer(wx.VERTICAL)

        self.sbSizer13 = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, wx.EmptyString), wx.VERTICAL)

        # Get exam to preload on the marks panel
        exam = getExamsInFormAndYear(student['form'], int(datetime.now().year))

        # If there's an exam id in the array, get results, else use dummy data
        if len(exam['ids']):

            exam_id = exam['ids'][0]
            exam_name = exam['exam_names'][0]
            exam_term = exam['terms'][0]
            exam_year = exam['years'][0]

            self.exam_data['exam_id'] = exam_id
            self.exam_data['exam_name'] = exam_name
            self.exam_data['term'] = exam_term
            self.exam_data['year'] = exam_year

            results = getResultsByStudentAndExamID(self.exam_data,
                                                   self.subjects_aliases,
                                                   self.subjects_names,
                                                   self.subjects_ids,
                                                   self.compulsory)
        else:
            # Sample data to prevent error on first load
            oneSubjectResult = {
                'subject': "",
                'mean': "",
                'grade': "",
                'rank': ""
            }
            results = {
                'exam_result_id': 0,
                'student_id': 0,
                'exam_id': 0,
                'form': 0,
                'form_pos': 0,
                'class_pos': 0,
                'total': 0,
                'points': 0,
                'mean': 0,
                'mean_grade': 0,
                'subjectData': [oneSubjectResult],
                'students_in_class': 0,
                'students_in_form': 0,
            }

        self.marks_panel = MarksPanel(self, results)
        self.sbSizer13.Add(self.marks_panel, 1, wx.EXPAND, 5)

        right_sizer.Add(self.sbSizer13, 1,
                        wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 15)

        outer_sizer.Add(right_sizer, 1, wx.EXPAND, 5)

        container.Add(outer_sizer, 1, wx.EXPAND, 5)

        self.SetSizer(container)
        self.Layout()

        # Connect Events
        self.download_btn.Bind(wx.EVT_BUTTON, self.downloadReportCard)
Exemple #11
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.parent = parent

        subject_sizer = wx.BoxSizer(wx.VERTICAL)

        self.subject_label = wx.StaticText(self, wx.ID_ANY, u"Select Subject",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.subject_label.Wrap(-1)
        subject_sizer.Add(self.subject_label, 0, wx.ALL, 5)

        self.subjects = {
            'names': [],
            'aliases': [],
            'ids': [],
            'compulsory': []
        }

        # subject_choices = []

        # This page can be viewed by admins and teachers

        # If admin is logged in, show all subjects
        if self.parent.userdata['role'] == 'admin':
            self.subjects = getActiveSubjectAliases()

        # If a teacher is logged in, show the subjects they teach only
        elif self.parent.userdata['role'] == 'teacher':
            # populate combo box with subjects the teacher logged in teaches
            teacher_subject_data = getSubjectsByTeacher(
                self.parent.userdata['user_id'])

            # subject_choices.append(teacher_subject_data['subject_alias1'])
            self.subjects['ids'].append(teacher_subject_data['subject_id1'])
            self.subjects['names'].append(
                teacher_subject_data['subject_name1'])
            self.subjects['aliases'].append(
                teacher_subject_data['subject_alias1'])
            self.subjects['compulsory'].append(
                teacher_subject_data['subject1compulsory'])

            if teacher_subject_data['subject_id2'] is not None:
                # subject_choices.append(teacher_subject_data['subject_alias2'])

                self.subjects['ids'].append(
                    teacher_subject_data['subject_id2'])
                self.subjects['names'].append(
                    teacher_subject_data['subject_name2'])
                self.subjects['aliases'].append(
                    teacher_subject_data['subject_alias2'])
                self.subjects['compulsory'].append(
                    teacher_subject_data['subject2compulsory'])

        subject_choices = self.subjects['names']

        self.subject_name = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString,
                                        wx.DefaultPosition, wx.DefaultSize,
                                        subject_choices, wx.CB_READONLY)
        subject_sizer.Add(self.subject_name, 0, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(subject_sizer)
        self.Layout()

        # Connect Events
        self.subject_name.Bind(wx.EVT_COMBOBOX, self.parent.subjectSelected)
Exemple #12
0
    def __init__(self, parent, mean, exam_data, deviation, mostImprovedData):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        self.parent = parent
        self.mean = mean
        self.exam_data = exam_data
        self.deviation = deviation

        if mostImprovedData:
            mostImprovedLabel = ""
            if mostImprovedData['nature'] == "Decline":
                mostImprovedLabel = "Least Drop: (All Dropped)"
            elif mostImprovedData['nature'] == "Improve":
                mostImprovedLabel = "Most Improved:"

            mostImprovedStud = ""

            for item in mostImprovedData['student_id']:
                student = getStudentByID(item)
                student_name = student['full_names'] + ", " + str(
                    student['form']) + " " + student['class'] + "\n"
                mostImprovedStud = mostImprovedStud + student_name

            mostImprvdPts = str(mostImprovedData['mark']) + " Points"

        if 'Form' in self.exam_data['class_name']:
            exam_title = "              " + self.exam_data[
                'exam_name'] + " RESULTS"
        else:
            if self.exam_data['class_id'] == 0:
                exam_title = "              " + self.exam_data[
                    'exam_name'] + " RESULTS"
            else:
                exam_title = str(
                    self.exam_data['form']) + " " + self.exam_data[
                        'class_name'] + "              " + self.exam_data[
                            'exam_name'] + " RESULTS"

        self.exam_title = exam_title.upper()
        self.term = "TERM " + self.exam_data['term'].upper()
        self.year = str(self.exam_data['year'])

        self.class_id = ""

        if self.parent.exam_data['subject_alias'] == "":
            self.subjects = []
        elif self.parent.exam_data['subject_alias'] == "All":
            subjects = getActiveSubjectAliases()
            self.subjects = subjects['aliases']
        else:
            self.subjects = [self.parent.exam_data['subject_alias']]

        self.results = getExamResults(self.parent.exam_data, self.subjects)

        self.resultsOLV = ObjectListView(self,
                                         wx.ID_ANY,
                                         style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.setExamResults()

        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # Sizer that contains titles at the top
        title_sizer = wx.BoxSizer(wx.HORIZONTAL)

        # space before title starts
        self.spacer_title = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.spacer_title.Wrap(-1)
        self.spacer_title.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.spacer_title, 1, wx.ALL, 5)

        # Exam name
        self.exam_title_text = wx.StaticText(self, wx.ID_ANY, self.exam_title,
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.exam_title_text.Wrap(-1)
        self.exam_title_text.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.exam_title_text, 3, wx.ALL, 5)

        # space before term, after exam name
        self.before_term_spacer = wx.StaticText(self, wx.ID_ANY,
                                                wx.EmptyString,
                                                wx.DefaultPosition,
                                                wx.DefaultSize, 0)
        self.before_term_spacer.Wrap(-1)
        self.before_term_spacer.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.before_term_spacer, 1, wx.ALL, 5)

        # Term exam was taken
        self.term_title = wx.StaticText(self, wx.ID_ANY, self.term,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.term_title.Wrap(-1)
        self.term_title.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.term_title, 1, wx.ALL, 5)

        # space after term, before year
        self.before_yr_spacer = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                              wx.DefaultPosition,
                                              wx.DefaultSize, 0)
        self.before_yr_spacer.Wrap(-1)
        self.before_yr_spacer.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.before_yr_spacer, 1, wx.ALL, 5)

        # Year exam was taken
        self.year_title = wx.StaticText(self, wx.ID_ANY, self.year,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.year_title.Wrap(-1)
        self.year_title.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.year_title, 0, wx.ALL, 5)

        # space after  year
        self.after_yr_spacer = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.after_yr_spacer.Wrap(-1)
        self.after_yr_spacer.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.after_yr_spacer, 1, wx.ALL, 5)

        # Download Button
        self.download_pdf_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(u"images/download_pdf.bmp", wx.BITMAP_TYPE_ANY),
            wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | wx.NO_BORDER)
        title_sizer.Add(self.download_pdf_button, 0, wx.RIGHT | wx.LEFT, 10)

        mainSizer.Add(title_sizer, 0, wx.EXPAND, 5)

        #
        #
        mainSizer.Add(self.resultsOLV, 2, wx.ALL | wx.EXPAND, 5)

        examStatsSizer = wx.BoxSizer(wx.VERTICAL)

        #
        # MEAN SIZER
        mean_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.mean_label = wx.StaticText(self, wx.ID_ANY, u"Class Mean:",
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.mean_label.Wrap(-1)
        self.mean_label.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        mean_sizer.Add(self.mean_label, 1, wx.ALL, 5)

        self.mean_text = wx.StaticText(self, wx.ID_ANY, self.mean,
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        self.mean_text.Wrap(-1)
        self.mean_text.SetFont(wx.Font(10, 70, 90, 90, False, wx.EmptyString))

        mean_sizer.Add(self.mean_text, 4, wx.ALL, 5)

        examStatsSizer.Add(mean_sizer, 0, wx.EXPAND, 5)

        #
        # DEVIATION
        if deviation:
            deviation_sizer = wx.BoxSizer(wx.HORIZONTAL)

            self.dev_label = wx.StaticText(self, wx.ID_ANY, u"Deviation:",
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
            self.dev_label.Wrap(-1)
            self.dev_label.SetFont(
                wx.Font(10, 70, 90, 92, False, wx.EmptyString))

            deviation_sizer.Add(self.dev_label, 1, wx.ALL, 5)

            self.dev_text = wx.StaticText(self, wx.ID_ANY, str(self.deviation),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
            self.dev_text.Wrap(-1)
            self.dev_text.SetFont(
                wx.Font(10, 70, 90, 90, False, wx.EmptyString))

            deviation_sizer.Add(self.dev_text, 4, wx.ALL, 5)

            examStatsSizer.Add(deviation_sizer, 0, wx.EXPAND, 5)

        # Show only if there are points in mostImprovedData['mark']
        if mostImprovedData and mostImprovedData['mark'] != "--":
            #
            # MOST IMPROVED STUDENT
            most_improved_sizer = wx.BoxSizer(wx.HORIZONTAL)

            self.most_improved_label = wx.StaticText(self, wx.ID_ANY,
                                                     mostImprovedLabel,
                                                     wx.DefaultPosition,
                                                     wx.DefaultSize, 0)
            self.most_improved_label.Wrap(-1)
            self.most_improved_label.SetFont(
                wx.Font(10, 70, 90, 92, False, wx.EmptyString))

            most_improved_sizer.Add(self.most_improved_label, 1, wx.ALL, 5)

            self.most_improved_text = wx.StaticText(self, wx.ID_ANY,
                                                    mostImprovedStud,
                                                    wx.DefaultPosition,
                                                    wx.DefaultSize,
                                                    wx.TE_MULTILINE)
            self.most_improved_text.Wrap(-1)
            self.most_improved_text.SetFont(
                wx.Font(10, 70, 90, 90, False, wx.EmptyString))

            most_improved_sizer.Add(self.most_improved_text, 1, wx.ALL, 5)

            self.most_improved_points = wx.StaticText(self, wx.ID_ANY,
                                                      mostImprvdPts,
                                                      wx.DefaultPosition,
                                                      wx.DefaultSize, 0)
            self.most_improved_points.Wrap(-1)
            self.most_improved_points.SetFont(
                wx.Font(10, 70, 90, 92, False, wx.EmptyString))

            most_improved_sizer.Add(self.most_improved_points, 3, wx.ALL, 5)

            examStatsSizer.Add(most_improved_sizer, 0, wx.EXPAND, 5)

        mainSizer.Add(examStatsSizer, 1, wx.EXPAND, 5)

        self.SetSizer(mainSizer)

        # Connect events
        self.download_pdf_button.Bind(wx.EVT_BUTTON, self.downloadReportCard)
Exemple #13
0
    def getResults(self, event):
        # To get mean of most previous exam
        # 1. Get previous exam's exam_id
        prev_exam_dets = getPreviousExam(self.exam_data)

        # If
        if prev_exam_dets:
            # Switch exam id
            prev_exam_data = {
                "year": prev_exam_dets['year'],
                "term": prev_exam_dets['term'],
                "exam_id": prev_exam_dets['exam_id'],
                "exam_name": prev_exam_dets['exam_name'],
                "form": prev_exam_dets['form'],
                "class_id": self.exam_data['class_id'],
                "class_name": self.exam_data['class_name'],
                "subject_alias": self.exam_data['subject_alias'],
            }

        # check if there are results
        if self.exam_data["subject_alias"] == "All":
            subjects = getActiveSubjectAliases()
            subjects = subjects['aliases']

            mean = getClassMean(self.exam_data, subjects)

            if prev_exam_dets:
                prev_mean = getClassMean(prev_exam_data, subjects)

                # get deviation before concatenating grade to mean
                deviation = calculateDeviation(prev_mean, mean)
            else:
                deviation = ""

            mean = getGradePlusMark(mean)

        else:
            subjects = [self.exam_data["subject_alias"]]

            mean = getSubjectMean(self.exam_data)

            if prev_exam_dets:
                prev_mean = getSubjectMean(prev_exam_data)

                # get deviation before concatenating grade to mean
                deviation = calculateDeviation(prev_mean, mean)
            else:
                deviation = ""

            mean = getGradePlusMark(mean)

        exam_data = getExamResults(self.exam_data, subjects)

        if prev_exam_dets:
            mostImproved = getMostImproved(prev_exam_data, self.exam_data,
                                           subjects)
        else:
            mostImproved = ""

        if exam_data:
            if self.results_panel_created == 0:
                self.show_results = ViewResults(self, mean, self.exam_data,
                                                deviation, mostImproved)
                self.right_container.Add(self.show_results, 1,
                                         wx.ALL | wx.EXPAND, 8)

                self.Layout()

                self.results_panel_created = 1
            else:
                self.show_results.Destroy()
                self.show_results = ViewResults(self, mean, self.exam_data,
                                                deviation, mostImproved)
                self.right_container.Add(self.show_results, 1,
                                         wx.ALL | wx.EXPAND, 8)

                self.Layout()

            self.show_results.setExamResults()
            self.show_results.updateResultsOLV("")
        else:
            dlg = wx.MessageDialog(None,
                                   "No results found. Try a different class.",
                                   'Error Message.', wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            self.select_class.class_name.SetSelection(-1)
Exemple #14
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(665, 855),
                          style=wx.TAB_TRAVERSAL)

        container = wx.BoxSizer(wx.VERTICAL)

        self.m_staticText17 = wx.StaticText(self, wx.ID_ANY, u"Add New Teacher", wx.DefaultPosition, wx.DefaultSize,
                                            wx.ALIGN_CENTRE)
        self.m_staticText17.Wrap(-1)
        self.m_staticText17.SetFont(wx.Font(14, 70, 90, 92, False, wx.EmptyString))

        container.Add(self.m_staticText17, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 15)

        bSizer27 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer28 = wx.BoxSizer(wx.VERTICAL)

        self.m_staticText30 = wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_staticText30.Wrap(-1)
        bSizer28.Add(self.m_staticText30, 0, wx.ALL, 5)

        bSizer27.Add(bSizer28, 1, wx.EXPAND, 5)

        bSizer36 = wx.BoxSizer(wx.VERTICAL)

        sbSizer2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"Add Teacher Form"), wx.VERTICAL)

        wrapper_sizer = wx.BoxSizer(wx.HORIZONTAL)

        left_controls_sizer = wx.BoxSizer(wx.VERTICAL)

        fname_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.fname_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"First Name", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.fname_label.Wrap(-1)
        fname_sizer.Add(self.fname_label, 1, wx.ALL, 8)

        self.first_name = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                      wx.DefaultSize, 0)
        fname_sizer.Add(self.first_name, 3, wx.ALL, 5)

        left_controls_sizer.Add(fname_sizer, 1, wx.ALL | wx.EXPAND | wx.TOP, 5)

        lname_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.lname_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Last Name", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.lname_label.Wrap(-1)
        lname_sizer.Add(self.lname_label, 1, wx.ALL, 8)

        self.last_name = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                     wx.DefaultSize, 0)
        lname_sizer.Add(self.last_name, 3, wx.ALL, 5)

        left_controls_sizer.Add(lname_sizer, 1, wx.ALL | wx.EXPAND, 5)

        surname_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.surname_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Surname", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.surname_label.Wrap(-1)
        surname_sizer.Add(self.surname_label, 1, wx.ALL, 8)

        self.surname = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                   wx.DefaultSize, 0)
        surname_sizer.Add(self.surname, 3, wx.ALL, 5)

        left_controls_sizer.Add(surname_sizer, 1, wx.ALL | wx.EXPAND, 5)

        email_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.email_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Email Address", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.email_label.Wrap(-1)
        email_sizer.Add(self.email_label, 1, wx.ALL, 8)

        self.email = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                 0)
        email_sizer.Add(self.email, 3, wx.ALL, 5)

        left_controls_sizer.Add(email_sizer, 1, wx.ALL | wx.EXPAND, 5)

        phone_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.phone_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Phone Number", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.phone_label.Wrap(-1)
        phone_sizer.Add(self.phone_label, 1, wx.ALL, 8)

        self.phone = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                 0)
        phone_sizer.Add(self.phone, 3, wx.ALL, 5)

        left_controls_sizer.Add(phone_sizer, 1, wx.ALL | wx.EXPAND, 5)

        address_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.address_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Postal Address", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.address_label.Wrap(-1)
        address_sizer.Add(self.address_label, 1, wx.ALL, 8)

        self.address = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                 0)
        address_sizer.Add(self.address, 3, wx.ALL, 5)

        left_controls_sizer.Add(address_sizer, 1, wx.ALL | wx.EXPAND, 5)



        national_id_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.national_id_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"National ID", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.national_id_label.Wrap(-1)
        national_id_sizer.Add(self.national_id_label, 1, wx.ALL, 8)

        self.national_id = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                 0)
        national_id_sizer.Add(self.national_id, 3, wx.ALL, 5)

        left_controls_sizer.Add(national_id_sizer, 1, wx.ALL | wx.EXPAND, 5)

        tsc_no_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.tsc_no_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"TSC Number", wx.DefaultPosition,
                                         wx.DefaultSize, 0)
        self.tsc_no_label.Wrap(-1)
        tsc_no_sizer.Add(self.tsc_no_label, 1, wx.ALL, 8)

        self.tsc_no = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,
                                 0)
        tsc_no_sizer.Add(self.tsc_no, 3, wx.ALL, 5)

        left_controls_sizer.Add(tsc_no_sizer, 1, wx.ALL | wx.EXPAND, 5)

        wrapper_sizer.Add(left_controls_sizer, 1, wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.TOP, 10)

        #
        #
        #

        right_controls_sizer = wx.BoxSizer(wx.VERTICAL)

        username_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.username_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Username", wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.username_label.Wrap(-1)
        username_sizer.Add(self.username_label, 1, wx.ALL, 8)

        self.username = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                    wx.DefaultSize, 0)
        username_sizer.Add(self.username, 3, wx.ALL, 5)

        right_controls_sizer.Add(username_sizer, 1, wx.ALL | wx.EXPAND, 5)

        password_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.password_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Password", wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.password_label.Wrap(-1)
        password_sizer.Add(self.password_label, 1, wx.ALL, 8)

        self.password = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                    wx.DefaultSize, wx.TE_PASSWORD)
        password_sizer.Add(self.password, 3, wx.ALL, 5)

        right_controls_sizer.Add(password_sizer, 1, wx.ALL | wx.EXPAND, 5)

        conf_pwd_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.conf_pwd_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Confirm Password", wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.conf_pwd_label.Wrap(-1)
        conf_pwd_sizer.Add(self.conf_pwd_label, 1, wx.ALL, 8)

        self.conf_password = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                         wx.DefaultSize, wx.TE_PASSWORD)
        conf_pwd_sizer.Add(self.conf_password, 3, wx.ALL, 5)

        right_controls_sizer.Add(conf_pwd_sizer, 1, wx.ALL | wx.EXPAND, 5)

        gender_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.gender_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Gender", wx.DefaultPosition,
                                          wx.DefaultSize, 0)
        self.gender_label.Wrap(-1)
        gender_sizer.Add(self.gender_label, 1, wx.ALL, 8)

        genderChoices = [u"Male", u"Female"]
        self.gender = wx.ComboBox(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Female", wx.DefaultPosition, wx.DefaultSize,
                                  genderChoices, wx.CB_READONLY)
        self.gender.SetSelection(-1)
        gender_sizer.Add(self.gender, 3, wx.ALL, 5)

        right_controls_sizer.Add(gender_sizer, 1, wx.ALL | wx.EXPAND, 5)

        dob_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.dob_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Date of Birth", wx.DefaultPosition,
                                       wx.DefaultSize, 0)
        self.dob_label.Wrap(-1)
        dob_sizer.Add(self.dob_label, 1, wx.ALL, 8)

        self.dob = wx.DatePickerCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.DefaultDateTime, wx.DefaultPosition,
                                     wx.DefaultSize, wx.DP_DEFAULT | wx.DP_DROPDOWN)
        dob_sizer.Add(self.dob, 3, wx.ALL, 5)

        right_controls_sizer.Add(dob_sizer, 1, wx.ALL | wx.EXPAND, 5)

        subject_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.subject_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Subject 1", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.subject_label.Wrap(-1)
        subject_sizer.Add(self.subject_label, 1, wx.ALL, 8)

        subjects = getActiveSubjectAliases()
        subjectChoices = subjects['names']
        self.subject = wx.ComboBox(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                   wx.DefaultSize, subjectChoices, wx.CB_READONLY)
        self.subject.SetSelection(-1)
        subject_sizer.Add(self.subject, 3, wx.ALL, 5)

        right_controls_sizer.Add(subject_sizer, 1, wx.ALL | wx.EXPAND, 5)

        subject2_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.subject2_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Subject 2", wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.subject2_label.Wrap(-1)
        subject2_sizer.Add(self.subject2_label, 1, wx.ALL, 8)

        subject2Choices = subjects['names']
        self.subject2 = wx.ComboBox(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                    wx.DefaultSize, subject2Choices, wx.CB_READONLY)
        self.subject2.SetSelection(-1)
        subject2_sizer.Add(self.subject2, 3, wx.ALL, 5)

        right_controls_sizer.Add(subject2_sizer, 1, wx.ALL | wx.EXPAND, 5)

        wrapper_sizer.Add(right_controls_sizer, 1, wx.BOTTOM | wx.EXPAND | wx.RIGHT | wx.TOP, 10)

        sbSizer2.Add(wrapper_sizer, 1, wx.EXPAND, 5)

        btns_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.btn_spacer = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition,
                                        wx.DefaultSize, 0)
        self.btn_spacer.Wrap(-1)
        btns_sizer.Add(self.btn_spacer, 1, wx.ALL, 5)

        self.cancel_btn = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Cancel", wx.DefaultPosition, wx.DefaultSize,
                                    0)
        btns_sizer.Add(self.cancel_btn, 0, wx.BOTTOM | wx.LEFT | wx.RIGHT, 15)

        self.save_teacher = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY, u"Save", wx.DefaultPosition, wx.DefaultSize,
                                      0)
        btns_sizer.Add(self.save_teacher, 0, wx.RIGHT, 25)

        sbSizer2.Add(btns_sizer, 0, wx.BOTTOM | wx.EXPAND, 25)

        bSizer36.Add(sbSizer2, 1, wx.ALL | wx.EXPAND, 10)

        self.below_form_spacer = wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
        self.below_form_spacer.Wrap(-1)
        bSizer36.Add(self.below_form_spacer, 0, wx.ALL, 5)

        bSizer27.Add(bSizer36, 2, wx.EXPAND, 5)

        bSizer281 = wx.BoxSizer(wx.VERTICAL)

        self.m_staticText31 = wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_staticText31.Wrap(-1)
        bSizer281.Add(self.m_staticText31, 0, wx.ALL, 5)

        bSizer27.Add(bSizer281, 1, wx.EXPAND, 5)

        container.Add(bSizer27, 1, wx.EXPAND, 5)

        self.SetSizer(container)
        self.Layout()

        # Connect Events
        self.cancel_btn.Bind(wx.EVT_BUTTON, self.cancelAddTeacher)
        self.save_teacher.Bind(wx.EVT_BUTTON, self.saveTeacher)
Exemple #15
0
    def __init__(self, parent, exam_dets):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        self.parent = parent
        self.exam_dets = exam_dets

        exam_title = "FORM " + str(
            self.exam_dets['form']
        ) + "              " + self.exam_dets['exam_name'] + " RESULTS"

        self.exam_title = exam_title.upper()
        self.term = "TERM " + self.exam_dets['term'].upper()
        self.year = str(self.exam_dets['year'])

        self.class_id = ""
        # subjects = getActiveSubjectAliases()
        # self.subjects = subjects['aliases']

        if self.parent.exam_data['subject_alias'] == "":
            self.subjects = []
        elif self.parent.exam_data['subject_alias'] == "All":
            subjects = getActiveSubjectAliases()
            self.subjects = subjects['aliases']
        else:
            self.subjects = [self.parent.exam_data['subject_alias']]

        self.results = getExamResults(self.parent.exam_data, self.subjects)

        self.resultsOLV = ObjectListView(self,
                                         wx.ID_ANY,
                                         style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.setExamResults()

        # Create some sizers
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        #
        #
        #
        # Sizer that contains titles at the top
        title_sizer = wx.BoxSizer(wx.HORIZONTAL)

        # space before title starts
        self.spacer_title = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.spacer_title.Wrap(-1)
        self.spacer_title.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.spacer_title, 1, wx.ALL, 5)

        # Exam name
        self.exam_title_text = wx.StaticText(self, wx.ID_ANY, self.exam_title,
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.exam_title_text.Wrap(-1)
        self.exam_title_text.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.exam_title_text, 3, wx.ALL, 5)

        # space before term, after exam name
        self.before_term_spacer = wx.StaticText(self, wx.ID_ANY,
                                                wx.EmptyString,
                                                wx.DefaultPosition,
                                                wx.DefaultSize, 0)
        self.before_term_spacer.Wrap(-1)
        self.before_term_spacer.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.before_term_spacer, 1, wx.ALL, 5)

        # Term exam was taken
        self.term_title = wx.StaticText(self, wx.ID_ANY, self.term,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.term_title.Wrap(-1)
        self.term_title.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.term_title, 1, wx.ALL, 5)

        # space after term, before year
        self.before_yr_spacer = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                              wx.DefaultPosition,
                                              wx.DefaultSize, 0)
        self.before_yr_spacer.Wrap(-1)
        self.before_yr_spacer.SetFont(
            wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.before_yr_spacer, 1, wx.ALL, 5)

        # Year exam was taken
        self.year_title = wx.StaticText(self, wx.ID_ANY, self.year,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.year_title.Wrap(-1)
        self.year_title.SetFont(wx.Font(10, 70, 90, 92, False, wx.EmptyString))

        title_sizer.Add(self.year_title, 0, wx.ALL, 5)

        # Download Button
        self.download_pdf_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(u"images/download_pdf.bmp", wx.BITMAP_TYPE_ANY),
            wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | wx.NO_BORDER)
        title_sizer.Add(self.download_pdf_button, 0, wx.RIGHT | wx.LEFT, 10)
        self.download_pdf_button.Bind(wx.EVT_BUTTON, self.downloadMarkSheet)

        mainSizer.Add(title_sizer, 0, wx.ALL | wx.EXPAND, 5)

        #
        #
        #

        mainSizer.Add(self.resultsOLV, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(mainSizer)
Exemple #16
0
    def saveTeacher(self, event):
        self.save_teacher.Enable(False)

        first_name = self.first_name.GetLineText(0)
        last_name = self.last_name.GetLineText(0)
        surname = self.surname.GetLineText(0)
        email = self.email.GetLineText(0)
        phone = self.phone.GetLineText(0)
        address = self.address.GetLineText(0)
        national_id = self.national_id.GetLineText(0)
        tsc_no = self.tsc_no.GetLineText(0)
        username = self.username.GetLineText(0)
        password = self.password.GetLineText(0)
        conf_password = self.conf_password.GetLineText(0)
        dob = self.dob.GetValue()
        genderIndex = self.gender.GetCurrentSelection()
        subjectOneIndex = self.subject.GetCurrentSelection()
        subjectTwoIndex = self.subject2.GetCurrentSelection()

        # Remove white spaces
        first_name = first_name.replace(" ", "")
        last_name = last_name.replace(" ", "")
        surname = surname.replace(" ", "")
        email = email.replace(" ", "")
        phone = phone.replace(" ", "")
        # address = address.replace(" ", "")
        national_id = national_id.replace(" ", "")
        tsc_no = tsc_no.replace(" ", "")
        username = username.replace(" ", "")
        password = password.replace(" ", "")
        conf_password = conf_password.replace(" ", "")

        #
        # ---------- VALIDATION ----------
        error = ""

        if first_name == "" or last_name == "" or surname == "":
            error = error + "All name fields are required.\n"

        if self.hasNumbers(first_name) or self.hasNumbers(last_name) or self.hasNumbers(surname):
            error = error + "Names cannot have numeric characters.\n"

        if email == "":
            error = error + "The Email Address field is required.\n"
        else:
            if not re.match(r"[^@]+@[^@]+\.[^@]+", email):
                error = error + "Enter a valid email address.\n"

        if phone == "":
            error = error + "The Phone Number field is required.\n"
        else:
            if not phone.isdigit():
                error = error + "The Phone Number field must contain only numbers.\n"

            if len(phone) != 10:
                error = error + "The Phone Number field expects ten numbers.\n"

        if address == "":
            error = error + "The Postal Address field is required.\n"

        if national_id == "":
            error = error + "The National ID field is required.\n"

        if tsc_no == "":
            error = error + "The TSC Number field is required.\n"

        if username == "":
            error = error + "The Username field is required.\n"

        if password == "":
            error = error + "The Password field is required.\n"

        if conf_password == "":
            error = error + "The Confirm Password field is required.\n"

        if conf_password != password:
            error = error + "Passwords do not match.\n"
        else:
            if len(password) < 5:
                error = error + "The Password should have at least 5 characters.\n"

        # check that date has been changed
        td = datetime.today()

        # get wxPython datetime format
        day = td.day
        month = td.month
        year = td.year

        # -1 because the month counts from 0, whereas people count January as month #1.
        tdFormatted = wx.DateTimeFromDMY(day, month - 1, year)
        if str(dob) == str(tdFormatted):
            error = error + "The Date of Birth field is required.\n"

        if genderIndex == -1:
            error = error + "The Gender field is required.\n"

        if subjectOneIndex == -1:
            error = error + "The Subject 1 field is required.\n"
        else:
            if subjectOneIndex == subjectTwoIndex:
                error = error + "The Subject 2 field must be different from Subject 1 field .\n"

        if error:
            dlg = wx.MessageDialog(None, error, 'Validation Error', wx.OK | wx.ICON_WARNING)
            dlg.ShowModal()
            dlg.Destroy()

        else:
            gen = self.gender.GetString(genderIndex)

            if gen == "Male":
                gender = "M"
            else:
                gender = "F"

            subjects = getActiveSubjectAliases()
            subject_ids = subjects['ids']
            subjectOneid = subject_ids[subjectOneIndex]

            if subjectTwoIndex == -1:
                subjectTwoid = None
            else:
                subjectTwoid = subject_ids[subjectTwoIndex]

            data = {
                "first_name": first_name.lower().capitalize(),
                "last_name": last_name.lower().capitalize(),
                "surname": surname.lower().capitalize(),
                "email": email,
                "phone": phone,
                "address": address,
                "national_id": national_id,
                "tsc_no": tsc_no,
                "username": username,
                "password": password,
                "dob": dob,
                "gender": gender,
                "subjectOneID": subjectOneid,
                "subjectTwoID": subjectTwoid
            }

            if saveTeacher(data):
                dlg = wx.MessageDialog(None, "Teacher Added Successfully.", 'Success Message',
                                       wx.OK | wx.ICON_INFORMATION)
                dlg.ShowModal()
                dlg.Destroy()
                self.cancelAddTeacher("")
            else:
                dlg = wx.MessageDialog(None, "Teacher Not Saved. Try Again.", 'Failed',
                                       wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()

        self.save_teacher.Enable(True)
Exemple #17
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        # Create some sizers
        container = wx.BoxSizer(wx.VERTICAL)

        self.m_staticText17 = wx.StaticText(self, wx.ID_ANY, u"View Teachers",
                                            wx.DefaultPosition, wx.DefaultSize,
                                            wx.ALIGN_CENTRE)
        self.m_staticText17.Wrap(-1)
        self.m_staticText17.SetFont(
            wx.Font(14, 70, 90, 92, False, wx.EmptyString))

        container.Add(self.m_staticText17, 0,
                      wx.TOP | wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 25)

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)

        left_sizer = wx.BoxSizer(wx.HORIZONTAL)

        #
        #
        # Search container
        # ----------------------------------------------------------------------------------
        #

        search_container = wx.BoxSizer(wx.HORIZONTAL)

        self.refresh_btn = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(u"images/reload_16x16.bmp", wx.BITMAP_TYPE_ANY),
            wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW)

        self.refresh_btn.SetBitmapHover(
            wx.Bitmap(u"images/reload_16x16_rotated.bmp", wx.BITMAP_TYPE_ANY))
        search_container.Add(self.refresh_btn, 0,
                             wx.BOTTOM | wx.LEFT | wx.RIGHT, 5)

        self.m_staticText53 = wx.StaticText(self, wx.ID_ANY, wx.EmptyString,
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)
        self.m_staticText53.Wrap(-1)
        search_container.Add(self.m_staticText53, 1, wx.ALL, 5)

        self.search_teachers = wx.SearchCtrl(self, wx.ID_ANY, wx.EmptyString,
                                             wx.DefaultPosition,
                                             wx.DefaultSize,
                                             wx.TE_PROCESS_ENTER)
        self.search_teachers.ShowSearchButton(True)
        self.search_teachers.ShowCancelButton(False)
        search_container.Add(self.search_teachers, 0, wx.BOTTOM | wx.RIGHT, 8)

        self.search_teachers.Bind(wx.EVT_TEXT, self.searchTeachers)
        self.search_teachers.Bind(wx.EVT_TEXT_ENTER, self.searchTeachers)

        tableSizer = wx.BoxSizer(wx.VERTICAL)

        tableSizer.Add(search_container, 0, wx.EXPAND, 5)

        #
        #
        self.products = getTeachers()

        self.dataOlv = ObjectListView(self,
                                      wx.ID_ANY,
                                      style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.setBooks()

        tableSizer.Add(self.dataOlv, 1, wx.ALL, 5)

        left_sizer.Add(tableSizer, 1, wx.ALL | wx.EXPAND, 5)

        # -------------------------------------------------------------------------
        # BUTTONS ON RIGHT OF TABLE
        # -------------------------------------------------------------------------

        left_btns_sizer = wx.BoxSizer(wx.VERTICAL)

        self.edit_class_btn = wx.Button(self, wx.ID_ANY, u"Edit Teacher",
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.edit_class_btn.Bind(wx.EVT_BUTTON, self.getTeacherInfo)
        left_btns_sizer.Add(self.edit_class_btn, 0,
                            wx.EXPAND | wx.BOTTOM | wx.RIGHT | wx.LEFT, 5)

        self.delete_class_btn = wx.Button(self, wx.ID_ANY, u"Delete",
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.delete_class_btn.Bind(wx.EVT_BUTTON, self.deleteStudent)
        left_btns_sizer.Add(self.delete_class_btn, 0, wx.ALL | wx.EXPAND, 5)

        left_sizer.Add(left_btns_sizer, 0, wx.ALL, 5)

        # -------------------------------------------------------------------------
        # BUTTONS ON RIGHT OF TABLE
        # -------------------------------------------------------------------------

        editFormSizer = wx.BoxSizer(wx.VERTICAL)

        #
        #
        #
        #
        # EDIT FORM
        sbSizer2 = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, u"Edit Teacher Form"), wx.VERTICAL)

        #
        bSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.user_id = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                   wx.EmptyString, wx.DefaultPosition,
                                   wx.DefaultSize, 0)
        self.user_id.Hide()
        bSizer.Add(self.user_id, 4, wx.ALL, 5)
        #

        sbSizer2.Add(bSizer, 1, wx.ALL | wx.EXPAND | wx.TOP, 10)

        fname_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText29 = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                            u"First Name", wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.m_staticText29.Wrap(-1)
        fname_sizer.Add(self.m_staticText29, 1, wx.ALL, 8)

        self.first_name = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                      wx.EmptyString, wx.DefaultPosition,
                                      wx.DefaultSize, 0)
        fname_sizer.Add(self.first_name, 3, wx.ALL, 5)

        sbSizer2.Add(fname_sizer, 1, wx.ALL | wx.EXPAND | wx.TOP, 7)

        lname_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText292 = wx.StaticText(sbSizer2.GetStaticBox(),
                                             wx.ID_ANY, u"Last Name",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.m_staticText292.Wrap(-1)
        lname_sizer.Add(self.m_staticText292, 1, wx.ALL, 8)

        self.last_name = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                     wx.EmptyString, wx.DefaultPosition,
                                     wx.DefaultSize, 0)
        lname_sizer.Add(self.last_name, 3, wx.ALL, 5)

        sbSizer2.Add(lname_sizer, 1, wx.ALL | wx.EXPAND, 7)

        surname_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText293 = wx.StaticText(sbSizer2.GetStaticBox(),
                                             wx.ID_ANY, u"Surname",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.m_staticText293.Wrap(-1)
        surname_sizer.Add(self.m_staticText293, 1, wx.ALL, 8)

        self.surname = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                   wx.EmptyString, wx.DefaultPosition,
                                   wx.DefaultSize, 0)
        surname_sizer.Add(self.surname, 3, wx.ALL, 5)

        sbSizer2.Add(surname_sizer, 1, wx.ALL | wx.EXPAND, 7)

        email_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                          u"Email Address", wx.DefaultPosition,
                                          wx.DefaultSize, 0)
        self.m_staticText.Wrap(-1)
        email_sizer.Add(self.m_staticText, 1, wx.ALL, 8)

        self.email = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                 wx.EmptyString, wx.DefaultPosition,
                                 wx.DefaultSize, 0)
        email_sizer.Add(self.email, 3, wx.ALL, 5)

        sbSizer2.Add(email_sizer, 1, wx.ALL | wx.EXPAND, 7)

        username_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText1 = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                           u"Username", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.m_staticText1.Wrap(-1)
        username_sizer.Add(self.m_staticText1, 1, wx.ALL, 8)

        self.username = wx.TextCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                    wx.EmptyString, wx.DefaultPosition,
                                    wx.DefaultSize, 0)
        username_sizer.Add(self.username, 3, wx.ALL, 5)

        sbSizer2.Add(username_sizer, 1, wx.ALL | wx.EXPAND, 7)

        dob_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText291 = wx.StaticText(sbSizer2.GetStaticBox(),
                                             wx.ID_ANY, u"Date of Birth",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.m_staticText291.Wrap(-1)
        dob_sizer.Add(self.m_staticText291, 1, wx.ALL, 8)

        self.dob = wx.DatePickerCtrl(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                     wx.DefaultDateTime, wx.DefaultPosition,
                                     wx.DefaultSize,
                                     wx.DP_DEFAULT | wx.DP_DROPDOWN)
        dob_sizer.Add(self.dob, 3, wx.ALL, 5)

        sbSizer2.Add(dob_sizer, 1, wx.ALL | wx.EXPAND, 7)

        gender_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText294 = wx.StaticText(sbSizer2.GetStaticBox(),
                                             wx.ID_ANY, u"Gender",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        self.m_staticText294.Wrap(-1)
        gender_sizer.Add(self.m_staticText294, 1, wx.ALL, 8)

        genderChoices = [u"Male", u"Female"]
        self.gender = wx.ComboBox(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                  u"Female", wx.DefaultPosition,
                                  wx.DefaultSize, genderChoices,
                                  wx.CB_READONLY)
        self.gender.SetSelection(-1)
        gender_sizer.Add(self.gender, 3, wx.ALL, 5)

        sbSizer2.Add(gender_sizer, 1, wx.ALL | wx.EXPAND, 7)

        #
        #
        #

        subject_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText2951 = wx.StaticText(sbSizer2.GetStaticBox(),
                                              wx.ID_ANY, u"Subject 1",
                                              wx.DefaultPosition,
                                              wx.DefaultSize, 0)
        self.m_staticText2951.Wrap(-1)
        subject_sizer.Add(self.m_staticText2951, 1, wx.ALL, 8)

        subjects = getActiveSubjectAliases()

        subjectChoices = subjects['aliases']
        self.subject = wx.ComboBox(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                   wx.EmptyString, wx.DefaultPosition,
                                   wx.DefaultSize, subjectChoices,
                                   wx.CB_READONLY)
        self.subject.SetSelection(-1)
        subject_sizer.Add(self.subject, 3, wx.ALL, 5)

        sbSizer2.Add(subject_sizer, 1, wx.ALL | wx.EXPAND, 7)

        #

        subject2_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.subject2_label = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                            u"Subject 2", wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.subject2_label.Wrap(-1)
        subject2_sizer.Add(self.subject2_label, 1, wx.ALL, 8)

        subject2Choices = subjects['aliases']
        self.subject2 = wx.ComboBox(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                    wx.EmptyString, wx.DefaultPosition,
                                    wx.DefaultSize, subject2Choices,
                                    wx.CB_READONLY)
        self.subject2.SetSelection(-1)
        subject2_sizer.Add(self.subject2, 3, wx.ALL, 5)

        sbSizer2.Add(subject2_sizer, 1, wx.ALL | wx.EXPAND, 7)

        btns_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText22 = wx.StaticText(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                            wx.EmptyString, wx.DefaultPosition,
                                            wx.DefaultSize, 0)
        self.m_staticText22.Wrap(-1)
        btns_sizer.Add(self.m_staticText22, 1, wx.ALL, 5)

        self.cancel_btn = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                    u"Cancel", wx.DefaultPosition,
                                    wx.DefaultSize, 0)
        btns_sizer.Add(self.cancel_btn, 0, wx.ALL, 5)

        self.edit_teacher = wx.Button(sbSizer2.GetStaticBox(), wx.ID_ANY,
                                      u"Save", wx.DefaultPosition,
                                      wx.DefaultSize, 0)
        btns_sizer.Add(self.edit_teacher, 0, wx.ALL, 5)

        sbSizer2.Add(btns_sizer, 3, wx.ALL | wx.EXPAND, 7)

        self.edit_teacher.Bind(wx.EVT_BUTTON, self.editTeacher)
        self.cancel_btn.Bind(wx.EVT_BUTTON, self.cancelEdit)

        editFormSizer.Add(sbSizer2, 1, wx.TOP | wx.EXPAND, 5)

        #
        #
        #

        mainSizer.Add(left_sizer, 1, wx.ALL | wx.EXPAND, 8)
        mainSizer.Add(editFormSizer, 1,
                      wx.TOP | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 8)

        container.Add(mainSizer, 1, wx.ALL, 5)

        self.SetSizer(container)

        self.refresh_btn.Bind(wx.EVT_BUTTON, self.refreshTable)