generated from your-land/yl_template
Fixes validation
This commit is contained in:
parent
6655b51a70
commit
b0aaebf437
7
api.lua
7
api.lua
@ -84,6 +84,9 @@ local function validate_responses(t_answers, responses)
|
||||
if (validate(t_answers, "table", false) == false) then return false end
|
||||
if (validate(responses, "table", false) == false) then return false end
|
||||
|
||||
-- Remove the question
|
||||
responses["q"] = nil
|
||||
|
||||
-- If the responses are not JSON-able, return false
|
||||
if (minetest.write_json(responses) == nil) then return false end
|
||||
|
||||
@ -683,6 +686,10 @@ local function answer_question(id, q_id, playername, responses, overwrite)
|
||||
record[tostring(q_id)]["responses"] = {}
|
||||
end
|
||||
|
||||
if (t_question["answers"] == nil) then
|
||||
t_question["answers"] = {}
|
||||
end
|
||||
|
||||
if (validate_responses(t_question["answers"], responses) == false) then
|
||||
return false, "responses do not fit the questions"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user