Fixed a bug from the previous commit, ENCOA-274
This commit is contained in:
@@ -126,7 +126,7 @@ const WritingComponents: React.FC<Props> = ({ localSettings, updateLocalAndSched
|
||||
</div>
|
||||
</Dropdown>}
|
||||
{
|
||||
type !== "academic" || (type === "academic" && academic_url !== undefined) && <Dropdown
|
||||
(type !== "academic" || (type === "academic" && academic_url !== undefined)) && <Dropdown
|
||||
title="Generate Instructions"
|
||||
module={"writing"}
|
||||
open={localSettings.isWritingTopicOpen}
|
||||
|
||||
@@ -93,14 +93,12 @@ const WritingSettings: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let firebase_url = undefined;
|
||||
let firebase_url: string | undefined = undefined;
|
||||
if (type === "academic" && academic_url) {
|
||||
const formData = new FormData();
|
||||
const sectionMap = new Map<number, string>();
|
||||
const fetchedBlob = await fetch(academic_url);
|
||||
const blob = await fetchedBlob.blob();
|
||||
formData.append('file', blob);
|
||||
sectionMap.set(1, academic_url);
|
||||
|
||||
const response = await axios.post('/api/storage', formData, {
|
||||
params: {
|
||||
@@ -110,13 +108,13 @@ const WritingSettings: React.FC = () => {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
});
|
||||
firebase_url = response.data.urls[1];
|
||||
firebase_url = response.data.urls[0];
|
||||
}
|
||||
|
||||
const exam: WritingExam = {
|
||||
exercises: sections.map((s) => {
|
||||
exercises: sections.map((s, index) => {
|
||||
const exercise = s.state as WritingExercise;
|
||||
if (exercise.sectionId == 1 && firebase_url) {
|
||||
if (index == 0 && firebase_url) {
|
||||
exercise["attachment"] = {
|
||||
url: firebase_url,
|
||||
description: "Visual Information"
|
||||
|
||||
Reference in New Issue
Block a user