Skip to content

Commit

Permalink
Populate passing DEDP grades that were set to None by Admin (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
annagav authored Aug 1, 2023
1 parent 1745f24 commit e2a422a
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions courses/migrations/0040_populate_none_letter_grades_for_DEDP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Generated by Django 3.2.18 on 2023-07-27 19:33
from django.db import migrations


def convert_to_letter(grade):
"""Convert a decimal number to letter grade"""
if grade >= 0.825:
return "A"
elif grade >= 0.65:
return "B"
elif grade >= 0.55:
return "C"
elif grade >= 0.50:
return "D"
else:
return "F"


def populate_letter_grade(apps, schema_editor):
"""Populate letter grades for DEDP courses that were set to None by admin"""
CourseRunGrade = apps.get_model("courses", "CourseRunGrade")
course_ids = [
"course-v1:MITxT+14.100x",
"course-v1:MITxT+14.750x",
"course-v1:MITxT+14.740x",
"course-v1:MITxT+JPAL102x",
"course-v1:MITxT+14.73x",
"course-v1:MITxT+14.310x",
"course-v1:MITxT+14.009x",
]
grades = CourseRunGrade.objects.filter(
passed=True,
course_run__course__readable_id__in=course_ids,
letter_grade=None,
set_by_admin=True,
)
for grade in grades:
grade.letter_grade = convert_to_letter(grade.grade)
grade.save()


class Migration(migrations.Migration):

dependencies = [
("courses", "0039_program_program_type"),
]

operations = [
migrations.RunPython(populate_letter_grade, migrations.RunPython.noop),
]

0 comments on commit e2a422a

Please sign in to comment.