diff --git a/app/directives/challenge-tile/challenge-tile.jade b/app/directives/challenge-tile/challenge-tile.jade index 20b415a2b..4660e4dfb 100644 --- a/app/directives/challenge-tile/challenge-tile.jade +++ b/app/directives/challenge-tile/challenge-tile.jade @@ -20,7 +20,7 @@ .stalled-challenge(ng-hide="challenge.userCurrentPhaseEndTime") This challenge is currently paused. .phase-action(ng-show="challenge.userAction", ng-switch="challenge.userAction") - a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'detail'}}") Submit + a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'submit'}}") Submit .submitted(ng-switch-when="Submitted") Submitted @@ -96,7 +96,7 @@ p.ends-in(ng-hide="challenge.userCurrentPhaseEndTime") This challenge is currently paused. .phase-action(ng-switch="challenge.userAction") - a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'detail'}}") Submit + a.tc-btn.tc-btn-s.tc-btn-wide.tc-btn-ghost.submit(ng-switch-when="Submit", ng-href="{{challenge|challengeLinks:'submit'}}") Submit .submitted(ng-switch-when="Submitted") Submitted diff --git a/app/filters/challengeLinks.filter.js b/app/filters/challengeLinks.filter.js index e6360ce0d..5204ba37b 100644 --- a/app/filters/challengeLinks.filter.js +++ b/app/filters/challengeLinks.filter.js @@ -1,4 +1,5 @@ import angular from 'angular' +import _ from 'lodash' (function() { 'use strict' @@ -13,15 +14,24 @@ import angular from 'angular' data = { domain: CONSTANTS.domain, roundId: challenge.rounds[0].id, - forumId: challenge.rounds[0].forumId + forumId: challenge.rounds[0].forumId, + componentId: _.get(challenge, 'componentId', ''), + challengeId: challenge.id, + problemId: _.get(challenge, 'problemId', '') } switch (type) { case 'forums': return String.supplant('https://apps.{domain}/forums/?module=ThreadList&forumID={forumId}', data) case 'registrants': return String.supplant('https://community.{domain}/longcontest/?module=ViewRegistrants&rd={roundId}', data) + case 'submit': + return String.supplant('https://community.{domain}/longcontest/?module=Submit&compid={componentId}&rd={roundId}&cd={challengeId}', data) case 'detail': - return String.supplant('https://community.{domain}/longcontest/stats/?module=ViewOverview&rd={roundId}', data) + if (challenge.status === 'PAST') { + return String.supplant('https://community.{domain}/longcontest/stats/?module=ViewOverview&rd={roundId}', data) + } else { // for all other statues (ACTIVE, UPCOMING), show the problem statement + return String.supplant('https://community.{domain}/longcontest/?module=ViewProblemStatement&pm={problemId}&rd={roundId}', data) + } } } else if (challenge.subTrack === 'SRM') { data = { @@ -54,6 +64,8 @@ import angular from 'angular' return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}#submissions', data) case 'registrants': return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}#viewRegistrant', data) + case 'submit':// TODO use details link for submit, we can replace it with new submission page url + return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}', data) case 'detail': return String.supplant('https://www.{domain}/challenge-details/{id}/?type={track}', data) } diff --git a/app/filters/filters.spec.js b/app/filters/filters.spec.js index 94a2a775f..aeaaed63a 100644 --- a/app/filters/filters.spec.js +++ b/app/filters/filters.spec.js @@ -68,6 +68,7 @@ describe('filters', function() { track: 'develop', subTrack : 'CODE' } + expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=develop') expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=develop') expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=Category&categoryID=2') expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=develop#viewRegistrant') @@ -81,23 +82,44 @@ describe('filters', function() { track: 'design', subTrack : 'WEB_DESIGN' } + expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design') expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design') expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=ThreadList&forumID=2') expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design#viewRegistrant') expect(challengeLinksFilter(_ch, 'submissions')).to.be.equal('https://www.'+domain+'/challenge-details/1/?type=design#submissions') }) - it ('should have the correct links for DATA_SCIENCE challenge', function() { + it ('should have the correct links for PAST DATA_SCIENCE challenge', function() { var _ch = { id: 1, rounds: [{id: 3,forumId: 2}], track: 'DATA_SCIENCE', - subTrack : 'MARATHON_MATCH' + subTrack : 'MARATHON_MATCH', + componentId: 4, + problemId: 5, + status: 'PAST' } + expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://community.'+domain+'/longcontest/?module=Submit&compid=4&rd=3&cd=1') expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://community.'+domain+'/longcontest/stats/?module=ViewOverview&rd=3') expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=ThreadList&forumID=2') expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewRegistrants&rd=3') }) + + it ('should have the correct links for ACTIVE/UPCOMING DATA_SCIENCE challenge', function() { + var _ch = { + id: 1, + rounds: [{id: 3,forumId: 2}], + track: 'DATA_SCIENCE', + subTrack : 'MARATHON_MATCH', + componentId: 4, + problemId: 5, + status: 'ACTIVE' + } + expect(challengeLinksFilter(_ch, 'submit')).to.be.equal('https://community.'+domain+'/longcontest/?module=Submit&compid=4&rd=3&cd=1') + expect(challengeLinksFilter(_ch, 'detail')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewProblemStatement&pm=5&rd=3') + expect(challengeLinksFilter(_ch, 'forums')).to.be.equal('https://apps.'+domain+'/forums/?module=ThreadList&forumID=2') + expect(challengeLinksFilter(_ch, 'registrants')).to.be.equal('https://community.'+domain+'/longcontest/?module=ViewRegistrants&rd=3') + }) }) describe('externalLinkColorFilter', function() {