Merge branch 'approval-workflows' into develop
This commit is contained in:
@@ -17,6 +17,7 @@ import ListeningComponents from "./listening/components";
|
||||
import ReadingComponents from "./reading/components";
|
||||
import SpeakingComponents from "./speaking/components";
|
||||
import SectionPicker from "./Shared/SectionPicker";
|
||||
import { getExamById } from "@/utils/exams";
|
||||
|
||||
|
||||
const LevelSettings: React.FC = () => {
|
||||
@@ -194,7 +195,7 @@ const LevelSettings: React.FC = () => {
|
||||
category: s.settings.category
|
||||
};
|
||||
}).filter(part => part.exercises.length > 0),
|
||||
isDiagnostic: false,
|
||||
isDiagnostic: true, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
||||
minTimer,
|
||||
module: "level",
|
||||
id: title,
|
||||
@@ -213,6 +214,36 @@ const LevelSettings: React.FC = () => {
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
|
||||
const requestBody = await (async () => {
|
||||
const handledExam = await getExamById("level", result.data.id);
|
||||
return {
|
||||
examAuthor: handledExam?.createdBy ?? "Unknown Author",
|
||||
examEntities: handledExam?.entities ?? [],
|
||||
examId: handledExam?.id ?? "Unknown ID",
|
||||
examModule: "level"
|
||||
};
|
||||
})();
|
||||
await axios
|
||||
.post(`/api/approval-workflows`, requestBody)
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
toast.success(`Approval Workflows for exam have been successfully created`);
|
||||
} else if (response.status === 207) {
|
||||
toast.warning(
|
||||
`Approval Workflows were partially created. Exam author might not have a configured workflow for all its entities.`
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (reason.response?.status === 404) {
|
||||
toast.error("No configured workflow found for examAuthor for any of its entities.");
|
||||
} else {
|
||||
toast.error(
|
||||
"Something went wrong while creating approval workflow, please try again later."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error: any) {
|
||||
console.error('Error submitting exam:', error);
|
||||
toast.error(
|
||||
|
||||
@@ -17,6 +17,7 @@ import { usePersistentExamStore } from "@/stores/exam";
|
||||
import { playSound } from "@/utils/sound";
|
||||
import { toast } from "react-toastify";
|
||||
import ListeningComponents from "./components";
|
||||
import { getExamById } from "@/utils/exams";
|
||||
|
||||
const ListeningSettings: React.FC = () => {
|
||||
const router = useRouter();
|
||||
@@ -137,7 +138,7 @@ const ListeningSettings: React.FC = () => {
|
||||
category: s.settings.category
|
||||
};
|
||||
}),
|
||||
isDiagnostic: false,
|
||||
isDiagnostic: true, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
||||
minTimer,
|
||||
module: "listening",
|
||||
id: title,
|
||||
@@ -151,6 +152,36 @@ const ListeningSettings: React.FC = () => {
|
||||
playSound("sent");
|
||||
toast.success(`Submitted Exam ID: ${result.data.id}`);
|
||||
|
||||
const requestBody = await (async () => {
|
||||
const handledExam = await getExamById("listening", result.data.id);
|
||||
return {
|
||||
examAuthor: handledExam?.createdBy ?? "Unknown Author",
|
||||
examEntities: handledExam?.entities ?? [],
|
||||
examId: handledExam?.id ?? "Unknown ID",
|
||||
examModule: "listening"
|
||||
};
|
||||
})();
|
||||
await axios
|
||||
.post(`/api/approval-workflows`, requestBody)
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
toast.success(`Approval Workflows for exam have been successfully created`);
|
||||
} else if (response.status === 207) {
|
||||
toast.warning(
|
||||
`Approval Workflows were partially created. Exam author might not have a configured workflow for all its entities.`
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (reason.response?.status === 404) {
|
||||
toast.error("No configured workflow found for examAuthor for any of its entities.");
|
||||
} else {
|
||||
toast.error(
|
||||
"Something went wrong while creating approval workflow, please try again later."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
toast.error('No audio sections found in the exam! Please either import them or generate them.');
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import axios from "axios";
|
||||
import { playSound } from "@/utils/sound";
|
||||
import { toast } from "react-toastify";
|
||||
import ReadingComponents from "./components";
|
||||
import { getExamById } from "@/utils/exams";
|
||||
|
||||
const ReadingSettings: React.FC = () => {
|
||||
const router = useRouter();
|
||||
@@ -46,15 +47,15 @@ const ReadingSettings: React.FC = () => {
|
||||
{
|
||||
label: "Preset: Reading Passage 1",
|
||||
value: "Welcome to {part} of the {label}. You will read texts relating to everyday topics and situations. These may include advertisements, brochures, manuals, or official documents. Answer questions that test your ability to locate specific information and understand main ideas."
|
||||
},
|
||||
{
|
||||
label: "Preset: Reading Passage 2",
|
||||
},
|
||||
{
|
||||
label: "Preset: Reading Passage 2",
|
||||
value: "Welcome to {part} of the {label}. You will read texts dealing with general interest topics that may include news articles, company policies, or workplace documents. Answer questions testing your understanding of main ideas, specific details, and the author's views."
|
||||
},
|
||||
{
|
||||
},
|
||||
{
|
||||
label: "Preset: Reading Passage 3",
|
||||
value: "Welcome to {part} of the {label}. You will read longer academic texts that may include journal articles, academic essays, or research papers. Answer questions testing your ability to understand complex arguments, identify key points, and follow the development of ideas."
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const canPreviewOrSubmit = sections.some(
|
||||
@@ -75,7 +76,7 @@ const ReadingSettings: React.FC = () => {
|
||||
category: localSettings.category
|
||||
};
|
||||
}),
|
||||
isDiagnostic: false,
|
||||
isDiagnostic: true, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
||||
minTimer,
|
||||
module: "reading",
|
||||
id: title,
|
||||
@@ -89,11 +90,37 @@ const ReadingSettings: React.FC = () => {
|
||||
.then((result) => {
|
||||
playSound("sent");
|
||||
toast.success(`Submitted Exam ID: ${result.data.id}`);
|
||||
return getExamById("reading", result.data.id);
|
||||
})
|
||||
.then((handledExam) => {
|
||||
const requestBody = {
|
||||
examAuthor: handledExam?.createdBy ?? "Unknown Author",
|
||||
examEntities: handledExam?.entities ?? [],
|
||||
examId: handledExam?.id ?? "Unknown ID",
|
||||
examModule: "reading"
|
||||
};
|
||||
|
||||
return axios.post(`/api/approval-workflows`, requestBody);
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
toast.success(`Approval Workflows for exam have been successfully created`);
|
||||
} else if (response.status === 207) {
|
||||
toast.warning(
|
||||
`Approval Workflows were partially created. Exam author might not have a configured workflow for all its entities.`
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
toast.error(error.response.data.error || "Something went wrong while submitting, please try again later.");
|
||||
})
|
||||
if (error.response && error.response.status === 404) {
|
||||
toast.error("No configured workflow found for examAuthor for any of its entities.");
|
||||
} else {
|
||||
toast.error(
|
||||
error.response?.data?.error ||
|
||||
"Something went wrong, please try again later."
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const preview = () => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import openDetachedTab from "@/utils/popout";
|
||||
import axios from "axios";
|
||||
import { playSound } from "@/utils/sound";
|
||||
import SpeakingComponents from "./components";
|
||||
import { getExamById } from "@/utils/exams";
|
||||
|
||||
export interface Avatar {
|
||||
name: string;
|
||||
@@ -180,7 +181,7 @@ const SpeakingSettings: React.FC = () => {
|
||||
minTimer,
|
||||
module: "speaking",
|
||||
id: title,
|
||||
isDiagnostic: false,
|
||||
isDiagnostic: true, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
||||
variant: undefined,
|
||||
difficulty,
|
||||
instructorGender: "varied",
|
||||
@@ -194,6 +195,36 @@ const SpeakingSettings: React.FC = () => {
|
||||
Array.from(urlMap.values()).forEach(url => {
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
|
||||
const requestBody = await (async () => {
|
||||
const handledExam = await getExamById("speaking", result.data.id);
|
||||
return {
|
||||
examAuthor: handledExam?.createdBy ?? "Unknown Author",
|
||||
examEntities: handledExam?.entities ?? [],
|
||||
examId: handledExam?.id ?? "Unknown ID",
|
||||
examModule: "speaking"
|
||||
};
|
||||
})();
|
||||
await axios
|
||||
.post(`/api/approval-workflows`, requestBody)
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
toast.success(`Approval Workflows for exam have been successfully created`);
|
||||
} else if (response.status === 207) {
|
||||
toast.warning(
|
||||
`Approval Workflows were partially created. Exam author might not have a configured workflow for all its entities.`
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (reason.response?.status === 404) {
|
||||
toast.error("No configured workflow found for examAuthor for any of its entities.");
|
||||
} else {
|
||||
toast.error(
|
||||
"Something went wrong while creating approval workflow, please try again later."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error: any) {
|
||||
toast.error(
|
||||
|
||||
@@ -12,6 +12,8 @@ import axios from "axios";
|
||||
import { playSound } from "@/utils/sound";
|
||||
import { toast } from "react-toastify";
|
||||
import WritingComponents from "./components";
|
||||
import { getExamById } from "@/utils/exams";
|
||||
import { ApprovalWorkflow } from "@/interfaces/approval.workflow";
|
||||
|
||||
const WritingSettings: React.FC = () => {
|
||||
const router = useRouter();
|
||||
@@ -129,7 +131,7 @@ const WritingSettings: React.FC = () => {
|
||||
minTimer,
|
||||
module: "writing",
|
||||
id: title,
|
||||
isDiagnostic: false,
|
||||
isDiagnostic: true, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
||||
variant: undefined,
|
||||
difficulty,
|
||||
private: isPrivate,
|
||||
@@ -140,6 +142,36 @@ const WritingSettings: React.FC = () => {
|
||||
playSound("sent");
|
||||
toast.success(`Submitted Exam ID: ${result.data.id}`);
|
||||
|
||||
const requestBody = await (async () => {
|
||||
const handledExam = await getExamById("writing", result.data.id);
|
||||
return {
|
||||
examAuthor: handledExam?.createdBy ?? "Unknown Author",
|
||||
examEntities: handledExam?.entities ?? [],
|
||||
examId: handledExam?.id ?? "Unknown ID",
|
||||
examModule: "writing"
|
||||
};
|
||||
})();
|
||||
await axios
|
||||
.post(`/api/approval-workflows`, requestBody)
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
toast.success(`Approval Workflows for exam have been successfully created`);
|
||||
} else if (response.status === 207) {
|
||||
toast.warning(
|
||||
`Approval Workflows were partially created. Exam author might not have a configured workflow for all its entities.`
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (reason.response?.status === 404) {
|
||||
toast.error("No configured workflow found for examAuthor for any of its entities.");
|
||||
} else {
|
||||
toast.error(
|
||||
"Something went wrong while creating approval workflow, please try again later."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error: any) {
|
||||
console.error('Error submitting exam:', error);
|
||||
toast.error(
|
||||
|
||||
Reference in New Issue
Block a user