liquid_feedback_frontend

view app/main/survey/participate.lua @ 1741:772c18d87b54

Fixed syntax error
author bsw
date Mon Oct 11 10:38:04 2021 +0200 (2021-10-11)
parents b94cf0ea5942
children 9f96b7e6e5f2
line source
1 local survey = Survey:get_open()
2 if not survey then
3 return execute.view { module = "index", view = "404" }
4 end
6 local survey_member = SurveyMember:by_pk(survey.id, app.session.member_id)
7 if not survey_member then
8 return execute.view { module = "index", view = "404" }
9 end
11 local question
13 if survey_member then
14 local answer_set = survey_member.answer_set
15 if answer_set then
16 local answers_by_question_id = {}
17 for i, answer in ipairs(answer_set.answers) do
18 answers_by_question_id[answer.survey_question_id] = answer
19 end
20 for i, q in ipairs(survey.questions) do
21 if not question and not answers_by_question_id[q.id] then
22 question = q
23 end
24 end
25 end
26 end
28 ui.title(_"Survey")
29 ui.grid{ content = function()
30 ui.cell_main{ content = function()
32 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp survey" }, content = function()
33 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
34 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = survey.title }
35 --[[
36 ui.container{
37 content = _(
38 "This survey closes in #{closing}.",
39 { closing = format.interval_text(survey.time_left) }
40 )
41 }
42 --]]
43 end }
44 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
45 if survey_member.finished then
46 ui.container{ content = function()
47 slot.put(survey.finished_text)
48 end }
49 slot.put("<br>")
50 ui.link{
51 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored" },
52 module = "index", view = "index", content = _"Go to start page"
53 }
54 return
55 else
56 ui.heading{ level = 2, content = question.question }
57 if question.description then
58 ui.container{ content = question.description }
59 end
60 ui.form{
61 module = "survey", action = "answer",
62 routing = {
63 ok = { mode = "redirect", module = "survey", view = "participate" },
64 error = { mode = "forward", module = "survey", view = "participate" },
65 },
66 content = function()
67 ui.field.hidden{ name = "question_id", value = question.id }
68 if question.answer_type == "radio" then
69 for i, answer_option in ipairs(question.answer_options) do
70 ui.container{ content = function()
71 ui.tag{ tag = "label", attr = {
72 class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
73 ["for"] = "answer_" .. i
74 },
75 content = function()
76 ui.tag{
77 tag = "input",
78 attr = {
79 id = "answer_" .. i,
80 class = "mdl-radio__button",
81 type = "radio",
82 name = "answer",
83 value = answer_option,
84 checked = param.get("answer") == answer_option and "checked" or nil,
85 }
86 }
87 ui.tag{
88 attr = { class = "mdl-radio__label", ['for'] = "answer_" .. i },
89 content = answer_option
90 }
91 end
92 }
93 end }
94 end
95 slot.put("<br>")
96 ui.tag{
97 tag = "input",
98 attr = {
99 type = "submit",
100 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
101 value = _"Next step"
102 },
103 content = ""
104 }
105 end
106 end
107 }
108 end
109 end }
110 end }
111 end }
112 end }

Impressum / About Us