Fix speaking grading overall.
This commit is contained in:
28
app.py
28
app.py
@@ -660,11 +660,7 @@ def grade_speaking_task_1():
|
||||
response['transcript_' + str(i)] = answer
|
||||
response['fixed_text_' + str(i)] = get_speaking_corrections(answer)
|
||||
|
||||
if response["overall"] == "0.0" or response["overall"] == 0.0:
|
||||
response["overall"] = round((response["task_response"]["Fluency and Coherence"] +
|
||||
response["task_response"]["Lexical Resource"] + response["task_response"][
|
||||
"Grammatical Range and Accuracy"] + response["task_response"][
|
||||
"Pronunciation"]) / 4, 1)
|
||||
response["overall"] = fix_speaking_overall(response["overall"], response["task_response"])
|
||||
|
||||
logging.info("POST - speaking_task_1 - " + str(request_id) + " - Final response: " + str(response))
|
||||
return response
|
||||
@@ -830,11 +826,7 @@ def grade_speaking_task_2():
|
||||
response['fixed_text'] = get_speaking_corrections(answer)
|
||||
logging.info("POST - speaking_task_2 - " + str(request_id) + " - Fixed text: " + response['fixed_text'])
|
||||
|
||||
if response["overall"] == "0.0" or response["overall"] == 0.0:
|
||||
response["overall"] = round((response["task_response"]["Fluency and Coherence"] +
|
||||
response["task_response"]["Lexical Resource"] + response["task_response"][
|
||||
"Grammatical Range and Accuracy"] + response["task_response"][
|
||||
"Pronunciation"]) / 4, 1)
|
||||
response["overall"] = fix_speaking_overall(response["overall"], response["task_response"])
|
||||
|
||||
logging.info("POST - speaking_task_2 - " + str(request_id) + " - Final response: " + str(response))
|
||||
return response
|
||||
@@ -1121,16 +1113,24 @@ def grade_speaking_task_3():
|
||||
for i, answer in enumerate(text_answers, start=1):
|
||||
response['transcript_' + str(i)] = answer
|
||||
response['fixed_text_' + str(i)] = get_speaking_corrections(answer)
|
||||
if response["overall"] == "0.0" or response["overall"] == 0.0:
|
||||
response["overall"] = round((response["task_response"]["Fluency and Coherence"] + response["task_response"][
|
||||
"Lexical Resource"] + response["task_response"]["Grammatical Range and Accuracy"] +
|
||||
response["task_response"]["Pronunciation"]) / 4, 1)
|
||||
response["overall"] = fix_speaking_overall(response["overall"], response["task_response"])
|
||||
logging.info("POST - speaking_task_3 - " + str(request_id) + " - Final response: " + str(response))
|
||||
return response
|
||||
except Exception as e:
|
||||
return str(e), 400
|
||||
|
||||
|
||||
def fix_speaking_overall(overall: float, task_response: dict):
|
||||
grades = [category["grade"] for category in task_response.values()]
|
||||
|
||||
if overall > max(grades) or overall < min(grades):
|
||||
total_sum = sum(grades)
|
||||
average = total_sum / len(grades)
|
||||
rounded_average = round(average, 0)
|
||||
return rounded_average
|
||||
|
||||
return overall
|
||||
|
||||
@app.route('/speaking', methods=['POST'])
|
||||
@jwt_required()
|
||||
def save_speaking():
|
||||
|
||||
Reference in New Issue
Block a user