Exemplo n.º 1
0
def get_relevant_threshold(context, score):
    if not ISurveyFeedback.providedBy(context):
        raise TypeError("context must be a SurveyFeedback object")
    thresholds = [x for x in context.values() if IFeedbackThreshold.providedBy(x)]
    for obj in sorted(thresholds, key = lambda x: x.percentage, reverse = True):
        if obj.percentage <= score:
            return obj
Exemplo n.º 2
0
 def get_thresholds(self):
     """ Returns all contained thresholds sorted on percentage. """
     return sorted(
         [x for x in self.context.values() if IFeedbackThreshold.providedBy(x)], key=lambda x: x.percentage
     )