Commit 771348e6 by Braden MacDonald

Fix: never color a row when there's no answer submitted

parent 9a795674
...@@ -301,10 +301,13 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock): ...@@ -301,10 +301,13 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
block['mcqs'].append({ block['mcqs'].append({
"display_name": mcq_block.question, "display_name": mcq_block.question,
"value": value, "value": value,
"color": self.color_for_value(value), "color": self.color_for_value(value) if value is not None else None,
}) })
# If the values are numeric, display an average: # If the values are numeric, display an average:
numeric_values = [float(mcq['value']) for mcq in block['mcqs'] if mcq['value'] and mcq['value'].isnumeric()] numeric_values = [
float(mcq['value']) for mcq in block['mcqs']
if mcq['value'] is not None and mcq['value'].isnumeric()
]
if numeric_values: if numeric_values:
average_value = sum(numeric_values) / len(numeric_values) average_value = sum(numeric_values) / len(numeric_values)
block['average'] = average_value block['average'] = average_value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment