Databricks Interview Question

basic trigger code on task, need to calculate total open and closed task and update to related case and opportunity object.