Update speaking 1 to be like interactive with 5 questions and 2 topics.
This commit is contained in:
@@ -29,26 +29,32 @@ GET_HEADER = {
|
||||
|
||||
|
||||
def create_videos_and_save_to_db(exercises, template, id):
|
||||
avatar = random.choice(list(AvatarEnum))
|
||||
# Speaking 1
|
||||
# Using list comprehension to find the element with the desired value in the 'type' field
|
||||
found_exercises_1 = [element for element in exercises if element.get('type') == 1]
|
||||
# Check if any elements were found
|
||||
if found_exercises_1:
|
||||
exercise_1 = found_exercises_1[0]
|
||||
sp1_questions = []
|
||||
app.app.logger.info('Creating video for speaking part 1')
|
||||
sp1_result = create_video(exercise_1["question"], random.choice(list(AvatarEnum)))
|
||||
if sp1_result is not None:
|
||||
sound_file_path = 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)
|
||||
sp1_video_path = firebase_file_path
|
||||
sp1_video_url = url
|
||||
template["exercises"][0]["text"] = exercise_1["question"]
|
||||
template["exercises"][0]["title"] = exercise_1["topic"]
|
||||
template["exercises"][0]["video_url"] = sp1_video_url
|
||||
template["exercises"][0]["video_path"] = sp1_video_path
|
||||
else:
|
||||
app.app.logger.error("Failed to create video for part 1 question: " + exercise_1["question"])
|
||||
for question in exercise_1["questions"]:
|
||||
sp1_result = create_video(question, avatar)
|
||||
if sp1_result is not None:
|
||||
sound_file_path = 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)
|
||||
video = {
|
||||
"text": question,
|
||||
"video_path": firebase_file_path,
|
||||
"video_url": url
|
||||
}
|
||||
sp1_questions.append(video)
|
||||
else:
|
||||
app.app.logger.error("Failed to create video for part 1 question: " + exercise_1["question"])
|
||||
template["exercises"][0]["prompts"] = sp1_questions
|
||||
template["exercises"][0]["first_title"] = exercise_1["first_topic"]
|
||||
template["exercises"][0]["second_title"] = exercise_1["second_topic"]
|
||||
|
||||
# Speaking 2
|
||||
# Using list comprehension to find the element with the desired value in the 'type' field
|
||||
@@ -57,7 +63,7 @@ def create_videos_and_save_to_db(exercises, template, id):
|
||||
if found_exercises_2:
|
||||
exercise_2 = found_exercises_2[0]
|
||||
app.app.logger.info('Creating video for speaking part 2')
|
||||
sp2_result = create_video(exercise_2["question"], random.choice(list(AvatarEnum)))
|
||||
sp2_result = create_video(exercise_2["question"], avatar)
|
||||
if sp2_result is not None:
|
||||
sound_file_path = VIDEO_FILES_PATH + sp2_result
|
||||
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp2_result
|
||||
@@ -79,7 +85,6 @@ def create_videos_and_save_to_db(exercises, template, id):
|
||||
if found_exercises_3:
|
||||
exercise_3 = found_exercises_3[0]
|
||||
sp3_questions = []
|
||||
avatar = random.choice(list(AvatarEnum))
|
||||
app.app.logger.info('Creating videos for speaking part 3')
|
||||
for question in exercise_3["questions"]:
|
||||
result = create_video(question, avatar)
|
||||
|
||||
Reference in New Issue
Block a user