stats4sd / aec_portfolio

A proof of concept for the AEC Consortium Project Management / Assessment System
GNU General Public License v3.0
0 stars 0 forks source link

[BUG] Overall score is > 100% #97

Closed dan-tang-ssd closed 1 year ago

dan-tang-ssd commented 1 year ago

Describe the bug Overall score is > 100%

To Reproduce Go to dashboard

Expected behavior I suppose the maximum overall score is 100%. It would be helpful to share how to calculate it.

Screenshots

image

dave-mills commented 1 year ago

Ooo, this is an important one.

Looking at the demo institution's data, I see the issue is that 3 of the 4 initiatives have completed the principle assessment, but the 'completed_at' value is null.

I think this is because of issue #79, and some of the initiatives in the current dataset will have been 'finalised' before that process was fixed, causing the mismatch between completed_at and principle_status.

Details

The overall score is calculated lines 258-> in the GenericDashboardController, and uses the completed_at value to determine the count of completed initiatives.

The problem here is the discrepancy between that and the overall_score calculated on the assessment, which checks for completeness based on principle_status.

You can see the issue by adding a temporary check in GenericDashboardController (line268):

dd($allAssessments->map(fn(Assessment $assessment) => [
            'score' => $assessment->overall_score,
            'completed_at' => $assessment->completed_at,
            'principle_status' => $assessment->principle_status,
        ]));

Which gives the result:

Illuminate\Support\Collection {#1989 // app/Http/Controllers/GenericDashboardController.php:272
  #items: array:4 [
    0 => array:3 [
      "score" => 42
      "completed_at" => "2023-06-15"
      "principle_status" => "Complete"
    ]
    1 => array:3 [
      "score" => 66
      "completed_at" => null
      "principle_status" => "Complete"
    ]
    2 => array:3 [
      "score" => null
      "completed_at" => null
      "principle_status" => "Not Started"
    ]
    3 => array:3 [
      "score" => 36
      "completed_at" => null
      "principle_status" => "Complete"
    ]
  ]
  #escapeWhenCastingToString: false
}

TODO:

2 fixes needed:

  1. Harmonise the use of the various status variables. Probably we move to 'principle_status' when getting the count of completed initiatives?
  2. Double check that the completed_at variable is correctly set when finalising the principle assessment.