Ignore:
Timestamp:
02/14/16 14:31:32 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

The student page is displayed with proper title, help and the entrance exam button updated based on the completion state of the exam (re #285)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r760 r762  
    13671367class StudentPage(Page):
    13681368    """A page displayed to students after logging in."""
     1369    _entryExamStatusQueryInterval = 60*1000
     1370
    13691371    def __init__(self, wizard):
    13701372        """Construct the student page."""
     
    13721374                                          xstr("student_title"),
    13731375                                          xstr("student_help"))
     1376
     1377        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     1378                                  xscale = 0.5, yscale = 0.0)
     1379
     1380        table = gtk.Table(1, 1)
     1381        table.set_row_spacings(4)
     1382        table.set_col_spacings(32)
     1383        alignment.add(table)
     1384        self.setMainWidget(alignment)
     1385
     1386        row = 0
     1387
     1388        buttonAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
     1389        button = self._entryExamButton = gtk.Button(xstr("student_entry_exam"))
     1390        button.set_use_underline(True)
     1391        button.connect("clicked", self._entryExamClicked)
     1392        button.set_tooltip_text(xstr("student_entry_exam_tooltip"))
     1393
     1394        buttonAlignment.add(button)
     1395        table.attach(buttonAlignment, 0, 1, 0, 1)
     1396
     1397    def activate(self):
     1398        """Activate the student page."""
     1399        loginResult = self._wizard.loginResult
     1400        self._entryExamButton.set_sensitive(not loginResult.entryExamPassed)
     1401        self._getEntryExamStatus()
     1402
     1403    def _entryExamClicked(self, button):
     1404        """Called when the entry exam button is clicked."""
     1405
     1406    def _getEntryExamStatus(self):
     1407        """Initiate the query of the entry exam status after the interval."""
     1408        gobject.timeout_add(StudentPage._entryExamStatusQueryInterval,
     1409                            lambda: self._wizard.gui.webHandler. \
     1410                            getEntryExamStatus(self._entryExamStatusCallback))
     1411
     1412    def _entryExamStatusCallback(self, returned, result):
     1413        """Called when the entry exam status is available."""
     1414        gobject.idle_add(self._handleEntryExamStatus, returned, result)
     1415
     1416    def _handleEntryExamStatus(self, returned, result):
     1417        """Called when the entry exam status is availabe."""
     1418        print "_handleEntryExamStatus", returned, result
     1419        if returned:
     1420            self._entryExamButton.set_sensitive(not result.entryExamPassed)
     1421            self._getEntryExamStatus()
    13741422
    13751423#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.