Coverage for modules/org/openteacher/interfaces/qt/lessons/words/words : 77%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#! /usr/bin/env python3 # -*- coding: utf-8 -*-
# Copyright 2011-2013, Marten de Vries # Copyright 2011-2012, Cas Widdershoven # Copyright 2011-2012, Milan Boers # # This file is part of OpenTeacher. # # OpenTeacher is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenTeacher is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenTeacher. If not, see <http://www.gnu.org/licenses/>.
self._teachWidget.addSideWidget(widget)
self._teachWidget.removeSideWidget(widget)
def list(self):
def list(self, list):
def changed(self): return self._changed
def changed(self, value):
self.fileTab.currentTab = self._enterWidget
self._updateResultsWidget()
#close current lesson (if one). Just reuse all the logic. self.fileTab.currentTab = self._enterWidget self._tabChanged() if self.fileTab.currentTab == self._teachWidget: #the tab change wasn't allowed. return False
#ask if the user wants to save if self.changed: if not self._okToClose(parent=self.fileTab.currentTab): return False
#it's ok, just close. self.fileTab.close() self.stopped.send() return True
"""First do checks that apply to all lessons. In case they don't show any problems, the callback with word specific checks is called.
""" #FIXME > 3.1: move into separate module since this uses QtWidgets? def callback(): #words specific checks for item in self._enterWidget.lesson.list["items"]: if not item.get("questions", []) or not item.get("answers", []): QtWidgets.QMessageBox.critical( self._teachWidget, _("Empty question or answer"), _("Please enter at least one question and one answer for every word.") ) self.fileTab.currentTab = self._enterWidget break
#generic checks self._onTabChanged(self.fileTab, self._enterWidget, self._teachWidget, callback)
"all": x, "selfstudy": x, "student@home": x, "student@school": x, "teacher": x, "words-only": x, "code-documentation": x, "test-suite": x, "default": -1, } self._mm.mods(type="ui"), self._mm.mods(type="event"), self._mm.mods(type="wordsEnterer"), self._mm.mods(type="wordsTeacher"), self._mm.mods(type="lessonDialogs"), self._mm.mods(type="buttonRegister"), ) self._mm.mods(type="dataTypeIcons"), self._mm.mods(type="translator"), self._mm.mods(type="testsViewer"), )
global QtWidgets except ImportError: return
else: #reasonable priority
else:
#Translations global _ global ngettext
else: self._mm.resourcePath("translations") )
lambda self: self._modules.default(type="event").createEvent )
lambda self: self._modules.default("active", type="lessonDialogs") )
#create widgets "active", type="wordsEnterer" ).createWordsEnterer()
"active", type="wordsTeacher" ).createWordsTeacher()
self.enterWidget, self.teachWidget, ] "active", type="testsViewer" ).createTestsViewer() except IndexError: pass else:
self.fileTab, self._createEvent, self._lessonDialogs.okToClose, self._lessonDialogs.onTabChanged, *widgets )
|