Skip to content

Commit

Permalink
Allow values to to be missing
Browse files Browse the repository at this point in the history
Map missing programming/open source/etc values to "(none)".
This can be then used in the right sections in grader.conf to assign
a value. I think limesurvey should be configured to not allow incomplete
values like that, but if it wasn't, then let's make the best of this situation.

[open_source_rating]
never used = 0.0
...
(none) = 0

[python_rating]
competent = 1.0
...
(none) = 0

[vcs_rating]
no = 0
...
(none) = 0
  • Loading branch information
keszybz committed Oct 7, 2018
1 parent fab56a6 commit 8cb1bf8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions grader/grader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,10 @@ def get_rating(name, dict, key, fallback=None):
Throws MissingRating if rating is not present.
"""
key = key.partition('(')[0].partition('/')[0].strip().partition(',')[0].strip()
if key == '':
key = '(none)'
else:
key = key.partition('(')[0].partition('/')[0].strip().partition(',')[0].strip()
try:
return dict[key]
except KeyError:
Expand All @@ -1216,6 +1219,7 @@ def get_rating(name, dict, key, fallback=None):
'male' : 'M',
'other' : 'O',
'non-binary': 'O',
'' : 'U', # unknown
'prefer not to say' : 'U'
}
def gender_to_formula_label(label):
Expand All @@ -1233,7 +1237,7 @@ def rank_person(person, formula, location,
key = getattr(person, attr)
value = get_rating(attr, dict, key)
vars[attr] = value
vars.update(born=int(person.born), # if we decide to implement ageism
vars.update(born=int(person.born) if person.born else 0, # if we decide to implement ageism
gender=gender_to_formula_label(person.gender), # if we decide, …
# oh we already did
nonmale=person.nonmale,
Expand Down

2 comments on commit 8cb1bf8

@otizonaizit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but I think that limesurvey should be fixed here. As far as I know, all questions in the ASPP application form are mandatory, so this is definitely a wrong configuration.

@jni
Copy link
Contributor

@jni jni commented on 8cb1bf8 Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.