THINK FIRST·CODE LATER

← All labs

A dashboard design linter

Problem

Read a JSON description of a dashboard: title, audience, shows_last_updated (boolean) and panels, each with id, kind (kpi, chart, table, map, image…), row, col, priority (1 = most important) and optionally task, comparison (boolean), colors (number).

Print dashboard 'City air' for city officials: 4 panels, then issues in this order:

  • D1 more than 9 panels: D1 12 panels: too many for one screen (aim for at most 9);
  • D2 the panel with the smallest priority number (first if tied) is not at row 0, col 0: D2 most important panel 'mean_pm25' is at row 0, col 1 (put it top-left);
  • for each panel in order: D3 a kpi without comparison: D3 KPI 'x' has no comparison (target, previous period or benchmark); D4 no task: D4 panel 'logo' serves no stated task; D5 more than 9 colours: D5 panel 'trend' uses 12 colours;
  • D6 shows_last_updated false: D6 no 'last updated' time shown (users cannot judge freshness);
  • D7 for each task used by more than one panel (first-appearance order): D7 2 panels serve the same task 'compare trends by district' (redundant?).

Finish with 6 issue(s) or no issues found.

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

v9-4-data-1.jsonl

{"title": "City air", "audience": "city officials", "shows_last_updated": false,
 "panels": [
  {"id": "logo", "kind": "image", "row": 0, "col": 0, "priority": 5},
  {"id": "mean_pm25", "kind": "kpi", "row": 0, "col": 1, "priority": 1, "task": "lookup current city mean"},
  {"id": "trend", "kind": "chart", "row": 1, "col": 0, "priority": 2, "task": "compare trends by district", "colors": 12, "comparison": true},
  {"id": "trend2", "kind": "chart", "row": 1, "col": 1, "priority": 3, "task": "compare trends by district", "colors": 6}
 ]}
What your program must print for v9-4-data-1.jsonl
dashboard 'City air' for city officials: 4 panels
D2 most important panel 'mean_pm25' is at row 0, col 1 (put it top-left)
D4 panel 'logo' serves no stated task
D3 KPI 'mean_pm25' has no comparison (target, previous period or benchmark)
D5 panel 'trend' uses 12 colours
D6 no 'last updated' time shown (users cannot judge freshness)
D7 2 panels serve the same task 'compare trends by district' (redundant?)
6 issue(s)

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), in the folder that holds both files:

python my_lab.py < v9-4-data-1.jsonl

Windows PowerShell (the default terminal of VS Code on Windows) does not understand <:

Get-Content v9-4-data-1.jsonl | python my_lab.py

PyCharm: Run → Edit Configurations → tick Redirect input from and choose the file.

Jupyter: put this at the top of the cell that holds your program:

import sys
sys.stdin = open("v9-4-data-1.jsonl", encoding="utf-8")

Write it here, in Jupyter or in your IDE, then paste it. Run it on the sample input yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.