Module m_survey

Model for accessing survey information.

Copyright © 2010-2020 Marc Worrell

Behaviours: zotonic_model.

Authors: Marc Worrell (marc@worrell.nl).

Description

Model for accessing survey information.

Function Index

answer_user/2
delete_result/3Delete a specific survey results.
delete_result/4Delete all survey results for a user or persistent id.
delete_results/2Delete all survey results.
get_handlers/1Return the list of known survey handlers.
get_questions/2get prepared questions from the blocks.
insert_survey_submission/3Save a survey, connect to the current user (if any).
insert_survey_submission/5Save or replace a survey, resetting the created if needed.
is_allowed_results_download/2
is_answer_user/2
is_answer_user/3
list_results/2
m_get/3Fetch the value for the key from a model source.
persistent_id/1
replace_survey_submission/4Replace a survey answer.
rsc_merge/3Move all answers of a to-be-deleted user to another user.
single_result/3
single_result/4Retrieve the latest survey result for a user or persistent id.
survey_results/3Return all results of a survey.
survey_results_prompts/3Return all results of a survey with separate names, prompts and data.
survey_results_sorted/3Get survey results, sorted by the given sort column.
survey_stats/2Fetch the aggregate answers of a survey.

Function Details

answer_user/2

answer_user(AnsId::integer(), Context::z:context()) -> integer() | undefined

delete_result/3

delete_result(SurveyId, ResultId, Context) -> any()

Delete a specific survey results

delete_result/4

delete_result(SurveyId, UserId, PersistentId, Context) -> any()

Delete all survey results for a user or persistent id.

delete_results/2

delete_results(SurveyId, Context) -> any()

Delete all survey results

get_handlers/1

get_handlers(Context::z:context()) -> [{atom(), binary()}]

Return the list of known survey handlers

get_questions/2

get_questions(SurveyId::m_rsc:resource_id(), Context::z:context()) -> [{BlockName::binary(), map()}] | undefined

get prepared questions from the blocks

insert_survey_submission/3

insert_survey_submission(SurveyId::m_rsc:resource_id(), Answers::list(), Context::z:context()) -> {ok, pos_integer()} | {error, any()}

Save a survey, connect to the current user (if any)

insert_survey_submission/5

insert_survey_submission(SurveyId, UserId, PersistentId, Answers, Context) -> any()

Save or replace a survey, resetting the created if needed.

is_allowed_results_download/2

is_allowed_results_download(Id::m_rsc:resource_id(), Context::z:context()) -> boolean()

is_answer_user/2

is_answer_user(AnsId::integer(), Context::z:context()) -> boolean()

is_answer_user/3

is_answer_user(AnsId::integer(), UserId::integer(), Context::z:context()) -> boolean()

list_results/2

list_results(SurveyId::integer(), Context::z:context()) -> list()

m_get/3

m_get(Rest::list(), Msg::zotonic_model:opt_msg(), Context::z:context()) -> zotonic_model:return()

Fetch the value for the key from a model source

persistent_id/1

persistent_id(Context::z:context()) -> {binary() | undefined, z:context()}

replace_survey_submission/4

replace_survey_submission(SurveyId::integer(), AnswerId::{user, m_rsc:resource_id()} | integer(), Answers::list(), Context::z:context()) -> {ok, integer()} | {error, term()}

Replace a survey answer

rsc_merge/3

rsc_merge(WinnerId, LoserId, Context) -> any()

Move all answers of a to-be-deleted user to another user.

single_result/3

single_result(SurveyId::integer(), AnswerId::integer(), Context::z:context()) -> list()

single_result/4

single_result(SurveyId, UserId, PersistentId, Context) -> any()

Retrieve the latest survey result for a user or persistent id.

survey_results/3

survey_results(SurveyId, IsAnonymous, Context) -> any()

Return all results of a survey

survey_results_prompts/3

survey_results_prompts(SurveyId, IsForceAnonymous, Context) -> any()

Return all results of a survey with separate names, prompts and data

survey_results_sorted/3

survey_results_sorted(SurveyId, SortColumn, Context) -> any()

Get survey results, sorted by the given sort column.

survey_stats/2

survey_stats(SurveyId::m_rsc:resource_id(), Context::z:context()) -> [{Block::binary(), [{QName::binary(), [{Answer::binary(), Count::integer()}]}]}]

Fetch the aggregate answers of a survey.


Generated by EDoc