Example #1
0
    def context(self):
        context_template = self.my_badge_type.context
        if context_template == None:
            context_template = u"  This puts you in the top {in_the_top_percentile}% of researchers."

        inverse_percentiles = ["reading_level"]
        if self.name in inverse_percentiles:
            if u"{percentile}" in context_template:
                if self.display_percentile > 50:
                    return None
            if u"{in_the_top_percentile}" in context_template:
                if self.display_in_the_top_percentile < 50:
                    return None

        else:
            if u"{percentile}" in context_template:
                if self.display_percentile < 50:
                    return None
            if u"{in_the_top_percentile}" in context_template:
                if self.display_in_the_top_percentile > 50:
                    return None

        context_string = context_template.format(
            value=conversational_number(self.value),
            one_hundred_minus_value=conversational_number(100 - self.value),
            in_the_top_percentile=self.display_in_the_top_percentile,
            percentile=self.display_percentile)

        return context_string
Example #2
0
    def context(self):
        context_template = self.my_badge_type.context
        if context_template == None:
            context_template = u"  This puts you in the top {in_the_top_percentile}% of researchers."

        inverse_percentiles = ["reading_level"]
        if self.name in inverse_percentiles:
            if u"{percentile}" in context_template:
                if self.display_percentile > 50:
                    return None
            if u"{in_the_top_percentile}" in context_template:
                if self.display_in_the_top_percentile < 50:
                    return None

        else:
            if u"{percentile}" in context_template:
                if self.display_percentile < 50:
                    return None
            if u"{in_the_top_percentile}" in context_template:
                if self.display_in_the_top_percentile > 50:
                    return None

        context_string = context_template.format(
            value=conversational_number(self.value),
            one_hundred_minus_value=conversational_number(100-self.value),
            in_the_top_percentile=self.display_in_the_top_percentile,
            percentile=self.display_percentile
        )

        return context_string
Example #3
0
 def description(self):
     description_template = self.my_badge_type.description
     description_string = description_template.format(
         value=conversational_number(self.value),
         one_hundred_minus_value=conversational_number(100-self.value)
     )
     return description_string
Example #4
0
 def description(self):
     description_template = self.my_badge_type.description
     description_string = description_template.format(
         value=conversational_number(self.value),
         one_hundred_minus_value=conversational_number(100-self.value)
     )
     return description_string