Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The fixes that i promised #63

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions FileHelpers/excelLoaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def loadSpecialCases():
"""
specialCasesDF = loadExcel(DEFAULT_SPECIAL_CASES_SEARCH_PATH, promptIfError=False, directoriesToCheck=["./"])

specialCasesDF = specialCasesDF.astype({"CWID": str})

if specialCasesDF.empty:
print("Failed to automatically load special cases file. Please enter file name")
Expand Down Expand Up @@ -89,12 +88,9 @@ def loadSpecialCases():
return createEmptySpecialCasesSheet()

# We want to non-destructively get the multipass so that it is easier to use the spreadsheet later
specialCasesDF['multipass'] = ""

# Get multipass from email
for i, row in specialCasesDF.iterrows():
specialCasesDF.at[i, 'multipass'] = row['CWID']
specialCasesDF['multipass'] = specialCasesDF["CWID"]

specialCasesDF['multipass'] = specialCasesDF['multipass'].apply(lambda x: f"{x:.0f}")
# Set the date to be a date
# specialCasesDF['new_due_date'] = pd.to_datetime(specialCasesDF['new_due_date'])

Expand Down
20 changes: 11 additions & 9 deletions Grade/grade.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,16 @@ def validateAndUpdateStatusAssignments(_gradescopeDF: pd.DataFrame,
elif _specialCasesDF.loc[currentSpecialCase, 'handled'].values[0] != "":
continue

if _specialCasesDF.loc[currentSpecialCase, 'extension_type'] in _statusAssignmentsDF['trigger'].values:
indexToAccess = len(_specialCasesDF.loc[currentSpecialCase, 'extension_type'].values) - 1

if _specialCasesDF.loc[currentSpecialCase, 'extension_type'].values[indexToAccess] in _statusAssignmentsDF['trigger'].values:
# Create a bool mask for the current status assignment score for the student and the correct trigger
currentStatusAssignment = \
(_statusAssignmentScoresDF['multipass'] == row['multipass']) & \
(_statusAssignmentScoresDF['status_assignment_id'] ==
(_statusAssignmentsDF.loc[_statusAssignmentsDF['trigger'] ==
_specialCasesDF.loc[currentSpecialCase, 'extension_type'].values[0],
'id'].values[0]))
_specialCasesDF.loc[currentSpecialCase, 'extension_type'].values[indexToAccess],
'id'].values[indexToAccess]))
# Check to make sure that the student actually has a value for the status assignment
# This should only happen if the student dropped, or recently added and does not yet have a score
# for the assignment, either way, it will require manual intervention.
Expand All @@ -165,8 +167,8 @@ def validateAndUpdateStatusAssignments(_gradescopeDF: pd.DataFrame,
"Unable to process triggered special case: No status assignment found for student"

# if the student requested more of an extension than they were entitled to
elif _statusAssignmentScoresDF.loc[currentStatusAssignment, 'student_score'].values[0] < \
_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[0]:
elif _statusAssignmentScoresDF.loc[currentStatusAssignment, 'student_score'].values[indexToAccess] < \
_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[indexToAccess]:

_specialCasesDF.loc[currentSpecialCase, 'handled'] = "FALSE"
_specialCasesDF.loc[currentSpecialCase, 'grader_notes'] = \
Expand All @@ -178,14 +180,14 @@ def validateAndUpdateStatusAssignments(_gradescopeDF: pd.DataFrame,
f"Automatically Approved on {datetime.date.today().strftime('%m-%d-%y')}"

_statusAssignmentScoresDF.loc[currentStatusAssignment, 'student_score'] -= \
_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[0]
_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[indexToAccess]

_specialCasesDF.loc[currentSpecialCase, 'approved_by'] = "AUTOMATIC APPROVAL"
extensionMessage: str = p.plural(_specialCasesDF.loc[currentSpecialCase, 'extension_type'].values[0],
_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[0])
extensionMessage: str = p.plural(_specialCasesDF.loc[currentSpecialCase, 'extension_type'].values[indexToAccess],
_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[indexToAccess])

_gradescopeDF.at[i, 'lateness_comment'] = \
f"Extended with {_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[0]} " + \
f"Extended with {_specialCasesDF.loc[currentSpecialCase, 'extension_days'].values[indexToAccess]} " + \
f"{extensionMessage}"

return _gradescopeDF, _specialCasesDF, _statusAssignmentScoresDF
Expand Down
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ async def main():
and "bartik_username" in loadedConfig.keys() \
and "bartik_password" in loadedConfig.keys() \
and "bartik_course" in loadedConfig.keys():
bartik = Bartik(loadedConfig["bartik_url"], loadedConfig["bartik_username"], loadedConfig["bartik_password"], loadedConfig['bartik_course'])
try:
bartik = Bartik(loadedConfig["bartik_url"], loadedConfig["bartik_username"], loadedConfig["bartik_password"], loadedConfig['bartik_course'])
except:
print("Failed to connect to bartik")
bartik = None

operation = mainMenu()
if not await operation(canvas=canvas, azure=azure, bartik=bartik, latePenalty=loadedConfig['late_penalties']):
Expand Down
Loading