feedback/utils.py
changeset 56 d8d4387b3281
parent 11 afc41af983e5
equal deleted inserted replaced
55:8d78e1e62424 56:d8d4387b3281
    12                    'exercises': "Choice of Exercises:",
    12                    'exercises': "Choice of Exercises:",
    13                   }
    13                   }
    14 
    14 
    15 EXPAND_OPTION = {
    15 EXPAND_OPTION = {
    16     "topics" : {
    16     "topics" : {
    17         "1" : "%s%% of the people felt that the range of topics covered was very relevant",
    17         "1" : "%d out of %s people felt that the range of topics covered was very relevant",
    18         "2" : "%s%% of the people felt that the range of topics covered was relevant",
    18         "2" : "%d out of %s people felt that the range of topics covered was relevant",
    19         "3" : "%s%% of the people felt that the range of topics covered was somewhat relevant",
    19         "3" : "%d out of %s people felt that the range of topics covered was somewhat relevant",
    20         "4" : "%s%% of the people felt that the range of topics covered was not relevant",
    20         "4" : "%d out of %s people felt that the range of topics covered was not relevant",
    21     },
    21     },
    22 
    22 
    23     "depth" : {
    23     "depth" : {
    24         "1" : "%s%% of the people felt that the depth of coverage was too detailed",
    24         "1" : "%d out of %s people felt that the depth of coverage was too detailed",
    25         "2" : "%s%% of the people felt that the depth of coverage was detailed",
    25         "2" : "%d out of %s people felt that the depth of coverage was detailed",
    26         "3" : "%s%% of the people felt that the depth of coverage was not detailed enough",
    26         "3" : "%d out of %s people felt that the depth of coverage was not detailed enough",
    27         "4" : "%s%% of the people felt that the depth of coverage was poorly detailed",
    27         "4" : "%d out of %s people felt that the depth of coverage was poorly detailed",
    28     },
    28     },
    29 
    29 
    30     "methodology" : {
    30     "methodology" : {
    31         "1" : "%s%% of the people felt that the teaching methodology was extremely effective",
    31         "1" : "%d out of %s people felt that the teaching methodology was extremely effective",
    32         "2" : "%s%% of the people felt that the teaching methodology was effective",
    32         "2" : "%d out of %s people felt that the teaching methodology was effective",
    33         "3" : "%s%% of the people felt that the teaching methodology was not very effective",
    33         "3" : "%d out of %s people felt that the teaching methodology was not very effective",
    34         "4" : "%s%% of the people felt that the teaching methodology was ineffective",
    34         "4" : "%d out of %s people felt that the teaching methodology was ineffective",
    35     },
    35     },
    36 
    36 
    37     "pace" : {
    37     "pace" : {
    38         "1" : "%s%% of the people felt that the the pace of coverage was too fast",
    38         "1" : "%d out of %s people felt that the the pace of coverage was too fast",
    39         "2" : "%s%% of the people felt that the the pace of coverage was fast",
    39         "2" : "%d out of %s people felt that the the pace of coverage was fast",
    40         "3" : "%s%% of the people felt that the the pace of coverage was just right",
    40         "3" : "%d out of %s people felt that the the pace of coverage was just right",
    41         "4" : "%s%% of the people felt that the the pace of coverage was slow",
    41         "4" : "%d out of %s people felt that the the pace of coverage was slow",
    42         "5" : "%s%% of the people felt that the the pace of coverage was too slow",
    42         "5" : "%d out of %s people felt that the the pace of coverage was too slow",
    43     },
    43     },
    44 
    44 
    45     "applicability" : {
    45     "applicability" : {
    46         "1" : "%s%% of the people felt that they can apply what they have learnt immediately",
    46         "1" : "%d out of %s people felt that they can apply what they have learnt immediately",
    47         "2" : "%s%% of the people felt that they can apply what they have learnt somewhat immediately",
    47         "2" : "%d out of %s people felt that they can apply what they have learnt somewhat immediately",
    48         "3" : "%s%% of the people felt that they cannot apply what they have learnt immediately",
    48         "3" : "%d out of %s people felt that they cannot apply what they have learnt immediately",
    49         "4" : "%s%% of the people felt that they might never apply what they have learnt",
    49         "4" : "%d out of %s people felt that they might never apply what they have learnt",
    50     },
    50     },
    51 
    51 
    52     "problems" : {
    52     "problems" : {
    53         "1" : "%s%% of the people felt that the problems were very interesting",
    53         "1" : "%d out of %s people felt that the problems were very interesting",
    54         "2" : "%s%% of the people felt that the problems were interesting",
    54         "2" : "%d out of %s people felt that the problems were interesting",
    55         "3" : "%s%% of the people felt that the problems were somewhat interesting",
    55         "3" : "%d out of %s people felt that the problems were somewhat interesting",
    56         "4" : "%s%% of the people felt that the problems were not interesting",
    56         "4" : "%d out of %s people felt that the problems were not interesting",
    57     },
    57     },
    58 
    58 
    59     "exercises" : {
    59     "exercises" : {
    60         "1" : "%s%% of the people felt that the exercises were very instructive",
    60         "1" : "%d out of %s people felt that the exercises were very instructive",
    61         "2" : "%s%% of the people felt that the exercises were instructive",
    61         "2" : "%d out of %s people felt that the exercises were instructive",
    62         "3" : "%s%% of the people felt that the exercises were somewhat instructive",
    62         "3" : "%d out of %s people felt that the exercises were somewhat instructive",
    63         "4" : "%s%% of the people felt that the exercises were not instructive",
    63         "4" : "%d out of %s people felt that the exercises were not instructive",
    64     },
    64     },
    65 }
    65 }
    66 
    66 
    67 def make_day_report(feeds):
    67 def make_day_report(feeds):
    68     """ take a list of feedback objects and return the percentage of each item in the form of a dict.
    68     """ take a list of feedback objects and return the percentage of each item in the form of a dict.
    80         choices_dict = dict(choices)
    80         choices_dict = dict(choices)
    81         
    81         
    82         field_report = []
    82         field_report = []
    83         for option in sorted(choices_dict.keys()):
    83         for option in sorted(choices_dict.keys()):
    84             args_dict = {field : option}
    84             args_dict = {field : option}
    85             option_percent = feeds.filter(**args_dict).count() / no_of_feeds * 100
    85             option_percent = feeds.filter(**args_dict).count() * 100.0 / no_of_feeds
    86             if option_percent:
    86             option_feeds = feeds.filter(**args_dict).count()
    87                 field_report.append((EXPAND_OPTION[field][option])%option_percent)
    87             if option_feeds:
       
    88                 field_report.append((EXPAND_OPTION[field][option])%(option_feeds,no_of_feeds))
    88         
    89         
    89         if field_report:
    90         if field_report:
    90             day_report.extend( [LONG_FIELD_NAME[field], field_report] )
    91             day_report.extend( [LONG_FIELD_NAME[field], field_report] )
    91 
    92 
    92     return day_report
    93     return day_report