generated from your-land/yl_template
Fixes allowed_answers wrong check. Thankyou tour
This commit is contained in:
parent
1a41313613
commit
01380c7622
12
api.lua
12
api.lua
@ -312,8 +312,8 @@ local function create_question(id, question, category, sort, allowed_types,
|
|||||||
|
|
||||||
-- Specialcase : answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice
|
-- Specialcase : answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice
|
||||||
if (((answers == nil) or (next(answers) == nil)) and
|
if (((answers == nil) or (next(answers) == nil)) and
|
||||||
((allowed_types["multiplechoice"] ~= nil) or
|
((yl_survey.table_contains(allowed_types, "multiplechoice") == true) or
|
||||||
(allowed_types["singlechoice"] ~= nil))) then
|
(yl_survey.table_contains(allowed_types, "singlechoice") == true))) then
|
||||||
return false, yl_survey.t(
|
return false, yl_survey.t(
|
||||||
"answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice")
|
"answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice")
|
||||||
end
|
end
|
||||||
@ -415,8 +415,8 @@ local function edit_question(id, q_id, question, sort, category, allowed_types,
|
|||||||
|
|
||||||
-- Specialcase : answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice
|
-- Specialcase : answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice
|
||||||
if ((answers ~= nil) and (next(answers) ~= nil) and
|
if ((answers ~= nil) and (next(answers) ~= nil) and
|
||||||
((allowed_types["multiplechoice"] ~= nil) or
|
((yl_survey.table_contains(allowed_types, "multiplechoice") == true) or
|
||||||
(allowed_types["singlechoice"] ~= nil))) then
|
(yl_survey.table_contains(allowed_types, "singlechoice") == true))) then
|
||||||
return false, yl_survey.t(
|
return false, yl_survey.t(
|
||||||
"answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice")
|
"answers cannot be nil or empty if allowedtypes has either multiplechoice or singlechoice")
|
||||||
end
|
end
|
||||||
@ -446,9 +446,7 @@ local function edit_question(id, q_id, question, sort, category, allowed_types,
|
|||||||
local no = 0
|
local no = 0
|
||||||
local n_responses = t_question["responses"] or {}
|
local n_responses = t_question["responses"] or {}
|
||||||
if (delete_responses == true) then
|
if (delete_responses == true) then
|
||||||
for _,_ in pairs(n_responses) do
|
for _, _ in pairs(n_responses) do no = no + 1 end
|
||||||
no = no + 1
|
|
||||||
end
|
|
||||||
n_responses = {}
|
n_responses = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
18
internal.lua
18
internal.lua
@ -30,6 +30,24 @@ end
|
|||||||
|
|
||||||
function yl_survey.priv_exists(priv) return priv_exists(priv) end
|
function yl_survey.priv_exists(priv) return priv_exists(priv) end
|
||||||
|
|
||||||
|
-- table.contains
|
||||||
|
|
||||||
|
local function table_contains(t, m)
|
||||||
|
if ((type(m) ~= "number") and (type(m) ~= "string") and (type(m) ~= "boolean")) then
|
||||||
|
return nil, yl_survey.t("member must be primitive")
|
||||||
|
end
|
||||||
|
for _, v in pairs(t) do
|
||||||
|
if (v == m) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function yl_survey.table_contains(t, m)
|
||||||
|
return table_contains(t, m)
|
||||||
|
end
|
||||||
|
|
||||||
-- Hash name
|
-- Hash name
|
||||||
|
|
||||||
local function hash_name(name)
|
local function hash_name(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user