30 lines
1.3 KiB
Python
Executable File
30 lines
1.3 KiB
Python
Executable File
from . models import MNFLPPDDatabase, LPPTASKDatabase
|
|
|
|
|
|
def assignment_algo():
|
|
X = LPPTASKDatabase()
|
|
if MNFLPPDDatabase.objects.filter(firstLanguage=X.firstLanguage).filter(secondLanguage=X.secondLanguage).exists():
|
|
LanguagePair = MNFLPPDDatabase.objects.filter(firstLanguage=X.firstLanguage).filter(secondLanguage=X.secondLanguage)
|
|
for i in LanguagePair:
|
|
rating = {}
|
|
score = {}
|
|
if i.level == "Expert":
|
|
if i.rating.max():
|
|
if i.score.max():
|
|
Assigned1.append(i.id)
|
|
X.assignedlpp = Assigned1[0]
|
|
elif i.level == "Proficient":
|
|
if i.rating >=1 and i.rating <=3:
|
|
if i.score >=5 and i.score <=10:
|
|
eligible.append(i.id)
|
|
X.eligiblelpp = eligible[0]
|
|
elif i.level == "Beginner":
|
|
print("This is beginner")
|
|
if i.rating >=0:
|
|
eligible.append(i.id)
|
|
X.eligiblelpp = eligible[0]
|
|
else:
|
|
print(f"No LPP found for {X.firstLanguage}, {X.secondLanguage} pair")
|
|
|
|
X.save()
|
|
return |