firstdraft / appdev_template

A Rails template for generating homework projects
0 stars 1 forks source link

Fix infinity score issue #156

Closed jelaniwoods closed 4 years ago

jelaniwoods commented 4 years ago

Related to https://github.com/firstdraft/grades/issues/444

If a 0/0 is achieved, via an error and it happens to be any one of the non late scores it will have a score of "Infinity", which is a String and prevents the score of the Submission from being updated. It doesn't matter how late the "Infinity" shows up, as long as it's before the due date. Since the builds will be ordered by score and Strings are ordered before Floats.

The NAN issue that was "resolved" in firstdraft/appdev_template#113 was to address specifically "Nan %" being displayed on assignments that had no specs. The change only modified the display score, not that the actual "score" part of the Build's test_output column. That change is no longer relevant since grades now conditionally hides builds and stuff if there are no tests.

This change makes the "score" zero, if there are no tests and displays a message that there is an error in the tests..

Since rails grade is just running

rspec --order default --format JsonOutputFormatter

If you run that rspec command in a project has an error that prevents the tests from fully running it produces something like:

{"summary" => 
  {
    "score"=>"Infinity",
    "duration"=>5.702e-05,
    "total_points"=>0,
    "earned_points"=>0,
    "example_count"=>0,
    "failure_count"=>0,
    "pending_count"=>0
  },
  "version"=>"3.9.2", 
  "examples"=>[],
  "messages"=>["No examples found."],
  "summary_line"=>"0 tests, 0 failures, 0/0 points, This project is not graded."
}

This change fixes it so that it does

{"summary" => 
  {
    "score"=>0,
    "duration"=>5.702e-05,
    "total_points"=>0,
    "earned_points"=>0,
    "example_count"=>0,
    "failure_count"=>0,
    "pending_count"=>0
  },
  "version"=>"3.9.2", 
  "examples"=>[],
  "messages"=>["No examples found."],
  "summary_line"=>"0 tests, 0 failures, 0/0 points, An error occurred while running tests"
}

Do this

Screen Shot 2020-07-16 at 6 30 59 PM

I suddenly stopped being able to replicate this error— but you can check the Submission#"faa0bd24-624f-43af-8597-24ad06399967" for the Infinity nonsense.

raghubetina commented 4 years ago

@jelaniwoods LGTM, thank you!