Open
Conversation
yannforget
approved these changes
Mar 11, 2026
| return ", ".join(labels) | ||
| # Fallback | ||
| if node.parent.question.type == "calculate" and node.cart_rule: | ||
| return f"'{node.cart_rule.operator} {node.cart_rule.value}'" |
Member
There was a problem hiding this comment.
We were quoting the label with single quotes because the rendering in Whimsical was broken without. Did they fix that?
Contributor
Author
There was a problem hiding this comment.
Oh I wasn't aware, I just thought it looked better without quotes and its working without errors so it seems to be fixed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR improves how link labels are generated for calculate nodes in the Mermaid form diagram. Previously, calculate nodes link labels didn’t appear. The main change in this PR is that now it retrieves choice labels directly from the Excel configuration (choices_config) when they are not available in the tree, while preserving the original behavior for other cases.
Summary of Changes
1. Retrieve labels from Excel configuration for calculate variables
Calculate variables do not contain choices in the generated form tree (reason why is not clear). However, their corresponding labels may exist in the Excel configuration used to build the form. The logic now checks if the calculate node already has choices attached in the tree. If not, it attempts to retrieve the choices from choices_config, which is populated from the Excel file. The retrieved choices are converted into Choice objects and filtered using the existing
filter_choiceslogic based on the CART rule. If matching labels are found, they are used for the diagram link.Examples from IDN TT (these labels were missing before)


2. Attach choices to dead-end nodes (exit_deadends) - (TODO: Test This)
In
options.py, the exit_deadends function was updated to setNew_node.question.choices_from_parentwhen generating nodes for dead-end paths. Dead-end nodes are created when the CART tree reaches a branch without a valid next node. Since these nodes are not produced through the standard CART branching logic, they do not automatically carry the choice labels required for diagram edges. Byattaching choices_from_parent, the diagram generation logic can correctly display the labels for these edges.3. Handle empty or missing
cart_valuein filter_choicesThe
filter_choicesfunction was updated to skip choices with missing target values. This prevents runtime errors when the code attempts to convert an empty or missing value to a numeric type during CART rule comparisons (e.g. when evaluating conditions like > 1.5).Without this safeguard, the filtering logic raises exceptions when encountering non-numeric values.
An example of this would be the
vehic_index_catvariable in IDN TT in which is a 'calculate' node but doesn't have target values and the variablevehic_indexis not present in the excel configuration so it would raise an exception.Current Issue (Not resolved)
Notes
There were changes to the
create_xlsformpipeline too and its PR should be merged before this one to avoid errors. PR Link