akvo / akvo-flow

A data collection and monitoring tool that works anywhere.
http://akvo.org/products/akvoflow/
GNU Affero General Public License v3.0
65 stars 31 forks source link

Add codes to cascade questions #1323

Closed ichinaski closed 8 years ago

ichinaski commented 9 years ago

Overview

Cascade resources do store codes already in GAE. However this properties are not reflected in the serialised version of the resource (SQLite database), therefore the app cannot submit the code as the value.

Actions:

Format options:

janagombitova commented 9 years ago

Duplicate of #1209

ichinaski commented 9 years ago

Sample response representing the first approach (code property):

// Cascade response

{
    "questionId": 0001,
    "answerType": "CASCADE",
    "value": "United Kingdom|England|Bristol",
    "code": "acb|def|ghi"
}

// Option question (single response)

{
    "questionId": 0002,
    "answerType": "OPTION",
    "value": "United Kingdom",
    "code": "acb"
}

// Option question (multiple responses)

{
    "questionId": 0003,
    "answerType": "OPTION",
    "value": "United Kingdom|Netherlands|Germany",
    "code": "acb|xyz|jkl"
}
ichinaski commented 9 years ago

The decision we have taken is to use JSON-encoded values for complex responses (and eventually, everywhere): https://github.com/akvo/akvo-product-design/blob/master/FLOW/arch/ADR-004.md

janagombitova commented 9 years ago

Related issue regarding how we visualize codes in Reports: https://github.com/akvo/akvo-flow/issues/1230

janagombitova commented 9 years ago

Suggestion on how to visualize codes + cascades in raw data report

cascade raw data rep

Suggestion for exporting cascades with codes in raw data report. Each cascade level will sit in its own cell/ column and the code:value formatting will copy the decision made with Codes for Option questions. If we put the entire cascade path with the codes in one cell, it may become too condensed and unreadable for the users.

iperdomo commented 9 years ago

@janagombitova remember that RAW DATA serves two purposes, there is the need to use it for data cleaning, so having everything packed in one cell is machine readable

mtwestra commented 9 years ago

@janagombitova, @iperdomo , I think we need to have two versions: one raw data report, which has everything in one column, and one 'export' version, which separates everything in columns.

I would make the column headers specific, so location_state_code, location_state, location_region_code, location_region, location_district_code, location_district, etc. Same for codes with options: someoption_code, someoption

janagombitova commented 9 years ago

@mtwestra @iperdomo @jonase @ichinaski @muloem

Based on your comments I suggest we can implement the reports work in two batches:

Implementation 1 - raw data report - everything in one cell, with reusing the proposed structure for options code1:value1|code2:value2|code3:value3 in the code+cascade as well: statecode:state|regioncode:region|districtcode:distrtict

Implementation 2 - Create either a report setting or a new type of report (based on UX) which will separate items into different columns. However, there are again multiple options how to approach this:

cascades options codes

I personally prefer: Code in one cell, Value in one cell + multi select (vertical), because if we divide items in separate columns, we should divide everything and the vertical view is consistent with our decision on repeated question groups.

rumca commented 8 years ago

I think the test plans for this are captured in issue number 317 on the mobile repo, but just to confirm that I see what I think is the correct new format in reports as below:

screen shot 2015-11-01 at 23 24 32

(showing one old response and one new one)

I'm going to close this issue and if we need to make future enhancements to the reports we can do so against a new issue :+1:

jonase commented 8 years ago

TestPlan

Test Plan for cascade questions with codes support in the raw data reports

The report with "Export this report for use with an external system"

+-------------+-------------+-------------+
| code1:text1 | code2:text2 | code3:text3 |
+-------------+-------------+-------------+
+-------+-------+-------+
| text1 | text2 | text3 |
+-------+-------+-------+

The report without "Export this report for use with an external system"

+-----------------------------------------+
| code1:text1 | code2:text2 | code3:text3 |
+-----------------------------------------+
+-----------------------+
| text1 | text2 | text3 |
+-----------------------+

Data cleaning

rumca commented 8 years ago

@jonase interestingly enough it's not actually possible to create a cascade without code properties set as far as I am aware. If there isn't one explicitly set, then it's set to the same value as the name. At least that's the case for all the cascades I've created manually and via the importer.

Otherwise this test plan passes as described :+1:

janagombitova commented 8 years ago

@jonas, is this expected (Ruarcc's message) and is this visible to the users? I though we said, that if the user does not create a code for any value, then he does not see the code (anywhere - app, dashboard, reports)

jonase commented 8 years ago

@janagombitova @rumca I might have confused cascade & option codes here. Currently the implementation assumes:

janagombitova commented 8 years ago

@jonas, so the user does not see a code, if he did not add one. If so, then good. I thought @rumca implied that codes are always visible (if created by user, or not - copy of the value name)

ichinaski commented 8 years ago

in the new format, if the code is missing (can it even be missing?) will the response be [{"name": "Finland"}, {"name": "Vasa"}] or [{"name": "Finland", "code": "FI"}, {"name": "Vasa", "code": "VA"}]?

The former. If the option has no codes, the app will not assign one by default. Note however, that the current value/text implementation (code/text as of now), does assign a default value (code), which results in the form XML being fully populated, that is never having missing values (codes). I believe this is something we'll have to adjust in the backend implementation for cases wherein the user provides no codes.

rumca commented 8 years ago

In my experience it's not possible to not see a code, if you don't explicitly add one then the name is used as the code and that's what is populated in the report.

janagombitova commented 8 years ago

Then yes, this needs to be changed

rumca commented 8 years ago

code no longer displays if it's the same as the name :+1: