LimeControl

Build a dependent survey and read its results

In Equipment readiness for class, respondents select locations, choose which devices to check at each location and enter a battery level for each device. At 20% or below, they describe how they will prepare that device before class. A tablet at the library and a tablet in the studio can have different answers. The survey uses one native LimeSurvey question followed by three Huge free text questions (type U).

Try the English demo · Download the equipment survey · Expected English CSV · Installation instructions · Polski

Reproduce the sample response

  1. Install the plugin and all three question themes from the 0.2.0 package set. In LimeSurvey, import equipment.lss as a survey. Choose English in the survey language selector. Preview the entire survey to check the question order. To test the export, activate a test copy and open its participant link.
  2. Select Library and Studio. Select Tablet for the library and Camera for the studio. The matrix will have two rows.
  3. Enter 0 for the tablet and 100 for the camera. In the follow-up for the tablet, enter I will charge the tablet. and finish the survey. Only the tablet needs an action.
  4. Open Tools → LimeControl JSON · Export CSV in survey administration. Find your response_id. Expect five records, two for DEVICES, two for CHARGE and one for PLAN. Compare the codes, paths and values with the English sample output.

Try 20 for the tablet in another response. The action field still appears. At 21 it disappears. Try 101 in the battery field to see a range error. The battery column sets the range of valid inputs, while a separate rule on the follow-up determines which devices need an action.

Configure the questions in your own survey

Create the questions in the order shown. Under Tools → LimeControl JSON · Editor, choose each U question, set its source and save the block. The source can be an earlier native single-choice list (L or !), a multiple-choice question (M or P), or one of the earlier JSON blocks.

Code Type or question theme Settings
PLACES Native multiple choice (M) Add subquestions LIBRARY (“Library”) and STUDIO (“Studio”).
DEVICES U → Choice for each item Choose PLACES as the source. Add TABLET and CAMERA as Multiple choice options.
CHARGE U → Table from previous answers Choose DEVICES. Add the Number column BATTERY, label it “Battery level (%)”, select Require a value, and set minimum 0 and maximum 100.
PLAN U → Follow-up question Choose CHARGE. Add the required Text column ACTION and label it “What will you do before class?”. Add the rule below.

For PLAN, set the action to Show, the target to *, the field to source · BATTERY, the operator to At most and the value to 20. LimeSurvey displays the row when that device has 20% charge or less. Here is the rule as stored in the definition.

{
  "effect": "show",
  "target": "*",
  "when": { "field": "source.BATTERY", "op": "lte", "value": 20 }
}

A row can have one active single option and several multi options. Choosing an Exclusive option clears the other active entries in its row. Comment requires a comment when the respondent uses that option. For a conditional comment, choose the Require a comment action and specify its condition.

To see how a comment is exported, open Fieldwork. Choose both locations, select Measurement for Łódź and Service for Gdynia, and enter 9 and 0 hours respectively. Select Other for the measurement and type Repeat measurement as the comment. The hours follow-up appears only for the activity above 8 hours. Try Fieldwork · Survey LSS · Expected English CSV

Rule fields and conditions

Field Meaning
source.BATTERY The value in column BATTERY of this device’s upstream row. Choose from columns defined in the source block.
self.CODE A column in the current row. Use it to reveal another field in the same question.
source.count The total number of source rows feeding this block. The sample equipment matrix has two.

Numeric operators include gt (>), gte (≥), lt (<) and lte (≤). Use eq to test equality. selected checks whether a cell has an active value, which includes numeric zero. All requires every condition in its group, Any requires at least one and Not inverts one condition.

With the action Show, the target * controls the whole row. With Require a value, the same target requires at least one active cell in the row. To require a particular field, choose its column code as the target. If several Show rules target the same item, all must match. Export includes only cells that remain visible and paths that match the respondent’s current upstream selections.

Numeric limits in version 0.2.0

For a number column you can set a minimum, a maximum, or both. Each limit is inclusive. Equal limits allow exactly one number. Require a value is a separate setting. A column without limits also accepts negative numbers. The battery column can be defined as follows.

{
  "code": "BATTERY",
  "type": "number",
  "label": { "en": "Battery level (%)" },
  "required": true,
  "min": 0,
  "max": 100
}

Read the JSON and the CSV

LimeSurvey stores each U question in one response column. Each answer contains the format version, the revision of that question’s definition and a list of rows. For the sample equipment response, CHARGE contains the following JSON.

{
  "version": 1,
  "revision": "3439516541d77259",
  "rows": [
    { "path": ["LIBRARY", "TABLET"], "cells": { "BATTERY": { "value": 0 } } },
    { "path": ["STUDIO", "CAMERA"], "cells": { "BATTERY": { "value": 100 } } }
  ]
}

The path identifies a row. Its first code comes from the selected native answer. A choice block appends a selected option code when it supplies rows to the next question. A matrix passes the path to the follow-up. The path ["LIBRARY","TABLET"] therefore identifies the same device in both CHARGE and PLAN, across all survey languages.

Each record in the plugin CSV represents one stored cell in an active row. Find question_code = CHARGE, column = BATTERY and path = ["LIBRARY","TABLET"]. Its value = 0 means an empty battery. In PLAN, “I will charge the tablet.” is the value of a text column. In the fieldwork survey, “Repeat measurement” is stored in the separate comment field on the OTHER cell. Equipment CSV · Fieldwork CSV

To look up the translated labels, download LimeControl JSON · Codebook CSV and join it to the response export by question_code, revision and column. The survey installation assigns the response ID. Editing the definition, including its labels, can change the revision. Keep the existing column and option codes when translating.

Troubleshoot a different result

What you see What to check
The source is missing from the editor Put it before the U question in the survey and group order. Check its question type and save the upstream block’s configuration.
A dependent question has no rows Start a full survey preview and choose a location and a device. A single-question preview starts without those selections. For PLAN, check that at least one device has a battery level of 20% or less.
The question theme is unavailable Import that theme’s ZIP under Question themes and activate LimeControlJsonQuestions in the plugin manager.
The battery field accepts 101 Check the installed plugin version and the limits in BATTERY. Start a new response after saving the definition to test its new revision.
The CSV contains a single field with serialized JSON Choose Tools → LimeControl JSON · Export CSV. The account needs both read and export permissions for responses in this survey.
The answer exceeds field capacity Check the size of the encoded block in bytes. Split large tables or long comments across several U questions. Each block has a maximum of 2 MiB. MySQL column capacity and encryption may reduce that limit.

Before upgrading from 0.1.0, back up the database, survey and installed archives. Update all four packages to the same version. Columns without min or max retain their previous range. To introduce a new limit, set it in the editor and save. Start one new response, resume an earlier response with stored rows, then compare their revisions in the export. See the maintenance instructions for detaching a question and the version-specific qualification results.

0.2.0 release candidate packages