knowledge: base functionality OK
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1227 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
dc0993ecc5
commit
cc1b0e4585
3 changed files with 28 additions and 8 deletions
|
@ -49,7 +49,11 @@ programming with Python:
|
||||||
Now we can ask what knowledge john is lacking if he would like to take
|
Now we can ask what knowledge john is lacking if he would like to take
|
||||||
the position offered:
|
the position offered:
|
||||||
|
|
||||||
>>> john.getMissingKnowledge(pos01) == (ooProg, pyOo,)
|
>>> missing = john.getMissingKnowledge(pos01)
|
||||||
|
>>> missing
|
||||||
|
(<...KnowledgeElement...>, <...KnowledgeElement...>)
|
||||||
|
|
||||||
|
>>> missing == (ooProg, pyOo,)
|
||||||
True
|
True
|
||||||
|
|
||||||
Luckily there are a few elearning content objects out there that
|
Luckily there are a few elearning content objects out there that
|
||||||
|
@ -65,6 +69,10 @@ provide some of the knowledge needed:
|
||||||
So that we are now able to find out what john has to study in order to
|
So that we are now able to find out what john has to study in order to
|
||||||
fulfill the position offered:
|
fulfill the position offered:
|
||||||
|
|
||||||
>>> list(john.getProvidersNeeded(pos01))
|
>>> prov = list(john.getProvidersNeeded(pos01))
|
||||||
|
>>> len(prov)
|
||||||
|
2
|
||||||
|
>>> [d[0] for k, d in prov] == [doc01, doc02]
|
||||||
|
True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,10 +90,10 @@ class IKnowing(Interface):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getProvidersNeeded(position):
|
def getProvidersNeeded(position):
|
||||||
""" Return two tuples: first a tuple of knowledge providers that
|
""" Return a tuple of tuples: Each tuple has as its first element
|
||||||
provide knowledge needed for fulfilling the position given,
|
a requirement of the position, the second element is a tuple
|
||||||
second a tuple with the requirements that could not
|
of the knowledge providers providing this knowledge
|
||||||
be met by the available knowledge providers.
|
((requirement, (provider, ...,)), ...).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,20 @@ class Knowing(object):
|
||||||
del obj._knowers[self]
|
del obj._knowers[self]
|
||||||
|
|
||||||
def getMissingKnowledge(self, position):
|
def getMissingKnowledge(self, position):
|
||||||
# to be done
|
knowledge = self.getKnowledge()
|
||||||
return tuple(position.getRequirements())
|
missing = []
|
||||||
|
toCheck = [k for k in position.getRequirements() if k not in knowledge]
|
||||||
|
while toCheck:
|
||||||
|
k = toCheck.pop()
|
||||||
|
missing.insert(0, k)
|
||||||
|
for d in k.getDependencies():
|
||||||
|
if d in knowledge or k in toCheck:
|
||||||
|
continue
|
||||||
|
if d in missing:
|
||||||
|
# TODO: rearrange missing, but care for cycles...
|
||||||
|
continue
|
||||||
|
toCheck.append(d)
|
||||||
|
return tuple(missing)
|
||||||
|
|
||||||
def getProvidersNeeded(self, position):
|
def getProvidersNeeded(self, position):
|
||||||
return ((k, k.getProviders())
|
return ((k, k.getProviders())
|
||||||
|
|
Loading…
Add table
Reference in a new issue