Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 2e78393

Browse files
author
vikasrohit
authored
Merge pull request #799 from appirio-tech/feature/sup-3127-marathonmatch-details-link
Feature/sup 3127 marathonmatch details link
2 parents 2c841b6 + 890cc37 commit 2e78393

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

app/directives/challenge-tile/challenge-tile.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
.stalled-challenge(ng-hide="challenge.userCurrentPhaseEndTime") This challenge is currently paused.
2121

2222
.phase-action(ng-show="challenge.userAction", ng-switch="challenge.userAction")
23-
a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'detail'}}") Submit
23+
a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'submit'}}") Submit
2424

2525
.submitted(ng-switch-when="Submitted") Submitted
2626

@@ -96,7 +96,7 @@
9696
p.ends-in(ng-hide="challenge.userCurrentPhaseEndTime") This challenge is currently paused.
9797

9898
.phase-action(ng-switch="challenge.userAction")
99-
a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'detail'}}") Submit
99+
a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'submit'}}") Submit
100100

101101
.submitted(ng-switch-when="Submitted") Submitted
102102

app/filters/challengeLinks.filter.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import angular from 'angular'
2+
import _ from 'lodash'
23

34
(function() {
45
'use strict'
@@ -13,15 +14,24 @@ import angular from 'angular'
1314
data = {
1415
domain: CONSTANTS.domain,
1516
roundId: challenge.rounds[0].id,
16-
forumId: challenge.rounds[0].forumId
17+
forumId: challenge.rounds[0].forumId,
18+
componentId: _.get(challenge, 'componentId', ''),
19+
challengeId: challenge.id,
20+
problemId: _.get(challenge, 'problemId', '')
1721
}
1822
switch (type) {
1923
case 'forums':
2024
return String.supplant('https://apps.{domain}/forums/?module=ThreadList&forumID={forumId}', data)
2125
case 'registrants':
2226
return String.supplant('https://community.{domain}/longcontest/?module=ViewRegistrants&rd={roundId}', data)
27+
case 'submit':
28+
return String.supplant('https://community.{domain}/longcontest/?module=Submit&compid={componentId}&rd={roundId}&cd={challengeId}', data)
2329
case 'detail':
24-
return String.supplant('https://community.{domain}/longcontest/stats/?module=ViewOverview&rd={roundId}', data)
30+
if (challenge.status === 'PAST') {
31+
return String.supplant('https://community.{domain}/longcontest/stats/?module=ViewOverview&rd={roundId}', data)
32+
} else { // for all other statues (ACTIVE, UPCOMING), show the problem statement
33+
return String.supplant('https://community.{domain}/longcontest/?module=ViewProblemStatement&pm={problemId}&rd={roundId}', data)
34+
}
2535
}
2636
} else if (challenge.subTrack === 'SRM') {
2737
data = {
@@ -54,6 +64,8 @@ import angular from 'angular'
5464
return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}#submissions', data)
5565
case 'registrants':
5666
return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}#viewRegistrant', data)
67+
case 'submit':// TODO use details link for submit, we can replace it with new submission page url
68+
return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}', data)
5769
case 'detail':
5870
return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}', data)
5971
}

app/filters/filters.spec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe('filters', function() {
6868
track: 'develop',
6969
subTrack : 'CODE'
7070
}
71+
expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=develop')
7172
expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=develop')
7273
expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=Category&categoryID=2')
7374
expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=develop#viewRegistrant')
@@ -81,23 +82,44 @@ describe('filters', function() {
8182
track: 'design',
8283
subTrack : 'WEB_DESIGN'
8384
}
85+
expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design')
8486
expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design')
8587
expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=ThreadList&forumID=2')
8688
expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design#viewRegistrant')
8789
expect(challengeLinksFilter(_ch, 'submissions')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design#submissions')
8890
})
8991

90-
it ('should have the correct links for DATA_SCIENCE challenge', function() {
92+
it ('should have the correct links for PAST DATA_SCIENCE challenge', function() {
9193
var _ch = {
9294
id: 1,
9395
rounds: [{id: 3,forumId: 2}],
9496
track: 'DATA_SCIENCE',
95-
subTrack : 'MARATHON_MATCH'
97+
subTrack : 'MARATHON_MATCH',
98+
componentId: 4,
99+
problemId: 5,
100+
status: 'PAST'
96101
}
102+
expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://community.'+domain+'/longcontest/?module=Submit&compid=4&rd=3&cd=1')
97103
expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://community.'+domain+'/longcontest/stats/?module=ViewOverview&rd=3')
98104
expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=ThreadList&forumID=2')
99105
expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewRegistrants&rd=3')
100106
})
107+
108+
it ('should have the correct links for ACTIVE/UPCOMING DATA_SCIENCE challenge', function() {
109+
var _ch = {
110+
id: 1,
111+
rounds: [{id: 3,forumId: 2}],
112+
track: 'DATA_SCIENCE',
113+
subTrack : 'MARATHON_MATCH',
114+
componentId: 4,
115+
problemId: 5,
116+
status: 'ACTIVE'
117+
}
118+
expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://community.'+domain+'/longcontest/?module=Submit&compid=4&rd=3&cd=1')
119+
expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewProblemStatement&pm=5&rd=3')
120+
expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=ThreadList&forumID=2')
121+
expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewRegistrants&rd=3')
122+
})
101123
})
102124

103125
describe('externalLinkColorFilter', function() {

0 commit comments

Comments
 (0)