author | nishanth |
Tue, 06 Jul 2010 23:31:33 +0530 | |
changeset 89 | f8e25dea5222 |
parent 56 | d8d4387b3281 |
permissions | -rw-r--r-- |
11 | 1 |
""" A collection of utilities for feedback app. |
2 |
""" |
|
3 |
||
4 |
from offline.feedback.models import * |
|
5 |
||
6 |
LONG_FIELD_NAME = {'topics': "Range of topics covered:", |
|
7 |
'depth': "Depth of coverage:", |
|
8 |
'methodology': "Effectiveness of methodology:", |
|
9 |
'pace': "Pace of coverage:", |
|
10 |
'applicability': "Applicability:", |
|
11 |
'problems': "Choice of problems:", |
|
12 |
'exercises': "Choice of Exercises:", |
|
13 |
} |
|
14 |
||
15 |
EXPAND_OPTION = { |
|
16 |
"topics" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
17 |
"1" : "%d out of %s people felt that the range of topics covered was very relevant", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
18 |
"2" : "%d out of %s people felt that the range of topics covered was relevant", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
19 |
"3" : "%d out of %s people felt that the range of topics covered was somewhat relevant", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
20 |
"4" : "%d out of %s people felt that the range of topics covered was not relevant", |
11 | 21 |
}, |
22 |
||
23 |
"depth" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
24 |
"1" : "%d out of %s people felt that the depth of coverage was too detailed", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
25 |
"2" : "%d out of %s people felt that the depth of coverage was detailed", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
26 |
"3" : "%d out of %s people felt that the depth of coverage was not detailed enough", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
27 |
"4" : "%d out of %s people felt that the depth of coverage was poorly detailed", |
11 | 28 |
}, |
29 |
||
30 |
"methodology" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
31 |
"1" : "%d out of %s people felt that the teaching methodology was extremely effective", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
32 |
"2" : "%d out of %s people felt that the teaching methodology was effective", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
33 |
"3" : "%d out of %s people felt that the teaching methodology was not very effective", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
34 |
"4" : "%d out of %s people felt that the teaching methodology was ineffective", |
11 | 35 |
}, |
36 |
||
37 |
"pace" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
38 |
"1" : "%d out of %s people felt that the the pace of coverage was too fast", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
39 |
"2" : "%d out of %s people felt that the the pace of coverage was fast", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
40 |
"3" : "%d out of %s people felt that the the pace of coverage was just right", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
41 |
"4" : "%d out of %s people felt that the the pace of coverage was slow", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
42 |
"5" : "%d out of %s people felt that the the pace of coverage was too slow", |
11 | 43 |
}, |
44 |
||
45 |
"applicability" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
46 |
"1" : "%d out of %s people felt that they can apply what they have learnt immediately", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
47 |
"2" : "%d out of %s people felt that they can apply what they have learnt somewhat immediately", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
48 |
"3" : "%d out of %s people felt that they cannot apply what they have learnt immediately", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
49 |
"4" : "%d out of %s people felt that they might never apply what they have learnt", |
11 | 50 |
}, |
51 |
||
52 |
"problems" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
53 |
"1" : "%d out of %s people felt that the problems were very interesting", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
54 |
"2" : "%d out of %s people felt that the problems were interesting", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
55 |
"3" : "%d out of %s people felt that the problems were somewhat interesting", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
56 |
"4" : "%d out of %s people felt that the problems were not interesting", |
11 | 57 |
}, |
58 |
||
59 |
"exercises" : { |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
60 |
"1" : "%d out of %s people felt that the exercises were very instructive", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
61 |
"2" : "%d out of %s people felt that the exercises were instructive", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
62 |
"3" : "%d out of %s people felt that the exercises were somewhat instructive", |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
63 |
"4" : "%d out of %s people felt that the exercises were not instructive", |
11 | 64 |
}, |
65 |
} |
|
66 |
||
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. |
|
69 |
""" |
|
70 |
||
71 |
no_of_feeds = feeds.count() |
|
72 |
if not no_of_feeds: |
|
73 |
return [] |
|
74 |
||
75 |
day_report = [] |
|
76 |
||
77 |
for field in ['topics', 'depth', 'methodology', 'pace', 'applicability', 'problems', 'exercises']: |
|
78 |
||
79 |
choices = eval((field+'_choices').upper()) ## the choices are named accordingly in the models file |
|
80 |
choices_dict = dict(choices) |
|
81 |
||
82 |
field_report = [] |
|
83 |
for option in sorted(choices_dict.keys()): |
|
84 |
args_dict = {field : option} |
|
56
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
85 |
option_percent = feeds.filter(**args_dict).count() * 100.0 / no_of_feeds |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
86 |
option_feeds = feeds.filter(**args_dict).count() |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
87 |
if option_feeds: |
d8d4387b3281
made change in show report as per requirement and improved the quiz intro
nishanth
parents:
11
diff
changeset
|
88 |
field_report.append((EXPAND_OPTION[field][option])%(option_feeds,no_of_feeds)) |
11 | 89 |
|
90 |
if field_report: |
|
91 |
day_report.extend( [LONG_FIELD_NAME[field], field_report] ) |
|
92 |
||
93 |
return day_report |
|
94 |
||
95 |