survey-model

Methods

(static) createNewEnketoId(idopt, triesRemainingopt) → {Promise.<(Error|string|Promise)>}

Source:

Generates a new random Enketo ID that has not been used yet, or checks whether a provided id has not been used. 8 characters keeps the chance of collisions below about 10% until about 10,000,000 IDs have been generated

Parameters:
Name Type Attributes Description
id string <optional>

This is only really included to write tests for collissions or a future "vanity ID" feature

triesRemaining number <optional>

Avoid infinite loops when collissions become the norm.

Returns:
Type
Promise.<(Error|string|Promise)>

(static) get(id) → {Promise.<(Error|SurveyObject)>}

Source:

Returns the information stored in the database for an enketo id.

Parameters:
Name Type Description
id string

Survey ID

Returns:

Promise that resolves with survey object

Type
Promise.<(Error|SurveyObject)>

(static) getId(survey) → {Promise.<(Error|null|string)>}

Source:
Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:

Promise that resolves with survey ID

Type
Promise.<(Error|null|string)>

(static) getList(server) → {Promise.<(Error|Array.<SurveyObject>)>}

Source:
Parameters:
Name Type Description
server string

Server URL

Returns:

Promise that resolves with a list of SurveyObjects

Type
Promise.<(Error|Array.<SurveyObject>)>

(static) getNumber(server) → {Promise.<(Error|string|number)>}

Source:
Parameters:
Name Type Description
server string

Server URL

Returns:

Promise that resolves with number of surveys

Type
Promise.<(Error|string|number)>

(static) incrementSubmissions(id) → {Promise.<(Error|string)>}

Source:
Parameters:
Name Type Description
id string

Survey ID

Returns:

Promise that eventually resolves with survey ID

Type
Promise.<(Error|string)>

(static) set(survey) → {Promise.<(Error|string)>}

Source:

Function for updating or creating a survey

Parameters:
Name Type Description
survey SurveyObject
Returns:

Promise that eventually resolves with Survey ID

Type
Promise.<(Error|string)>

(static) update(survey) → {Promise.<(Error|string)>}

Source:
Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:

Promise that resolves with survey ID

Type
Promise.<(Error|string)>

(inner) _404Empty(error) → {object}

Source:
Parameters:
Name Type Description
error Error
Returns:

Empty object for 404 errors; throws normally for other

Type
object

(inner) _addSurvey(openRosaKey, survey) → {Promise.<(Error|string)>}

Source:
Parameters:
Name Type Description
openRosaKey string
survey module:survey-model~SurveyObject
Returns:

Promise that eventually resolves with survey ID

Type
Promise.<(Error|string)>

(inner) _ascendingLaunchDate(a, b) → {number}

Source:

Function for launch date comparison

Parameters:
Name Type Description
a module:survey-model~SurveyObject
b module:survey-model~SurveyObject
Returns:
Type
number

(inner) _getActiveSurveys(openRosaIds) → {Promise}

Source:
Parameters:
Name Type Description
openRosaIds Array.<string>

A list of openRosaIds

Returns:
Type
Promise

(inner) _getEnketoId(openRosaKey) → {Promise.<(Error|null|string)>}

Source:
Parameters:
Name Type Description
openRosaKey string
Returns:

Promise that resolves with survey ID

Type
Promise.<(Error|null|string)>

(inner) _nonEmpty(survey) → {boolean}

Source:
Parameters:
Name Type Description
survey module:survey-model~SurveyObject
Returns:

Whether survey has openRosaId

Type
boolean

(inner) _updateProperties(id, survey) → {Promise.<(Error|string)>}

Source:
Parameters:
Name Type Description
id string

Survey ID

survey module:survey-model~SurveyObject

New survey

Returns:

Promise that resolves with survey ID

Type
Promise.<(Error|string)>

Type Definitions

SurveyObject

Source:
Properties:
Name Type Description
openRosaServer string
openRosaId string
enketoId string
theme string
info object
Properties
Name Type Description
hash string