Next / Previous / Contents / TCC Help System / NM Tech homepage

21. buildClassroomTable(): Build the table of classrooms

This function builds the table of classrooms, and also the room pages for each room.

hwscan3.py
# - - -   b u i l d C l a s s r o o m T a b l e

def buildClassroomTable ( parent, reportInfo, clientSet ):
    '''Build the classroom pages and the table of classrooms.

      [ (parent is an et.Element) and
        (reportInfo is a ReportInfo) and
        (clientSet is a ClientSet) ->
          parent  +:=  table of classrooms named in reportInfo, with
                       configuration data from clientSet, as links
                       to room pages for those rooms
          room pages for classrooms  +:=  tables of clients in
                                            those rooms ]
    '''

We'll start by adding the horizontal rule and subhead, then the table without the content of its tbody element.

hwscan3.py
    #-- 1 --
    # [ parent  +:=  (horizontal rule) + (subhead) ]
    parent.append ( E.hr() )
    parent.append ( E.h2 ( 'Classrooms' ) )
    parent.append ( E.p ( 'Click on the room name for a list of the '
              'workstations in that room.' ) )

For relevant constants, see Section 6.22, “TABLE_ATTRS, Section 6.23, “L_ALIGN, and Section 6.24, “R_ALIGN.

hwscan3.py
    #-- 2 --
    # [ parent  +:=  a new table element with col, thead, and
    #                an empty tbody element
    #   tbody   :=   that tbody element ]
    table  =  E.table (
        TABLE_ATTRS,
        E.col ( L_ALIGN ),
        E.col ( R_ALIGN ),
        E.col ( R_ALIGN ),
        E.thead (
            E.tr (
                E.th ( 'Room' ),
                E.th ( 'Workstations' ),
                E.th ( 'Instructor station' ) ) ) )
    parent.append ( table )
    tbody  =  et.SubElement ( table, 'tbody' )

The overall ordering of the classrooms in the classroom table is determined by reportInfo.roomMap. We'll generate the rooms in ascending order by prefix. The logic that checks to see if it's a classroom, and builds each classroom line in the table as well as the room page for that classroom, is in Section 22, “buildClassroom(): Build one classroom table line and page”.

hwscan3.py
    #-- 3 --
    # [ tbody  +:=  rows for classrooms named in reportInfo, with
    #       configuration data from clientSet, as links to room
    #       pages for those rooms
    #   room pages for those rooms  +:=  tables of clients in
    #       those rooms, with configuration data from clientSet
    #       and devices from reportInfo ]
    prefixList  =  reportInfo.roomMap.keys()
    prefixList.sort()
    for prefix in prefixList:
        #-- 3 body --
        # [ if reportInfo.roomMap[prefix] is a classroom ->
        #     tbody  +:=  a row for that classroom, with
        #         workstation and instructor station counts from
        #         clientSet, and a link to a room page for
        #         that room
        #     room page for that room  :=  table of clients in
        #         that room, with configuration data from
        #         clientSet and devices from reportInfo ]
        room  =  reportInfo.roomMap[prefix]
        if room.roomType == Room.ROOM_CLASS:
            buildClassroom ( tbody, room, reportInfo, clientSet )