PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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