Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit option for submission guidelines and leaderboard description #3569

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,26 @@ <h5 class="fw-light">Challenge Settings</h5>
</ng-template>
</mat-tab>

<!-- Edit Phase Details -->
<mat-tab label="Phase and Leaderboard Details">
<!-- Edit Phase and Leaderboard Details -->
<mat-tab label="Phase and Leaderboard">
<div class="row margin-bottom-cancel">
<div class="col s12">
<button
class="btn ev-btn-dark waves-effect waves-dark grad-btn grad-btn-dark fs-12"
(click)="editSubmissionGuidelines()"
>
Submission Guidelines
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
<button
class="btn ev-btn-dark waves-effect waves-dark grad-btn grad-btn-dark fs-12"
(click)="editLeaderboardDescription()"
>
Leaderboard Description
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
</div>
</div>
<div class="row settings-section">
<div class="col-lg-3 col-md-4 col-sm-3 col-xs-3">
<span class="fw-light fs-18">Edit Phase</span>
Expand Down Expand Up @@ -200,7 +218,7 @@ <h5 class="fw-light">Challenge Settings</h5>
</span>
<a class="pointer fs-20" (click)="toggleLeaderboardVisibility()">
<i class="{{ leaderboardVisibility.icon }}" aria-hidden="true"> </i>
</a>&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,40 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy {
}
}

/**
* Edit submission guidelines
*/
editSubmissionGuidelines() {
const SELF = this;
SELF.apiCall = (params) => {
const BODY = JSON.stringify(params);
SELF.apiService
.patchUrl(SELF.endpointsService.editChallengeDetailsURL(SELF.challenge.creator.id, SELF.challenge.id), BODY)
.subscribe(
(data) => {
SELF.challenge.submission_guidelines = data.submission_guidelines;
SELF.globalService.showToast('success', 'The submission guidelines are successfully updated!', 5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gautamjajoo please change the message to Submission guidelines updated successfully!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

},
(err) => {
SELF.globalService.handleApiError(err, true);
SELF.globalService.showToast('error', err);
},
() => {}
);
};

const PARAMS = {
title: 'Edit Submission Guidelines',
label: 'submission_guidelines',
isEditorRequired: true,
editorContent: this.challenge.submission_guidelines,
confirm: 'Submit',
deny: 'Cancel',
confirmCallback: SELF.apiCall,
};
SELF.globalService.showModal(PARAMS);
}

// Edit Leaderboard Details ->

/**
Expand Down Expand Up @@ -1000,6 +1034,43 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy {
}
}

/**
* Edit leaderboard description of the challenge
*/
editLeaderboardDescription() {
const SELF = this;
SELF.apiCall = (params) => {
const BODY = JSON.stringify(params);
SELF.apiService
.patchUrl(SELF.endpointsService.editChallengeDetailsURL(SELF.challenge.creator.id, SELF.challenge.id), BODY)
.subscribe(
(data) => {
SELF.challenge.leaderboard_description = data.leaderboard_description;
SELF.globalService.showToast('success', 'The leaderboard description is successfully updated!', 5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gautamjajoo please change the message to Leaderboard description updated successfully!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

},
(err) => {
SELF.globalService.handleApiError(err, true);
SELF.globalService.showToast('error', err);
},
() => this.logger.info('Edit Leaderboard Description')
);
};

/**
* Parameters of the modal
*/
const PARAMS = {
title: 'Edit Leaderboard Description',
label: 'leaderboard_description',
isEditorRequired: true,
editorContent: this.challenge.leaderboard_description,
confirm: 'Submit',
deny: 'Cancel',
confirmCallback: SELF.apiCall,
};
SELF.globalService.showModal(PARAMS);
}

// Edit Evaluation Script and Criteria ->

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ <h5 class="fw-light">Submission Guidelines</h5>
</p>
</div>
</div>
<div [innerHTML]="submissionGuidelines" class="submission-guidelines fw-light fs-16"></div>
</div>
<div *ngIf="isChallengeHost" class="col-md-1 col-sm-1 col-xs-2 col-lr-pad">
<a class="pointer fs-16" (click)="editSubmissionGuideline()">
<i class="fa fa-pencil" aria-hidden="true"> </i>&nbsp;edit
</a>
<div [innerHTML]="challenge.submission_guidelines" class="submission-guidelines fw-light fs-16"></div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ export class ChallengesubmitComponent implements OnInit {
*/
submissionError = '';

/**
* Guidelines text
*/
submissionGuidelines = '';

/**
* Stores the attributes format and phase ID for all the phases of a challenge.
*/
Expand Down Expand Up @@ -248,7 +243,6 @@ export class ChallengesubmitComponent implements OnInit {
this.challengeService.currentChallenge.subscribe((challenge) => {
this.challenge = challenge;
this.isActive = this.challenge['is_active'];
this.submissionGuidelines = this.challenge['submission_guidelines'];
if (this.challenge.cli_version !== null) {
this.cliVersion = this.challenge.cli_version;
}
Expand Down Expand Up @@ -603,40 +597,6 @@ export class ChallengesubmitComponent implements OnInit {
this.globalService.showToast('success', 'Command copied to clipboard');
}

/**
* Edit submission guidelines
*/
editSubmissionGuideline() {
const SELF = this;
SELF.apiCall = (params) => {
const BODY = JSON.stringify(params);
SELF.apiService
.patchUrl(SELF.endpointsService.editChallengeDetailsURL(SELF.challenge.creator.id, SELF.challenge.id), BODY)
.subscribe(
(data) => {
SELF.submissionGuidelines = data.submission_guidelines;
SELF.globalService.showToast('success', 'The submission guidelines is successfully updated!', 5);
},
(err) => {
SELF.globalService.handleApiError(err, true);
SELF.globalService.showToast('error', err);
},
() => {}
);
};

const PARAMS = {
title: 'Edit Submission Guidelines',
label: 'submission_guidelines',
isEditorRequired: true,
editorContent: this.challenge.submission_guidelines,
confirm: 'Submit',
deny: 'Cancel',
confirmCallback: SELF.apiCall,
};
SELF.globalService.showModal(PARAMS);
}

validateInput(inputValue) {
const regex = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/);
const validExtensions = ['json', 'zip', 'txt', 'tsv', 'gz', 'csv', 'h5', 'npy'];
Expand Down