Actually save questions.
This commit is contained in:
57
app.py
57
app.py
@@ -166,15 +166,13 @@ def save_listening():
|
|||||||
conversation_text_to_speech(part["text"]["conversation"], sound_file_path)
|
conversation_text_to_speech(part["text"]["conversation"], sound_file_path)
|
||||||
else:
|
else:
|
||||||
text_to_speech(part["text"], sound_file_path)
|
text_to_speech(part["text"], sound_file_path)
|
||||||
# file_url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
file_url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||||
file_url = "test_url/" + firebase_file_path
|
|
||||||
template["parts"][i]["audio"]["source"] = file_url
|
template["parts"][i]["audio"]["source"] = file_url
|
||||||
template["parts"][i]["exercises"].append(part["exercises"])
|
template["parts"][i]["exercises"].append(part["exercises"])
|
||||||
# if save_to_db("listening", template):
|
if save_to_db("listening", template):
|
||||||
# return template
|
return template
|
||||||
# else:
|
else:
|
||||||
# raise Exception("Failed to save question: " + parts)
|
raise Exception("Failed to save question: " + parts)
|
||||||
return template
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
@@ -281,11 +279,10 @@ def save_writing_task():
|
|||||||
template = getWritingTemplate()
|
template = getWritingTemplate()
|
||||||
for i, exercise in enumerate(exercises, start=0):
|
for i, exercise in enumerate(exercises, start=0):
|
||||||
template["exercises"][i]["prompt"] = exercise
|
template["exercises"][i]["prompt"] = exercise
|
||||||
# if save_to_db("writing", template):
|
if save_to_db("writing", template):
|
||||||
# return template
|
return template
|
||||||
# else:
|
else:
|
||||||
# raise Exception("Failed to save writing: " + template)
|
raise Exception("Failed to save writing: " + template)
|
||||||
return template
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
@@ -459,13 +456,11 @@ def save_speaking():
|
|||||||
template = getSpeakingTemplate()
|
template = getSpeakingTemplate()
|
||||||
|
|
||||||
# Speaking 1
|
# Speaking 1
|
||||||
# sp1_result = create_video(exercises[0]["question"], random.choice(list(AvatarEnum)))
|
sp1_result = create_video(exercises[0]["question"], random.choice(list(AvatarEnum)))
|
||||||
sp1_result = "speaking_1"
|
|
||||||
if sp1_result is not None:
|
if sp1_result is not None:
|
||||||
sound_file_path = VIDEO_FILES_PATH + sp1_result
|
sound_file_path = VIDEO_FILES_PATH + sp1_result
|
||||||
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp1_result
|
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp1_result
|
||||||
# url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||||
url = "speaking_1_url"
|
|
||||||
sp1_video_path = firebase_file_path
|
sp1_video_path = firebase_file_path
|
||||||
sp1_video_url = url
|
sp1_video_url = url
|
||||||
template["exercises"][0]["text"] = exercises[0]["question"]
|
template["exercises"][0]["text"] = exercises[0]["question"]
|
||||||
@@ -476,13 +471,11 @@ def save_speaking():
|
|||||||
print("Failed to create video for part 1 question: " + exercises[0]["question"])
|
print("Failed to create video for part 1 question: " + exercises[0]["question"])
|
||||||
|
|
||||||
# Speaking 2
|
# Speaking 2
|
||||||
# sp2_result = create_video(exercises[1]["question"], random.choice(list(AvatarEnum)))
|
sp2_result = create_video(exercises[1]["question"], random.choice(list(AvatarEnum)))
|
||||||
sp2_result = "speaking_2"
|
|
||||||
if sp2_result is not None:
|
if sp2_result is not None:
|
||||||
sound_file_path = VIDEO_FILES_PATH + sp2_result
|
sound_file_path = VIDEO_FILES_PATH + sp2_result
|
||||||
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp2_result
|
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp2_result
|
||||||
# url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||||
url = "speaking_2_url"
|
|
||||||
sp2_video_path = firebase_file_path
|
sp2_video_path = firebase_file_path
|
||||||
sp2_video_url = url
|
sp2_video_url = url
|
||||||
template["exercises"][1]["prompts"] = exercises[1]["prompts"]
|
template["exercises"][1]["prompts"] = exercises[1]["prompts"]
|
||||||
@@ -497,13 +490,11 @@ def save_speaking():
|
|||||||
sp3_questions = []
|
sp3_questions = []
|
||||||
avatar = random.choice(list(AvatarEnum))
|
avatar = random.choice(list(AvatarEnum))
|
||||||
for question in exercises[2]["questions"]:
|
for question in exercises[2]["questions"]:
|
||||||
# result = create_video(question, avatar)
|
result = create_video(question, avatar)
|
||||||
result = "speaking_3"
|
|
||||||
if result is not None:
|
if result is not None:
|
||||||
sound_file_path = VIDEO_FILES_PATH + result
|
sound_file_path = VIDEO_FILES_PATH + result
|
||||||
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + result
|
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + result
|
||||||
# url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
url = upload_file_firebase_get_url(FIREBASE_BUCKET, firebase_file_path, sound_file_path)
|
||||||
url = "speaking_3_url"
|
|
||||||
video = {
|
video = {
|
||||||
"text": question,
|
"text": question,
|
||||||
"video_path": firebase_file_path,
|
"video_path": firebase_file_path,
|
||||||
@@ -515,11 +506,10 @@ def save_speaking():
|
|||||||
template["exercises"][2]["prompts"] = sp3_questions
|
template["exercises"][2]["prompts"] = sp3_questions
|
||||||
template["exercises"][2]["title"] = exercises[2]["topic"]
|
template["exercises"][2]["title"] = exercises[2]["topic"]
|
||||||
|
|
||||||
# if save_to_db("speaking", template):
|
if save_to_db("speaking", template):
|
||||||
# return template
|
return template
|
||||||
# else:
|
else:
|
||||||
# raise Exception("Failed to save speaking: " + template)
|
raise Exception("Failed to save speaking: " + template)
|
||||||
return template
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
@@ -615,11 +605,10 @@ def save_reading_passage():
|
|||||||
parts = data.get('parts')
|
parts = data.get('parts')
|
||||||
template = getReadingTemplate()
|
template = getReadingTemplate()
|
||||||
template["parts"] = parts
|
template["parts"] = parts
|
||||||
# if save_to_db("reading", template):
|
if save_to_db("reading", template):
|
||||||
# return template
|
return template
|
||||||
# else:
|
else:
|
||||||
# raise Exception("Failed to save reading: " + template)
|
raise Exception("Failed to save reading: " + template)
|
||||||
return template
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def getListeningTemplate():
|
|||||||
"exercises": []
|
"exercises": []
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"isDiagnostic": True,
|
"isDiagnostic": False,
|
||||||
"minTimer": 30,
|
"minTimer": 30,
|
||||||
"module": "listening"
|
"module": "listening"
|
||||||
}
|
}
|
||||||
@@ -715,7 +715,7 @@ def getListeningPostSample():
|
|||||||
def getReadingTemplate():
|
def getReadingTemplate():
|
||||||
return {
|
return {
|
||||||
"parts": [],
|
"parts": [],
|
||||||
"isDiagnostic": True,
|
"isDiagnostic": False,
|
||||||
"minTimer": 60,
|
"minTimer": 60,
|
||||||
"type": "academic"
|
"type": "academic"
|
||||||
}
|
}
|
||||||
@@ -1179,7 +1179,7 @@ def getSpeakingTemplate():
|
|||||||
"type": "interactiveSpeaking"
|
"type": "interactiveSpeaking"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"isDiagnostic": True,
|
"isDiagnostic": False,
|
||||||
"minTimer": 14,
|
"minTimer": 14,
|
||||||
"module": "speaking"
|
"module": "speaking"
|
||||||
}
|
}
|
||||||
@@ -1241,7 +1241,7 @@ def getWritingTemplate():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"isDiagnostic": True,
|
"isDiagnostic": False,
|
||||||
"minTimer": 60,
|
"minTimer": 60,
|
||||||
"module": "writing",
|
"module": "writing",
|
||||||
"type": "general"
|
"type": "general"
|
||||||
|
|||||||
Reference in New Issue
Block a user