Coverage for modules/org/openteacher/interfaces/qt/testMode/testSelecter/testSelecter : 49%
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-2012, Milan Boers # Copyright 2012, Marten de Vries # # 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/>.
global TestSelecter
# Parameter: The current test (tests/<id>) super().__init__(*args, **kwargs)
self.connection = connection # Are tests you already handed in answers for filtered out? self.filter = filter self.currentRowChanged.connect(self._currentRowChanged)
#retranslate fills the list self.retranslate()
# Get all tests self.testsInfo = self.connection.get("tests") self.testsInfos = []
for test in self.testsInfo: if self.filter: # Get urls of all answers for this test answersUrls = self.connection.get(test["url"] + "/answers") # Get userids of all answers for this test answersIds = map(os.path.basename, answersUrls)
if str(self.connection.userId) in answersIds: break
# Get name of this test testInfo = self.connection.get(test["url"]) testInfo["list"] = json.loads(testInfo["list"]) self.testsInfos.append(testInfo)
if "title" in testInfo["list"]: self.addItem(testInfo["list"]["title"]) else: self.addItem(_("Unnamed"))
self.clear() self._addTests()
self.testChosen.emit(self.testsInfos[index])
return self.testsInfos[self.currentRow()]
"default": 532, }
self._mm.mods(type="translator"), ) self._mm.mods(type="ui"), self._mm.mods(type="event"), self._mm.mods(type="testModeConnection"), )
global QtCore, QtWidgets except ImportError: return
#setup translation except IndexError: pass else:
global _ global ngettext
except IndexError: _, ngettext = str, lambda a, b, n: a if n == 1 else b else: self._mm.resourcePath("translations") )
selecter = ref() if selecter is not None: selecter.retranslate()
ts = TestSelecter(self.connection, filter) self._selecters.add(weakref.ref(ts)) return ts
|