Skip to content

accept multiple answers as correct #3

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
19 changes: 19 additions & 0 deletions app/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,28 @@ def evaluation_function(response, answer, params) -> dict:
return types and that evaluation_function() is the main function used
to output the grading response.
"""
#Accept multiple different answers as correct
answer.strip()
response.strip()

if answer.find(",") != -1:
if response.find(",") != -1:
response_list = re.split(r", |,| ,", response)
answer_list = re.split(r", |,| ,", answer)

answer = ''
response = ''

for i in range(len(answer_list)):
for j in range(len(response_list)):
if response_list[j] == answer_list[i]:
answer = answer + answer_list[i] + ', '
response = response + response_list[j] + ', '

from sympy.parsing.sympy_parser import parse_expr
from sympy import expand, simplify, trigsimp, latex, Symbol
from sympy import pi
import re

if params.get("specialFunctions",False) == True:
from sympy import beta, gamma, zeta
Expand All @@ -42,6 +60,7 @@ def evaluation_function(response, answer, params) -> dict:

# Dealing with special cases that aren't accepted by SymPy
response, answer = Absolute(response, answer)


# Safely try to parse answer and response into symbolic expressions
try:
Expand Down