Permalink
Browse files

mos_survey: fix chart export when answer name changed for yesno quest…

…ions.
  • Loading branch information...
1 parent a7f0262 commit 99adc4e67726bbb7d2c27c572a747f09160636ff @arjan arjan committed Mar 14, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 modules/mod_survey/questions/survey_q_yesno.erl
View
9 modules/mod_survey/questions/survey_q_yesno.erl
@@ -76,9 +76,12 @@ answer(#survey_question{name=Name}, Answers) ->
prep_chart(_Q, []) ->
undefined;
-prep_chart(Q, [{_, Vals}]) ->
- Yes = proplists:get_value(<<"yes">>, Vals, 0),
- No = proplists:get_value(<<"no">>, Vals, 0),
+prep_chart(Q, Answers) ->
+ {Yes, No} = lists:foldr(fun({_Id, Vals}, {Y, N}) ->
+ {proplists:get_value(<<"yes">>, Vals, 0) + Y,
+ proplists:get_value(<<"no">>, Vals, 0) + N} end,
+ {0, 0},
+ Answers),
Total = Yes + No,
YesP = round(Yes * 100 / Total),
NoP = 100 - YesP,

0 comments on commit 99adc4e

Please sign in to comment.