Example #1
0
def get_choice_values_appstruct(ruleset, question, request):
    """ Fetch any existing scores for choices related to this question or question type.
    """
    appstruct = {}
    for choice in get_all_choices(question, request, include_omitted = True):
        value = ruleset.get_choice_score(question, choice)
        if value != None:
            appstruct[choice.cluster] = value
    return appstruct
Example #2
0
def get_choice_values_schema(question, request):
    """ Append all relevant choices for question.
        question is either a QuestionType or a Question object.
        If it's a Question object, fetch all choices from
        the referenced question type too.
    """
    schema = colander.Schema()
    choices = get_all_choices(question, request, include_omitted = True)
    for choice in choices:
        schema.add(colander.SchemaNode(colander.Int(),
                                       name = choice.cluster,
                                       title = choice.title))
    return schema
Example #3
0
 def get_choices(self, question, only_from_type=False):
     return get_all_choices(question, self.request, only_from_type=only_from_type)