rdmorganiser / rdmorganiser/rdmo
QuestionSet titles are missing from "View Answers" and exports
- Dominant language
- Python
- Stars
- 133
- Forks
- 60
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 21
Description
Description / Beschreibung
issue was written with help of ChatGPT
The "View Answers" page does not display the titles of QuestionSets.
When a catalog has:
Section
└── Page
└── QuestionSet
├── Question
└── Question
the "View Answers" currently only renders:
Section
└── Page
├── Question
└── Question
The QuestionSets, or nested QuestionSets, are missing.
The current templates may explain the behavior:
It renders Section and Page titles and delegates each Page element to:
For Questions, project_answers_element.html renders the question text and corresponding values. For QuestionSets, however, it only recursively renders the contained elements:
The available element.title is not rendered.
Regression
This also seems to be at least partly a regression.
The implementation associated with #318 / #320 previously rendered top-level QuestionSet titles in project_answers_tree.html:
https://github.com/rdmorganiser/rdmo/pull/320
<h3>{{ questionset.title }}</h3>
Later, when the Page model was introduced in:
https://github.com/rdmorganiser/rdmo/commit/471c4089922714bda14a58169f800de7e54d4989
the tree changed approximately from:
{% for questionset in section.questionsets.all %}
<h3>{{ questionset.title }}</h3>
...
{% endfor %}
to:
{% for page in section.pages.all %}
<h3>{{ page.title }}</h3>
{% for element in page.elements %}
{% include 'projects/project_answers_element.html' %}
{% endfor %}
{% endfor %}
Since the recursive project_answers_element.html template does not render QuestionSet titles itself, the QuestionSet heading disappeared from "View Answers".
Nested QuestionSets appear to have had the same problem already when support for nested QuestionSets was introduced.
Expected behaviour / Erwartetes Verhalten
"View Answers" should preserve the structural hierarchy of the catalog and display QuestionSet titles before their contained questions/elements.
For example:
Section title
Page title
QuestionSet title
Question?
Answer
Question?
Answer
Another QuestionSet
Question?
Answer
Nested QuestionSets should also retain their titles, for example:
Page
└── QuestionSet A
└── QuestionSet B
└── Question
should not be flattened to:
Page
└── Question
The exact HTML heading levels or styling could follow the existing hierarchy. For example, Section and Page currently use h2 and h3; QuestionSets could use an appropriate lower-level heading or dedicated styling.
Empty QuestionSet titles should of course not result in empty headings.
QuestionSet titles should support Markdown consistently with the existing Section/Page titles.
Exports
The same hierarchy should also be retained in exports created from the "View Answers" page.
project_answers_export.html uses the same tree:
{% include 'projects/project_answers_tree.html' %}
so fixing the recursive tree rendering should also make QuestionSet titles available in the corresponding answer exports.
Steps to reproduce / Schritte zum Reproduzieren
-
Create or use a Catalog containing:
- a Section and a Page
- a QuestionSet with a non-empty title,
- one or more Questions inside that QuestionSet.
-
Create a Project using the Catalog.
-
Answer the Questions.
-
Open View Answers.
-
See that the Section title, Page title, Questions and Answers are displayed, but the QuestionSet title is missing.
-
Optionally create a nested QuestionSet and observe that its title is missing as well.
-
Export the answers from this page and observe the same missing QuestionSet structure.
References / Verweise
- Current answers tree:
https://github.com/rdmorganiser/rdmo/blob/main/rdmo/projects/templates/projects/project_answers_tree.html - Current recursive element template:
https://github.com/rdmorganiser/rdmo/blob/main/rdmo/projects/templates/projects/project_answers_element.html - Current interview QuestionSet component:
https://github.com/rdmorganiser/rdmo/blob/main/rdmo/projects/assets/js/interview/components/main/questionset/QuestionSet.js - Previous related "View Answers" bug:
https://github.com/rdmorganiser/rdmo/issues/318 - Previous fix that still rendered QuestionSet titles:
https://github.com/rdmorganiser/rdmo/pull/320 - Page-model refactor where the direct QuestionSet heading was removed:
https://github.com/rdmorganiser/rdmo/commit/471c4089922714bda14a58169f800de7e54d4989
Contributor 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.
Assessment
This issue has not been assessed yet.