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

AssignmentCorrection => Add commit and description

parent 839567cb
No related branches found
No related tags found
No related merge requests found
......@@ -14,12 +14,22 @@ abstract class AssignmentCorrectionLinkUpdateCommand extends CommanderCommand {
.description(this.isUpdate ? 'update a correction of an assignment' : 'link an exercise repo as a correction for an assignment')
.argument('<string>', 'id or url of the exercise that is the correction')
.requiredOption('-a, --assignment <string>', 'id or url of the assignment of the correction')
.option('-c, --commit <string>', 'specific commit to link as correction (default: last commit)')
.option('-d, --description <string>', 'description of the correction (limited to 80 characters, default: empty)')
.action(this.commandAction.bind(this));
}
protected async commandAction(exerciseIdOrUrl: string, options: { assignment: string }): Promise<void> {
protected async commandAction(exerciseIdOrUrl: string, options: { assignment: string, commit?: string, description?: string }): Promise<void> {
let assignment!: Assignment | undefined;
// Check requirements
{
if ( options.description && options.description.length > 80 ) {
ora('Description is limited to 80 characters').start().fail();
return;
}
}
// Check access
{
console.log(TextStyle.BLOCK('Please wait while we check access...'));
......@@ -53,7 +63,7 @@ abstract class AssignmentCorrectionLinkUpdateCommand extends CommanderCommand {
{
console.log(TextStyle.BLOCK('Please wait while we link the exercise...'));
await DojoBackendManager.linkUpdateCorrection(exerciseIdOrUrl, assignment, this.isUpdate);
await DojoBackendManager.linkUpdateCorrection(exerciseIdOrUrl, assignment, options.commit, options.description, this.isUpdate);
}
}
}
......
......@@ -193,7 +193,7 @@ class DojoBackendManager {
}
}
public async linkUpdateCorrection(exerciseIdOrUrl: string, assignment: Assignment, isUpdate: boolean, verbose: boolean = true): Promise<boolean> {
public async linkUpdateCorrection(exerciseIdOrUrl: string, assignment: Assignment, commit: string | undefined, description: string | undefined, isUpdate: boolean, verbose: boolean = true): Promise<boolean> {
const spinner: ora.Ora = ora(`${ isUpdate ? 'Updating' : 'Linking' } correction`);
if ( verbose ) {
......@@ -202,13 +202,15 @@ class DojoBackendManager {
try {
const axiosFunction = isUpdate ? axios.patch.bind(axios) : axios.post.bind(axios);
const route = isUpdate ? ApiRoute.ASSIGNMENT_CORRECTION_UPDATE : ApiRoute.ASSIGNMENT_CORRECTION_LINK;
const route = isUpdate ? ApiRoute.ASSIGNMENT_CORRECTION_UPDATE_DELETE : ApiRoute.ASSIGNMENT_CORRECTION_LINK;
await axiosFunction(DojoBackendHelper.getApiUrl(route, {
assignmentNameOrUrl: assignment.name,
exerciseIdOrUrl : exerciseIdOrUrl
}), {
exerciseIdOrUrl: exerciseIdOrUrl
exerciseIdOrUrl: exerciseIdOrUrl,
commit : commit,
description : description
});
if ( verbose ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment