diff --git a/NodeApp/src/commander/assignment/AssignmentCommand.ts b/NodeApp/src/commander/assignment/AssignmentCommand.ts index 95fd40423a2f1c7e06c3b90d447012a085161497..7f547897650e04479fe1735d5cb3d550954d811b 100644 --- a/NodeApp/src/commander/assignment/AssignmentCommand.ts +++ b/NodeApp/src/commander/assignment/AssignmentCommand.ts @@ -4,6 +4,7 @@ import AssignmentPublishCommand from './subcommands/AssignmentPublishCommand' import AssignmentUnpublishCommand from './subcommands/AssignmentUnpublishCommand'; import AssignmentCheckCommand from './subcommands/AssignmentCheckCommand'; import AssignmentRunCommand from './subcommands/AssignmentRunCommand'; +import AssignmentDeleteCommand from './subcommands/AssignmentDeleteCommand'; // import AssignmentCorrectionCommand from './subcommands/correction/AssignmentCorrectionCommand'; @@ -21,6 +22,7 @@ class AssignmentCommand extends CommanderCommand { AssignmentRunCommand.registerOnCommand(this.command); AssignmentPublishCommand.registerOnCommand(this.command); AssignmentUnpublishCommand.registerOnCommand(this.command); + AssignmentDeleteCommand.registerOnCommand(this.command); // AssignmentCorrectionCommand.registerOnCommand(this.command); } diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts new file mode 100644 index 0000000000000000000000000000000000000000..62f8cd455257942d23f04badae50c656f826cf2f --- /dev/null +++ b/NodeApp/src/commander/assignment/subcommands/AssignmentDeleteCommand.ts @@ -0,0 +1,32 @@ +import CommanderCommand from '../../CommanderCommand'; +import DojoBackendManager from '../../../managers/DojoBackendManager'; +import AccessesHelper from '../../../helpers/AccessesHelper'; +// import GitlabManager from '../../../managers/GitlabManager'; +// import ExerciseRunHelper from '../../../helpers/Dojo/ExerciseRunHelper'; +// import ora from 'ora'; + + +class AssignmentDeleteCommand extends CommanderCommand { + protected commandName: string = 'delete'; + + protected defineCommand() { + this.command + .description('delete an assignment') + .arguments('<name>') + // .argument('-n, --name <name>', 'name of the assignment') + .action(this.commandAction.bind(this)); + } + + protected async commandAction(name : string): Promise<void> { + { + if (!await AccessesHelper.checkTeachingStaff()) { + return; + } + const tmp = await DojoBackendManager.delAssignment(name); + console.log(tmp); + } + } +} + + +export default new AssignmentDeleteCommand(); \ No newline at end of file diff --git a/NodeApp/src/managers/DojoBackendManager.ts b/NodeApp/src/managers/DojoBackendManager.ts index c2faab9199b7fa0004d67e2870f7b37585f2c45c..db889b7acef4708d6b8ade5ab76d4c38c7df1fe6 100644 --- a/NodeApp/src/managers/DojoBackendManager.ts +++ b/NodeApp/src/managers/DojoBackendManager.ts @@ -54,9 +54,9 @@ class DojoBackendManager { }); } - - public async delAssignment() : Promise<Assignment[]> { - return (await axios.get<DojoBackendResponse<Assignment[]>>(this.getApiUrl(ApiRoute.ASSIGNMENT_DEL))).data.data; + + public async delAssignment(nameOrUrl : string) : Promise<Assignment> { + return (await axios.patch<DojoBackendResponse<Assignment>>(this.getApiUrl(ApiRoute.ASSIGNMENT_DEL).replace('{{assignmentNameOrUrl}}', nameOrUrl))).data.data; } public async checkTemplateAccess(idOrNamespace: string, verbose: boolean = true): Promise<boolean> {