make access confidential when user submits exam with approval process. make access private upon approval workflow completed.
This commit is contained in:
@@ -159,7 +159,7 @@ const SettingsEditor: React.FC<SettingsEditorProps> = ({
|
|||||||
disabled={!canSubmit}
|
disabled={!canSubmit}
|
||||||
>
|
>
|
||||||
<FaFileUpload className="mr-2" size={18} />
|
<FaFileUpload className="mr-2" size={18} />
|
||||||
Submit Module as Exam
|
Submit module as exam for approval
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@@ -167,11 +167,14 @@ const SettingsEditor: React.FC<SettingsEditorProps> = ({
|
|||||||
`bg-ielts-${module}/70 border border-ielts-${module} hover:bg-ielts-${module} disabled:bg-ielts-${module}/30`,
|
`bg-ielts-${module}/70 border border-ielts-${module} hover:bg-ielts-${module} disabled:bg-ielts-${module}/30`,
|
||||||
"disabled:cursor-not-allowed disabled:text-gray-200"
|
"disabled:cursor-not-allowed disabled:text-gray-200"
|
||||||
)}
|
)}
|
||||||
onClick={() => submitModule(false)}
|
onClick={() => {
|
||||||
|
if (!confirm(`Are you sure you want to skip the approval process for this exam?`)) return;
|
||||||
|
submitModule(false);
|
||||||
|
}}
|
||||||
disabled={!canSubmit}
|
disabled={!canSubmit}
|
||||||
>
|
>
|
||||||
<FaFileUpload className="mr-2" size={18} />
|
<FaFileUpload className="mr-2" size={18} />
|
||||||
Submit Module as Exam Without Approval Process
|
Submit module as exam and skip approval process
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@@ -183,7 +186,7 @@ const SettingsEditor: React.FC<SettingsEditorProps> = ({
|
|||||||
disabled={!canPreview}
|
disabled={!canPreview}
|
||||||
>
|
>
|
||||||
<FaEye className="mr-2" size={18} />
|
<FaEye className="mr-2" size={18} />
|
||||||
Preview Module
|
Preview module
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ const LevelSettings: React.FC = () => {
|
|||||||
};
|
};
|
||||||
}).filter(part => part.exercises.length > 0),
|
}).filter(part => part.exercises.length > 0),
|
||||||
requiresApproval: requiresApproval,
|
requiresApproval: requiresApproval,
|
||||||
isDiagnostic: requiresApproval ? true : false, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
isDiagnostic: false,
|
||||||
minTimer,
|
minTimer,
|
||||||
module: "level",
|
module: "level",
|
||||||
id: title,
|
id: title,
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ const ListeningSettings: React.FC = () => {
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
requiresApproval: requiresApproval,
|
requiresApproval: requiresApproval,
|
||||||
isDiagnostic: requiresApproval ? true : false, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
isDiagnostic: false,
|
||||||
minTimer,
|
minTimer,
|
||||||
module: "listening",
|
module: "listening",
|
||||||
id: title,
|
id: title,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const ReadingSettings: React.FC = () => {
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
requiresApproval: requiresApproval,
|
requiresApproval: requiresApproval,
|
||||||
isDiagnostic: requiresApproval ? true : false, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
isDiagnostic: false,
|
||||||
minTimer,
|
minTimer,
|
||||||
module: "reading",
|
module: "reading",
|
||||||
id: title,
|
id: title,
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ const SpeakingSettings: React.FC = () => {
|
|||||||
module: "speaking",
|
module: "speaking",
|
||||||
id: title,
|
id: title,
|
||||||
requiresApproval: requiresApproval,
|
requiresApproval: requiresApproval,
|
||||||
isDiagnostic: requiresApproval ? true : false, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
isDiagnostic: false,
|
||||||
variant: undefined,
|
variant: undefined,
|
||||||
difficulty,
|
difficulty,
|
||||||
instructorGender: "varied",
|
instructorGender: "varied",
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ const WritingSettings: React.FC = () => {
|
|||||||
module: "writing",
|
module: "writing",
|
||||||
id: title,
|
id: title,
|
||||||
requiresApproval: requiresApproval,
|
requiresApproval: requiresApproval,
|
||||||
isDiagnostic: requiresApproval ? true : false, // using isDiagnostic to keep exam hidden until the respective approval workflow is completed.
|
isDiagnostic: false,
|
||||||
variant: undefined,
|
variant: undefined,
|
||||||
difficulty,
|
difficulty,
|
||||||
access,
|
access,
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
throw new Error("Name already exists");
|
throw new Error("Name already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin(user)) {
|
if (exam.requiresApproval === true) {
|
||||||
exam.isDiagnostic = false;
|
exam.access = "confidential";
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.collection(module).updateOne(
|
await db.collection(module).updateOne(
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor
|
|||||||
const handleApproveStep = () => {
|
const handleApproveStep = () => {
|
||||||
const isLastStep = (selectedStepIndex + 1 === currentWorkflow.steps.length);
|
const isLastStep = (selectedStepIndex + 1 === currentWorkflow.steps.length);
|
||||||
if (isLastStep) {
|
if (isLastStep) {
|
||||||
if (!confirm(`Are you sure you want to approve the last step? Doing so will approve the exam.`)) return;
|
if (!confirm(`Are you sure you want to approve the last step? Doing so will change the access type of the exam from confidential to private.`)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedWorkflow: ApprovalWorkflow = {
|
const updatedWorkflow: ApprovalWorkflow = {
|
||||||
@@ -192,7 +192,7 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor
|
|||||||
const examId = currentWorkflow.examId;
|
const examId = currentWorkflow.examId;
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.patch(`/api/exam/${examModule}/${examId}`, { isDiagnostic: false })
|
.patch(`/api/exam/${examModule}/${examId}`, { access: "private" })
|
||||||
.then(() => toast.success(`The exam was successfuly approved and this workflow has been completed.`))
|
.then(() => toast.success(`The exam was successfuly approved and this workflow has been completed.`))
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
if (reason.response.status === 404) {
|
if (reason.response.status === 404) {
|
||||||
|
|||||||
Reference in New Issue
Block a user