我正在使用这个 Discourse Surveys 插件:GitHub - discourse/discourse-surveys
提交调查后,我发现单选按钮、复选框和下拉列表在数据库中似乎都注册为 NULL。它似乎还重复注册了一个答案:
我正在使用这个 Discourse Surveys 插件:GitHub - discourse/discourse-surveys
提交调查后,我发现单选按钮、复选框和下拉列表在数据库中似乎都注册为 NULL。它似乎还重复注册了一个答案:
的值存储在单独的表中。
这应该能让你达到你想要的结果 ![]()
-- [params]
-- null int :user_id
-- string :name
SELECT s.name, s.post_id, sf.question, COALESCE(sr.value, sfo.html) AS value, sr.user_id, sr.created_at as responded_at
FROM surveys s
JOIN survey_fields sf ON sf.survey_id = s.id
JOIN survey_responses sr ON sr.survey_field_id = sf.id
LEFT JOIN survey_field_options sfo ON sfo.id = sr.survey_field_option_id
WHERE s.name = :name
AND (:user_id IS NULL OR sr.user_id = :user_id)
ORDER BY sr.user_id
我添加了一个按用户查询的选项(留空时,它会查询每个调查的所有用户),但如果你不感兴趣,可以随时删除
AND (:user_id IS NULL OR sr.user_id = :user_id)
啊,我都没注意到那个额外的表格!谢谢!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.