'''Enrolment display.
Web UI pages for viewing student enrolment for an offering.
'''
from operator import attrgetter
from ll.xist.ns import html
from uw.web.html.format import make_table_format, format_email, format_return, format_tabs
from uw.web.wsgi.delegate import delegate_get_post
from uw.web.wsgi.function import return_html
from .division import render_enrol_division
[docs]def get_sections (cursor, term, admin):
return cursor.execute_tuples ("select section_id, off_instruct_section_format (term_id, section_id) AS section_description, is_enrol_total from teaching_admin_section_mapping join off_instruct_section using (term_id, section_id) where (term_id, admin_id) = (%(term_id)s, %(admin_id)s) order by section_description", term_id=term.code (), admin_id=admin.admin_id)
@delegate_get_post
@return_html
def enrol_handler (cursor, term, admin, roles):
result = [format_return ('Main Menu', None, None, dot='Offering')]
problem_enrolments = format_problem_enrolments (cursor, term, admin)
if problem_enrolments:
result.append (problem_enrolments)
links = []
if 'ADMIN' in roles:
links.append (html.a ('Move Sections…', href="edit"))
if set (['ISC', 'INST']) & roles:
links.append (html.a ('Grade Revisions…', href="grades/"))
if admin.enrolment:
links.append ([
html.a ('Download Current Students', href="classlist"),
' (', admin.enrolment, ' enrolled)',
])
links.append ([
html.a ('Download Former Students', href="classlist?dropped"),
' (dropped or withdrawn since beginning of classes)',
])
if links:
result.append (html.h2 ('Quick Links'))
result.append (html.ul (html.li (link) for link in links))
sections = get_sections (cursor, term, admin)
sections_content = []
if sections:
sections_content.append (html.p ('The following enrolment sections are attached to this offering:'))
sections_content.append (format_sections (sections))
if admin.enrolment:
sections_content.append (html.p ('The enrolment numbers in this table include withdrawn students. Accordingly, their total may not match the total enrolment shown in the downloadable enrolment list above.'))
else:
sections_content.append (html.p ('The enrolment numbers shown in this table are the Quest numbers. Enrolments will be imported into this system on the first day of classes. At that time, they will become available for download at the top of this page.'))
else:
sections_content.append (html.p ('No sections are attached to this offering.'))
divisions_content, divisions_count = render_enrol_division (cursor, term, admin, roles, "division/", True)
tab_lst = [
('Divisions (%s)' % divisions_count, 'divisions', divisions_content),
('Sections (%s)' % len (sections), 'sections', sections_content)
]
result.append (format_tabs (tab_lst))
return "%s (%s) Enrollment" % (admin.admin_description, term.description ()), result