Created
January 14, 2014 07:15
-
-
Save mtomwing/8414391 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'courses.settings') | |
from gpaconvert.models import GradeSource, DiscreteRule, ContinuousRule | |
GradeSource.objects.all().delete() | |
DISCRETE_GRADES = ( | |
('Super Sully', 'A'), | |
('Mediocre Mike', 'C'), | |
) | |
CONTINUOUS_GRADES = ( | |
(100.0, 'A+'), | |
(50.0, 'C'), | |
(0.0, 'F'), | |
) | |
monsters_uni = GradeSource.objects.create(country='CA', | |
institution='Monsters University', | |
status='ACTI') | |
for source, target in DISCRETE_GRADES: | |
monsters_uni.discrete_rules.add(DiscreteRule(lookup_value=source, | |
transfer_value=target)) | |
monsters_uni.save() | |
balls_uni = GradeSource.objects.create(country='US', | |
institution='Ball State University', | |
scale='CONT', | |
status='ACTI') | |
for source, target in CONTINUOUS_GRADES: | |
balls_uni.continuous_rules.add(ContinuousRule(lookup_lbound=source, | |
transfer_value=target)) | |
balls_uni.save() | |
# SOME TESTCASES | |
print monsters_uni.get_rule('Super Sully') | |
print monsters_uni.get_rule('Mediocre Mike') | |
print monsters_uni.get_rule('Fail Frank') | |
print balls_uni.get_rule(50) | |
print balls_uni.get_rule(30.5) | |
print balls_uni.get_rule(-100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment