/modules/mod_survey/questions/survey_q_subhead.erl

https://code.google.com/p/zotonic/ · Erlang · 70 lines · 40 code · 15 blank · 15 comment · 1 complexity · 6b0bedf853cfe997b932101eb81b026b MD5 · raw file

  1. %% @author Marc Worrell <marc@worrell.nl>
  2. %% @copyright 2011 Marc Worrell
  3. %% Copyright 2011 Marc Worrell
  4. %%
  5. %% Licensed under the Apache License, Version 2.0 (the "License");
  6. %% you may not use this file except in compliance with the License.
  7. %% You may obtain a copy of the License at
  8. %%
  9. %% http://www.apache.org/licenses/LICENSE-2.0
  10. %%
  11. %% Unless required by applicable law or agreed to in writing, software
  12. %% distributed under the License is distributed on an "AS IS" BASIS,
  13. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. %% See the License for the specific language governing permissions and
  15. %% limitations under the License.
  16. -module(survey_q_subhead).
  17. -export([
  18. new/0,
  19. question_props/1,
  20. render/1,
  21. answer/2,
  22. prep_answer_header/1,
  23. prep_answer/2
  24. ]).
  25. -include("../survey.hrl").
  26. new() ->
  27. Q = #survey_question{
  28. type = subhead,
  29. name = z_ids:identifier(5),
  30. text = "",
  31. question = <<"This is a subhead">>
  32. },
  33. render(Q).
  34. question_props(Q) ->
  35. [
  36. {explanation, "Please enter the text for the subhead."},
  37. {has_question, true},
  38. {has_text, false},
  39. {has_name, true},
  40. {question_label, "Subhead"},
  41. {text_label, ""}
  42. ] ++
  43. ?QUESTION_AS_PROPLIST(Q).
  44. render(Q) ->
  45. Q#survey_question{
  46. text = "",
  47. question = iolist_to_binary(Q#survey_question.question),
  48. html = iolist_to_binary(["<h2>", z_html:escape(Q#survey_question.question), "</h2>"])
  49. }.
  50. answer(_Q, _Answers) ->
  51. {ok, none}.
  52. prep_answer_header(_Q) ->
  53. [].
  54. prep_answer(_Q, _Answer) ->
  55. [].