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