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

Commit d513a6c

Browse files
committed
Merge pull request #728 from appirio-tech/feature/peer-review
Feature/peer review
2 parents 6da9a09 + d500698 commit d513a6c

12 files changed

+225
-245
lines changed

app/peer-review/completed-review/completed-review.controller.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,34 @@ import angular from 'angular'
2727

2828
function activate() {
2929
var promises = [
30-
handle,
3130
ChallengeService.getChallengeDetails($stateParams.challengeId),
3231
ReviewService.getReview($stateParams.reviewId),
3332
ScorecardService.getScorecard(vm.challengeId)
3433
]
3534

3635
$q.all(promises)
37-
.then(function(response) {
36+
.then(function(responses) {
3837
vm.stats.username = handle
3938

40-
var challenge = response[1].data
41-
vm.challenge = challenge
39+
vm.challenge = responses[0]
4240

43-
var reviewData = response[2].data.result.content
44-
vm.review = reviewData
45-
vm.stats.submissionId = reviewData.submissionId
46-
vm.stats.uploadId = reviewData.uploadId
47-
vm.stats.createdAt = reviewData.createdAt
48-
vm.stats.updatedAt = reviewData.updatedAt
41+
vm.review = responses[1]
42+
vm.stats.submissionId = vm.review.submissionId
43+
vm.stats.uploadId = vm.review.uploadId
44+
vm.stats.createdAt = vm.review.createdAt
45+
vm.stats.updatedAt = vm.review.updatedAt
4946

50-
var scorecardData = response[3].data.result.content[0]
47+
var scorecardData = responses[2][0]
5148
var scorecardId = scorecardData.id
5249

5350
ScorecardService.getScorecardQuestions(scorecardId)
54-
.then(function(data) {
55-
var questions = data.data.result.content
56-
51+
.then(function(questions) {
5752
Helpers.storeById(vm.scorecard.questions, questions)
5853
Helpers.parseQuestions(vm.scorecard.questions)
5954

6055
return ReviewService.getReviewItems($stateParams.reviewId)
6156

62-
}).then(function(data) {
63-
var answers = data.data.result.content
64-
57+
}).then(function(answers) {
6558
Helpers.parseAnswers(vm.scorecard.questions, answers)
6659

6760
vm.loaded = true

app/peer-review/edit-review/edit-review.controller.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,42 +65,36 @@ import angular from 'angular'
6565

6666
function activate() {
6767
var promises = [
68-
handle,
6968
ChallengeService.getChallengeDetails(vm.challengeId),
7069
ReviewService.getReview($stateParams.reviewId),
7170
ScorecardService.getScorecard(vm.challengeId)
7271
]
7372

7473
$q.all(promises)
75-
.then(function(response) {
74+
.then(function(responses) {
7675
vm.stats.username = handle
7776

78-
var challenge = response[1].data
79-
vm.challenge = challenge
77+
vm.challenge = responses[0]
8078

81-
var reviewData = response[2].data.result.content
82-
vm.review = reviewData
83-
vm.stats.submissionId = reviewData.submissionId
84-
vm.stats.uploadId = reviewData.uploadId
85-
vm.stats.createdAt = reviewData.createdAt
86-
vm.stats.updatedAt = reviewData.updatedAt
79+
vm.review = responses[1]
80+
vm.stats.submissionId = vm.review.submissionId
81+
vm.stats.uploadId = vm.review.uploadId
82+
vm.stats.createdAt = vm.review.createdAt
83+
vm.stats.updatedAt = vm.review.updatedAt
8784

88-
var scorecardData = response[3].data.result.content[0]
85+
var scorecardData = responses[2][0]
8986
var scorecardId = scorecardData.id
9087

9188
ScorecardService.getScorecardQuestions(scorecardId)
92-
.then(function(data) {
93-
var questions = data.data.result.content
89+
.then(function(questions) {
9490

9591
Helpers.storeById(vm.scorecard.questions, questions)
9692
Helpers.parseQuestions(vm.scorecard.questions)
9793

9894
return ReviewService.getReviewItems($stateParams.reviewId)
9995

10096
})
101-
.then(function(data) {
102-
var answers = data.data.result.content
103-
97+
.then(function(answers) {
10498
vm.saved = Helpers.parseAnswers(vm.scorecard.questions, answers)
10599

106100
vm.loaded = true

app/peer-review/peer-review.routes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import angular from 'angular'
1919
},
2020
'review.status': {
2121
parent: 'review',
22-
url: '/challenge/:challengeId/',
22+
url: '/challenges/:challengeId/reviews/',
2323
data: {
2424
title: 'Peer Review'
2525
},
@@ -33,7 +33,7 @@ import angular from 'angular'
3333
},
3434
'review.readOnlyScorecard': {
3535
parent: 'review',
36-
url: '/scorecard/:scorecardId/',
36+
url: '/challenges/:challengeId/scorecards/:scorecardId/',
3737
data: {
3838
title: 'Scorecard'
3939
},
@@ -47,7 +47,7 @@ import angular from 'angular'
4747
},
4848
'review.completed': {
4949
parent: 'review',
50-
url: '/:challengeId/reviews/:reviewId/completed/',
50+
url: '/challenges/:challengeId/reviews/:reviewId/completed/',
5151
data: {
5252
title: 'Completed'
5353
},
@@ -61,7 +61,7 @@ import angular from 'angular'
6161
},
6262
'review.edit': {
6363
parent: 'review',
64-
url: '/:challengeId/reviews/:reviewId/edit/',
64+
url: '/challenges/:challengeId/reviews/:reviewId/edit/',
6565
data: {
6666
title: 'Edit Review'
6767
},

app/peer-review/review-status/review-status.controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import angular from 'angular'
2121
}
2222
ReviewService.getNextReview(vm.challengeId)
2323
.then(function(data) {
24-
var newReviewId = data.data.result.content
24+
var newReviewId = data
2525

2626
$state.go('review.edit', {
2727
challengeId: vm.challengeId,
@@ -39,19 +39,19 @@ import angular from 'angular'
3939
function activate() {
4040
ChallengeService.getChallengeDetails(vm.challengeId)
4141
.then(function(data) {
42-
vm.challenge = data.data
42+
vm.challenge = data
4343
})
4444

4545
ReviewService.getUsersPeerReviews(vm.challengeId)
4646
.then(function(data) {
47-
vm.reviews = data.data.result.content
47+
vm.reviews = data.plain()
4848
vm.completed = Helpers.countCompleted(vm.reviews)
4949
// Move calls to $q.all(), and move this to the success callback there
5050
vm.loaded = true
5151
})
5252

53-
ChallengeService.getReviewEndDate(vm.challengeId).then(function(data) {
54-
vm.reviewsDue = data.data.result.content[0].scheduledEndTime
53+
ChallengeService.getPhase(vm.challengeId, 'REVIEW').then(function(data) {
54+
vm.reviewsDue = data.scheduledEndTime
5555
})
5656
}
5757
}

app/peer-review/review-status/review-status.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.review-status-container(ng-show="vm.loaded")
22
.back-link
33
.arrow
4+
45
p #[a.back(href="https://www.{{vm.domain}}/challenge-details/{{vm.challengeId}}/?type=develop") Back to Challenge]
56

67
h1(ng-bind="vm.challenge.challengeName")
@@ -30,6 +31,6 @@
3031

3132
td
3233
a(ng-href="https://software.{{vm.domain}}/review/actions/DownloadContestSubmission?uid={{review.uploadId}}")
33-
span.glyphicon.glyphicon-download-alt
34+
i.fa.fa-download
3435

3536
button.start-review(type="button", ng-click="vm.getNextReview()") Start another review

app/peer-review/review-status/review-status.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ describe('Review Status Controller', function() {
1515
getChallengeDetails: function() {
1616
return $q.when(challenge)
1717
},
18-
getReviewEndDate: function() {
18+
getPhase: function() {
1919
return $q.when(challengeDates)
2020
}
2121
}
2222

2323
var reviewService = {
2424
getUsersPeerReviews: function() {
25+
userReviews.plain = function() { return this }
2526
return $q.when(userReviews)
2627
}
2728
}
@@ -64,7 +65,7 @@ describe('Review Status Controller', function() {
6465

6566
it('should get a challenge', function() {
6667
expect(controller.challenge).to.exist
67-
expect(controller.challenge.challengeName).to.equal(challenge.data.challengeName)
68+
expect(controller.challenge.challengeName).to.equal(challenge.challengeName)
6869
})
6970

7071
it('should have a user\'s reviews', function() {

app/services/challenge.service.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import moment from 'moment'
77

88
angular.module('tc.services').factory('ChallengeService', ChallengeService)
99

10-
ChallengeService.$inject = ['CONSTANTS', 'ApiService', '$q']
10+
ChallengeService.$inject = ['CONSTANTS', 'ApiService', '$q', '$log']
1111

12-
function ChallengeService(CONSTANTS, ApiService, $q) {
12+
function ChallengeService(CONSTANTS, ApiService, $q, $log) {
1313
var api = ApiService.restangularV3
14-
14+
var apiV2 = ApiService.restangularV2
1515
var service = {
1616
getChallenges: getChallenges,
1717
getUserChallenges: getUserChallenges,
1818
getUserMarathonMatches: getUserMarathonMatches,
19-
getReviewEndDate: getReviewEndDate,
19+
getPhase: getPhase,
2020
getChallengeDetails: getChallengeDetails,
2121
processActiveDevDesignChallenges: processActiveDevDesignChallenges,
2222
processActiveMarathonMatches: processActiveMarathonMatches,
@@ -40,14 +40,23 @@ import moment from 'moment'
4040
return api.one('members', handle.toLowerCase()).all('mms').getList(params)
4141
}
4242

43-
function getReviewEndDate(challengeId) {
44-
var url = CONSTANTS.API_URL + '/phases/?filter=' + encodeURIComponent('challengeId=' + challengeId + '&phaseType=4')
45-
return ApiService.requestHandler('GET', url)
43+
function getPhase(challengeId, phaseType) {
44+
return api.one('challenges', challengeId).getList('phases').then(
45+
function(phases) {
46+
return _.find(phases, function(p) { return p.phaseType.toUpperCase() === phaseType})
47+
},
48+
function(err) {
49+
$log.error(err)
50+
}
51+
)
4652
}
4753

4854
function getChallengeDetails(challengeId) {
49-
var url = CONSTANTS.API_URL_V2 + '/challenges/' + challengeId
50-
return ApiService.requestHandler('GET', url, {}, true)
55+
// var url = CONSTANTS.API_URL_V2 + '/challenges/' + challengeId
56+
// return ApiService.requestHandler('GET', url, {}, true)
57+
return apiV2.one('challenges', challengeId).get().then(
58+
function(data) { return data.plain() }
59+
)
5160
}
5261

5362
function processActiveDevDesignChallenges(challenges) {

app/services/helpers.service.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import angular from 'angular'
88
Helpers.$inject = ['$window', '$location', '$state', '$http', '$filter', 'ISO3166']
99

1010
function Helpers($window, $location, $state, $http, $filter, ISO3166) {
11-
// TODO: Separate helpers by submodule
12-
1311
var service = {
1412
storeById: storeById,
1513
parseQuestions: parseQuestions,

app/services/review.service.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import angular from 'angular'
88
ReviewService.$inject = ['CONSTANTS', 'ApiService']
99

1010
function ReviewService(CONSTANTS, ApiService) {
11+
var api = ApiService.getApiServiceProvider('Review')
12+
1113
var service = {
1214
getUsersPeerReviews: getUsersPeerReviews,
1315
getReview: getReview,
@@ -20,39 +22,36 @@ import angular from 'angular'
2022

2123
///////////////
2224
function getUsersPeerReviews(challengeId) {
23-
var url = CONSTANTS.API_URL + '/reviews/?filter=' + encodeURIComponent('challengeId=' + challengeId)
24-
return ApiService.requestHandler('GET', url)
25+
return api.all('reviews').getList({filter: encodeURIComponent('challengeId=' + challengeId)})
2526
}
2627

2728
function getReview(reviewId) {
28-
var url = CONSTANTS.API_URL + '/reviews/' + reviewId
29-
return ApiService.requestHandler('GET', url)
29+
return api.one('reviews', reviewId).get()
3030
}
3131

3232
function getReviewItems(reviewId) {
33-
var url = CONSTANTS.API_URL + '/reviewItems/?filter=' + encodeURIComponent('reviewId=' + reviewId)
34-
return ApiService.requestHandler('GET', url)
33+
return api.all('reviewItems').getList({filter: encodeURIComponent('reviewId=' + reviewId)})
3534
}
3635

3736
function getNextReview(challengeId) {
38-
var url = CONSTANTS.API_URL + '/reviews/' + challengeId + '/assignNextReview'
39-
return ApiService.requestHandler('PUT', url)
37+
return api.one('reviews', challengeId).customPUT(null, 'assignNextReview', null, null)
4038
}
4139

4240
function saveReviewItems(body, isPreviouslySaved) {
43-
var method = isPreviouslySaved ? 'PUT' : 'POST'
44-
var url = CONSTANTS.API_URL + '/reviewItems/'
45-
return ApiService.requestHandler(method, url, JSON.stringify(body))
41+
if (isPreviouslySaved) {
42+
return api.all('reviewItems').customPUT(body, null, null, null)
43+
} else {
44+
return api.all('reviewItems').post(body)
45+
}
4646
}
4747

4848
function markAsCompleted(reviewId) {
49-
var url = CONSTANTS.API_URL + '/reviews/' + reviewId
5049
var body = {
5150
committed: 1,
5251
id: reviewId
5352
}
5453

55-
return ApiService.requestHandler('PUT', url, JSON.stringify(body))
54+
return api.one('reviews', reviewId).customPUT(body, null, null, null)
5655
}
5756
}
5857
})()

app/services/scorecard.service.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import angular from 'angular'
88
ScorecardService.$inject = ['CONSTANTS', 'ApiService']
99

1010
function ScorecardService(CONSTANTS, ApiService) {
11+
var api = ApiService.restangularV3
12+
1113
var service = {
1214
getScorecardById: getScorecardById,
1315
getScorecard: getScorecard,
@@ -18,18 +20,24 @@ import angular from 'angular'
1820
///////////////
1921

2022
function getScorecardById(scorecardId) {
21-
var url = CONSTANTS.API_URL + '/scorecards/?filter=' + encodeURIComponent('scorecardId=' + scorecardId)
22-
return ApiService.requestHandler('GET', url)
23+
return api.all('scorecards').getList({filter: encodeURIComponent('scorecardId='+scorecardId)})
24+
.then(function(data) {
25+
return data.plain()
26+
})
2327
}
2428

2529
function getScorecard(challengeId) {
26-
var url = CONSTANTS.API_URL + '/scorecards/?filter=' + encodeURIComponent('challengeId=' + challengeId)
27-
return ApiService.requestHandler('GET', url)
30+
return api.all('scorecards').getList({filter: encodeURIComponent('challengeId='+challengeId)})
31+
.then(function(data) {
32+
return data.plain()
33+
})
2834
}
2935

3036
function getScorecardQuestions(scorecardId) {
31-
var url = CONSTANTS.API_URL + '/scorecardQuestions/?filter=' + encodeURIComponent('scorecardId=' + scorecardId)
32-
return ApiService.requestHandler('GET', url)
37+
return api.all('scorecardQuestions').getList({filter: encodeURIComponent('scorecardId='+scorecardId)})
38+
.then(function(data) {
39+
return data.plain()
40+
})
3341
}
3442
}
3543
})()

0 commit comments

Comments
 (0)