Skip to content

Commit

Permalink
Merge pull request #31449 from code-dot-org/ha/ta-scholarship-criteria
Browse files Browse the repository at this point in the history
Fix teacher application scholarship evaluation
  • Loading branch information
hacodeorg committed Oct 24, 2019
2 parents 32dd6e2 + 779094b commit 48a17c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dashboard/app/models/pd/application/teacher2021_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ def meets_criteria

scores = scored_questions.map {|q| response_scores[q]}

# Need all criteria to be YES to be qualified
if scores.uniq == [YES]
YES
elsif NO.in? scores
Expand All @@ -672,12 +673,13 @@ def meets_scholarship_criteria

scores = scored_questions.map {|q| response_scores[q]}

if scores.uniq == [YES]
# Only need one of the criteria to be YES to be qualified for scholarship
if YES.in? scores
YES
elsif NO.in? scores
NO
else
elsif nil.in? scores
REVIEWING_INCOMPLETE
else
NO
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,29 @@ class Teacher2021ApplicationTest < ActiveSupport::TestCase
end
end

test 'meets_scholarship_criteria' do
application = create :pd_teacher2021_application
test_cases = [
{underrepresented_minority_percent: YES, free_lunch_percent: YES, verdict: YES},
{underrepresented_minority_percent: YES, free_lunch_percent: nil, verdict: YES},
{underrepresented_minority_percent: YES, free_lunch_percent: NO, verdict: YES},
{underrepresented_minority_percent: nil, free_lunch_percent: YES, verdict: YES},
{underrepresented_minority_percent: nil, free_lunch_percent: nil, verdict: REVIEWING_INCOMPLETE},
{underrepresented_minority_percent: nil, free_lunch_percent: NO, verdict: REVIEWING_INCOMPLETE},
{underrepresented_minority_percent: NO, free_lunch_percent: YES, verdict: YES},
{underrepresented_minority_percent: NO, free_lunch_percent: nil, verdict: REVIEWING_INCOMPLETE},
{underrepresented_minority_percent: NO, free_lunch_percent: NO, verdict: NO}
]

test_cases.each do |test_case|
input = test_case.slice(:underrepresented_minority_percent, :free_lunch_percent)
application.update(response_scores: {meets_scholarship_criteria_scores: input}.to_json)

output = application.meets_scholarship_criteria
assert_equal test_case[:verdict], output, "Wrong result for case #{input}"
end
end

test 'test update scholarship status' do
application = create :pd_teacher2021_application
assert_nil application.scholarship_status
Expand Down

0 comments on commit 48a17c7

Please sign in to comment.