Metadata-Version: 2.5
Name: trytond_etude_report
Version: 8.0.0.1
Summary: Etude Form Server — Statistics, Cross-Tabs and Export
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: crosstab,export,form,report,statistics,survey,tryton
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Requires-Python: >=3.10
Requires-Dist: trytond-etude-collect<8.1,>=8.0
Requires-Dist: trytond-etude<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Etude Report Module
===================

The ``etude_report`` module turns what a form collected into answers: it
reads the responses of a form over the scope a *report* gives it, it adds
each question of the form up over the responses it read as a *statistic*,
it reads one question against another as a *cross-tab*, and it writes the
responses and the answers it read out as a CSV file or a JSON document.

A report reads the responses of a form and not its definition, so what it
shows is what the form collected rather than what it offers: the
questions a report is read by are the questions of the working copy of
the form it belongs to, and a question a definition dropped takes its
statistic with it rather than being kept beside the questions the form
holds now.  The reading is derived data - a report whose answers moved
holds the reading of the answers it reads now - so a report is computed
again when it is read again rather than maintained by hand.

The scope of a report
---------------------

A report belongs to the form whose responses it reads - ``etude.form``
gains the reports which read it - and its name is unique per form, so a
form is read under as many readings as a designer writes for it and every
one of them is named.  What a report reads is decided by its *scope*,
which is made of the states of the responses and of the moments they were
submitted between.

A response is read when it answers the form of the report and is in one
of the states the report reads.  A submitted response is one the form
took and an archived one is read alone; a *draft* is a response still
being answered and is not read, because a partial answer is not what a
form collected.  A report which asks for the drafts reads them beside
what the form took, and a draft then counts as a response which skipped
the questions that were not answered yet.

The two moments of a report bound the submit of a response: the start
date is the moment a response was submitted after and the end date the
moment it was submitted before.  A draft was submitted at no moment, so a
report which asks for the drafts *and* bounds the moments reads none of
them - its scope then holds two conditions no draft answers, which is
what the dates of a report mean.

Statistics
----------

A statistic is the reading of one question over the responses the report
scoped: the number of responses it was read over, the number that
answered the question and the number that left it.  The number of
responses is the number the report scoped rather than the number that
answered the question, because a question a response left out is part of
what the question reads - what a statistic shows is read against the
whole scope of its report.

What the answers of a question add up to is read from the kind of the
question.  A question answered by a choice is read as a *distribution*
over the options it offers, including the options nobody chose, which are
reported with a count of zero rather than left out, and so is a question
answered by yes or no, over its two answers.  A question answered by a
number or a decimal is read as an average, a smallest and a largest
answer.  The numbers of a question are read from the value of its answer
rather than from the column it is held in, so a definition that moved on
from an answer already collected is read for what it answers now.

A question that holds no answer of its own is left out of the reading: a
question of the kind *display* asks nothing, and a question of the kind
matrix, an array and a ranking holds its answers on the subquestions it
carries, which are questions of their group like any other and are read
in its place.

Cross-tabs
----------

A cross-tab reads one question against another: every response is counted
in the cell of the bucket it answered the row question in and the bucket
it answered the column question in, so what it shows is whether the
answers of two questions move together rather than what each of them adds
up to on its own.

A cross-tab is built of the *buckets* a question is answered in, so only
the questions answered by a choice or by yes or no are offered to it - a
question answered by a number or a text has no bucket to be counted in.
Both questions must be questions of the form the report reads, because a
cross-tab counts the answers of one response and a question of another
form is never answered by it, and a question read against itself is
refused, because every answer of it falls in the cell of its own bucket
and the cross-tab says nothing.

The questions of a cross-tab are checked where it is written and again
where it is read, so a definition which moves on after a cross-tab was
written is refused where it is read rather than read half way.  A
response which answered one question and left the other is counted in no
cell, because a cross-tab reads the answers of both, and a question
answered by a multiple choice is counted in every bucket it chose, so a
response which chose two options moves along two rows of the cross-tab.  A
cell no response fell into holds no row rather than a count of zero, so
what a cross-tab reads is what was answered and not every pair of a
definition.

What a report writes out
------------------------

The export of a report reads it once and writes what it read, in a CSV
file or in a JSON document, in one of two readings:

- the *responses*, one row per response with the answers of each beside
  it, which is what a spreadsheet sorts and filters; and
- the *answers*, one row per answer of a response, which is what a pivot
  table counts.

The values written are the answers as the kind of their question reads
them - a number as the text of the number, a moment as the ISO text of
it, a multiple choice as the list of the values it chose - so a JSON
export reads back as what was stored.  A CSV file holds the same values
as text, with the values of a multiple choice joined by a comma, a yes or
no written as *Yes* or *No* and a value that holds nothing written as
nothing rather than as the word "None".

The file is offered to the caller rather than stored: the export wizard
writes the data of the report into a field the caller downloads, so
exporting the same report twice writes the file twice rather than keeping
two of them in the database.

See ``doc/index.rst`` for the module documentation and ``ETUDE.md`` in
``modules-cch/`` for the architecture of the whole group.
