Skip to content
Snippets Groups Projects
Commit d0162dd0 authored by michael.minelli's avatar michael.minelli
Browse files

Merge branch 'exercise_delete_integration' into v4.2.0

parents ad1f8a7c fb9ee36a
No related branches found
No related tags found
No related merge requests found
Pipeline #33471 passed
......@@ -3,7 +3,7 @@
url = ../../shared/jetbrains_configuration.git
[submodule "NodeApp/src/shared"]
path = NodeApp/src/shared
url = ../../shared/nodesharedcode.git
url = https://gitedu.hesge.ch/dojo_project/projects/shared/nodesharedcode
[submodule "NodeApp/src/sharedByClients"]
path = NodeApp/src/sharedByClients
url = ../../shared/nodeclientsharedcode.git
url = https://gitedu.hesge.ch/dojo_project/projects/shared/nodeclientsharedcode
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/dojocli.iml" filepath="$PROJECT_DIR$/.idea/dojocli.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -22,6 +22,7 @@
"commander": "^12.1.0",
"form-data": "^4.0.0",
"fs-extra": "^11.2.0",
"fuse.js": "^7.0.0",
"http-status-codes": "^2.3.0",
"inquirer": "^8.2.6",
"json5": "^2.2.3",
......@@ -3552,6 +3553,14 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/fuse.js": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz",
"integrity": "sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==",
"engines": {
"node": ">=10"
}
},
"node_modules/genversion": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/genversion/-/genversion-3.2.0.tgz",
......
......@@ -8,9 +8,9 @@
"bin" : {
"dojo": "./dist/app.js"
},
"pkg" : {
"pkg": {
"scripts": [],
"assets" : [
"assets": [
"node_modules/axios/dist/node/axios.cjs",
".env",
"assets/**/*"
......
......@@ -2,6 +2,7 @@ import CommanderCommand from '../CommanderCommand.js';
import ExerciseCreateCommand from './subcommands/ExerciseCreateCommand.js';
import ExerciseRunCommand from './subcommands/ExerciseRunCommand.js';
import ExerciseCorrectionCommand from './subcommands/ExerciseCorrectionCommand.js';
import ExerciseDeleteCommand from './subcommands/ExerciseDeleteCommand';
class ExerciseCommand extends CommanderCommand {
......@@ -15,6 +16,7 @@ class ExerciseCommand extends CommanderCommand {
protected defineSubCommands() {
ExerciseCreateCommand.registerOnCommand(this.command);
ExerciseRunCommand.registerOnCommand(this.command);
ExerciseDeleteCommand.registerOnCommand(this.command);
ExerciseCorrectionCommand.registerOnCommand(this.command);
}
......
......@@ -17,8 +17,8 @@ class ExerciseCorrectionCommand extends CommanderCommand {
protected defineCommand() {
this.command
.description('link an exercise repo as a correction for an assignment')
.requiredOption('-a, --assignment <string>', 'id or url of the assignment of the correction')
.description('list corrections of an assignment')
.requiredOption('-a, --assignment <string>', 'id or url of the assignment')
.action(this.commandAction.bind(this));
}
......
import CommanderCommand from '../../CommanderCommand';
import DojoBackendManager from '../../../managers/DojoBackendManager';
import AccessesHelper from '../../../helpers/AccessesHelper';
import TextStyle from '../../../types/TextStyle';
class ExerciseDeleteCommand extends CommanderCommand {
protected commandName: string = 'delete';
protected defineCommand(): void {
this.command
.description('delete an exercise')
.argument('id or url', 'id or url of the exercise')
.action(this.commandAction.bind(this));
}
private async dataRetrieval() {
console.log(TextStyle.BLOCK('Please wait while we verify and retrieve data...'));
await AccessesHelper.checkStudent();
}
private async deleteExercise(exerciseIdOrUrl: string) {
console.log(TextStyle.BLOCK('Please wait while we are deleting the exercise...'));
await DojoBackendManager.deleteExercise(exerciseIdOrUrl);
}
protected async commandAction(exerciseIdOrUrl: string): Promise<void> {
try {
await this.dataRetrieval();
await this.deleteExercise(exerciseIdOrUrl);
} catch ( e ) { /* Do nothing */ }
}
}
export default new ExerciseDeleteCommand();
......@@ -13,6 +13,7 @@ import DojoBackendHelper from '../sharedByClients/helpers/Dojo/DojoBackendHe
import GitlabPipelineStatus from '../shared/types/Gitlab/GitlabPipelineStatus.js';
import Tag from '../sharedByClients/models/Tag';
import TagProposal from '../sharedByClients/models/TagProposal';
import Result from '../sharedByClients/models/Result';
class DojoBackendManager {
......@@ -84,7 +85,6 @@ class DojoBackendManager {
}
}
public async login(gitlabTokens: GitlabToken): Promise<User | undefined> {
try {
return (await axios.post<DojoBackendResponse<User>>(DojoBackendHelper.getApiUrl(ApiRoute.LOGIN), {
......@@ -365,6 +365,85 @@ class DojoBackendManager {
return false;
}
}
public async getUserExercises(): Promise<Array<Exercise> | undefined> {
try {
const response = await axios.get<DojoBackendResponse<Array<Exercise>>>(DojoBackendHelper.getApiUrl(ApiRoute.EXERCISE_LIST));
return response.data.data;
} catch ( error ) {
console.error('Error fetching user exercises:', error);
return undefined;
}
}
public async getExerciseDetails(exerciseIdOrUrl: string): Promise<Exercise | undefined> {
try {
const response = await axios.get<Exercise>(DojoBackendHelper.getApiUrl(ApiRoute.EXERCISE_DETAILS_GET, {
exerciseIdOrUrl: exerciseIdOrUrl
}));
return response.data;
} catch ( error ) {
console.error('Error fetching exercise details:', error);
return undefined;
}
}
public async deleteExercise(exerciseIdOrUrl: string, verbose: boolean = true): Promise<void> {
const spinner: ora.Ora = ora('Deleting exercise...');
if ( verbose ) {
spinner.start();
}
try {
await axios.delete<DojoBackendResponse<Exercise>>(DojoBackendHelper.getApiUrl(ApiRoute.EXERCISE_GET_DELETE, {
exerciseIdOrUrl: exerciseIdOrUrl
}));
if ( verbose ) {
spinner.succeed(`Exercise deleted with success`);
}
} catch ( error ) {
this.handleApiError(error, spinner, verbose, `Exercise deleting error: ${ error }`);
throw error;
}
}
public async getExerciseMembers(exerciseIdOrUrl: string): Promise<Array<User>> {
return (await axios.get<DojoBackendResponse<Array<User>>>(DojoBackendHelper.getApiUrl(ApiRoute.EXERCISE_MEMBERS_GET, {
exerciseIdOrUrl: exerciseIdOrUrl
}))).data.data;
}
public async getExerciseResults(exerciseIdOrUrl: string): Promise<Array<Result>> {
try {
const response = await axios.get(DojoBackendHelper.getApiUrl(ApiRoute.EXERCISE_RESULTS, {
exerciseIdOrUrl: exerciseIdOrUrl
}));
return response.data as Array<Result>;
} catch ( error ) {
console.error('Error fetching exercise results:', error);
return [];
}
}
public async getUsers(roleFilter?: string): Promise<Array<User> | undefined> {
try {
const response = await axios.get<DojoBackendResponse<Array<User>>>(DojoBackendHelper.getApiUrl(ApiRoute.USER_LIST), { params: roleFilter ? { roleFilter: roleFilter } : {} });
return response.data.data;
} catch ( error ) {
console.error('Error fetching professors:', error);
return undefined;
}
}
public async getTeachers(): Promise<Array<User> | undefined> {
return this.getUsers('teacher');
}
}
......
Subproject commit 8c87edbbc5734d6b85d1e52063e8d815807277c0
Subproject commit 6e46ceeabffc5ba6fdd27ca89b9b5f82c68f82de
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment