Export: an empty row in a number grid shifts all following cells left
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
The export logic is in lib/Service/SubmissionService.php, in the foreach loop over $gridRowsPerQuestionId[$questionId]; the empty-row branch currently appends one '' column. Check how $gridColumnsPerQuestionId is built for ANSWER_GRID_TYPE_NUMBER and make an empty row add one blank cell per column. Also change the inner empty() check so an answer of 0 is kept. Done when a number grid with an empty row keeps later columns aligned and a 0 answer is exported as 0.
Written by the indexing model from the issue text.
Description
Describe the bug
In the CSV/XLSX export of results, a number grid question whose row is left completely empty shifts every following cell on that line to the left: the next rows' values, and the answers to all later questions, end up under the wrong headers.
Steps to reproduce
- Create a form with one grid question, cell type Number, rows A1, A2, A3 and columns N0, N1, N2. Add a second question of any type after it.
- Submit one response that fills A1 (N0 = 2, N2 = 1) and A3 (N1 = 4), and leaves all of row A2 empty.
- Go to Results and export to CSV or XLSX.
Expected behaviour
The 4 appears under "(A3 - N1)", and the second question's answer appears in its own column.
Actual behaviour
The 4 appears under "(A2 - N2)", and every later cell on that line, including the second question's answer, is shifted left by (number of columns − 1) = 2.
Cause
In lib/Service/SubmissionService.php (the export), a grid row with no answer adds one empty cell:
foreach ($gridRowsPerQuestionId[$questionId] as $row) {
if (empty($answerText[$row])) {
$columns[] = '';
continue;
}
A number grid has one export column per row × column, so for ANSWER_GRID_TYPE_NUMBER an empty row has to add one empty cell per column (count($gridColumnsPerQuestionId[$questionId])). Radio and checkbox grids use one column per row, so they are not affected.
Versions
Seen on Forms 5.4.2; the same code is on main today (checked against v5.4.3 and main).
Related, same block: an answer of 0 exports as an empty cell
For number grids, the inner check if (empty($answerText[$row][$column])) treats an answer of 0 (or "0") as missing, because empty() is true for 0 in PHP, so a cell answered with 0 is exported blank. A check such as !isset($answerText[$row][$column]) || $answerText[$row][$column] === '' keeps the 0. (Found by reading the code, not by running it.)
- Dominant language
- JavaScript
- Stars
- 385
- Forks
- 133
- Avg merge
- 7h 54m
- Merged PRs (30d)
- 157
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/forms
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
0. Needs triage bug
Difficulty 3/5 1-2 days Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
1. to develop enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
nextcloud/forms#3841 · 1 reaction ·
Maintainers usually reply within 1 day
-
0. Needs triage bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
nextcloud/forms#3831 · 1 comment ·
Maintainers usually reply within 1 day
-
1. to develop enhancement
Difficulty 4/5 3-5 days Newbie friendliness 22/100
nextcloud/forms#3829 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cytoscape/cytoscape.js#3597 ·
Maintainers usually reply within 5 days
-
priority: low server testing
Difficulty 1/5 Under an hour Newbie friendliness 88/100
blamechris/chroxy#9277 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
sunososobro-hub/cloudball#191 ·
Maintainers usually reply within 1 day
-
[MCP]: page snapshots in .playwright-mcp/ are not git-ignored (.playwright-cli/ is, since #42318)Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/playwright#44289 ·
Maintainers usually reply within 1 day
-
Wire ISO post: has() accepts text values such as an empty string, true or 0x1A for wire numbersOpenarea:post effort:low enhancement P7 source:agent
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day