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

Feature/peer review #728

Merged
merged 7 commits into from
Feb 10, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 10 additions & 17 deletions app/peer-review/completed-review/completed-review.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,34 @@ import angular from 'angular'

function activate() {
var promises = [
handle,
ChallengeService.getChallengeDetails($stateParams.challengeId),
ReviewService.getReview($stateParams.reviewId),
ScorecardService.getScorecard(vm.challengeId)
]

$q.all(promises)
.then(function(response) {
.then(function(responses) {
vm.stats.username = handle

var challenge = response[1].data
vm.challenge = challenge
vm.challenge = responses[0]

var reviewData = response[2].data.result.content
vm.review = reviewData
vm.stats.submissionId = reviewData.submissionId
vm.stats.uploadId = reviewData.uploadId
vm.stats.createdAt = reviewData.createdAt
vm.stats.updatedAt = reviewData.updatedAt
vm.review = responses[1]
vm.stats.submissionId = vm.review.submissionId
vm.stats.uploadId = vm.review.uploadId
vm.stats.createdAt = vm.review.createdAt
vm.stats.updatedAt = vm.review.updatedAt

var scorecardData = response[3].data.result.content[0]
var scorecardData = responses[2][0]
var scorecardId = scorecardData.id

ScorecardService.getScorecardQuestions(scorecardId)
.then(function(data) {
var questions = data.data.result.content

.then(function(questions) {
Helpers.storeById(vm.scorecard.questions, questions)
Helpers.parseQuestions(vm.scorecard.questions)

return ReviewService.getReviewItems($stateParams.reviewId)

}).then(function(data) {
var answers = data.data.result.content

}).then(function(answers) {
Helpers.parseAnswers(vm.scorecard.questions, answers)

vm.loaded = true
Expand Down
26 changes: 10 additions & 16 deletions app/peer-review/edit-review/edit-review.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,42 +65,36 @@ import angular from 'angular'

function activate() {
var promises = [
handle,
ChallengeService.getChallengeDetails(vm.challengeId),
ReviewService.getReview($stateParams.reviewId),
ScorecardService.getScorecard(vm.challengeId)
]

$q.all(promises)
.then(function(response) {
.then(function(responses) {
vm.stats.username = handle

var challenge = response[1].data
vm.challenge = challenge
vm.challenge = responses[0]

var reviewData = response[2].data.result.content
vm.review = reviewData
vm.stats.submissionId = reviewData.submissionId
vm.stats.uploadId = reviewData.uploadId
vm.stats.createdAt = reviewData.createdAt
vm.stats.updatedAt = reviewData.updatedAt
vm.review = responses[1]
vm.stats.submissionId = vm.review.submissionId
vm.stats.uploadId = vm.review.uploadId
vm.stats.createdAt = vm.review.createdAt
vm.stats.updatedAt = vm.review.updatedAt

var scorecardData = response[3].data.result.content[0]
var scorecardData = responses[2][0]
var scorecardId = scorecardData.id

ScorecardService.getScorecardQuestions(scorecardId)
.then(function(data) {
var questions = data.data.result.content
.then(function(questions) {

Helpers.storeById(vm.scorecard.questions, questions)
Helpers.parseQuestions(vm.scorecard.questions)

return ReviewService.getReviewItems($stateParams.reviewId)

})
.then(function(data) {
var answers = data.data.result.content

.then(function(answers) {
vm.saved = Helpers.parseAnswers(vm.scorecard.questions, answers)

vm.loaded = true
Expand Down
8 changes: 4 additions & 4 deletions app/peer-review/peer-review.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import angular from 'angular'
},
'review.status': {
parent: 'review',
url: '/challenge/:challengeId/',
url: '/challenges/:challengeId/reviews/',
data: {
title: 'Peer Review'
},
Expand All @@ -33,7 +33,7 @@ import angular from 'angular'
},
'review.readOnlyScorecard': {
parent: 'review',
url: '/scorecard/:scorecardId/',
url: '/challenges/:challengeId/scorecards/:scorecardId/',
data: {
title: 'Scorecard'
},
Expand All @@ -47,7 +47,7 @@ import angular from 'angular'
},
'review.completed': {
parent: 'review',
url: '/:challengeId/reviews/:reviewId/completed/',
url: '/challenges/:challengeId/reviews/:reviewId/completed/',
data: {
title: 'Completed'
},
Expand All @@ -61,7 +61,7 @@ import angular from 'angular'
},
'review.edit': {
parent: 'review',
url: '/:challengeId/reviews/:reviewId/edit/',
url: '/challenges/:challengeId/reviews/:reviewId/edit/',
data: {
title: 'Edit Review'
},
Expand Down
10 changes: 5 additions & 5 deletions app/peer-review/review-status/review-status.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import angular from 'angular'
}
ReviewService.getNextReview(vm.challengeId)
.then(function(data) {
var newReviewId = data.data.result.content
var newReviewId = data

$state.go('review.edit', {
challengeId: vm.challengeId,
Expand All @@ -39,19 +39,19 @@ import angular from 'angular'
function activate() {
ChallengeService.getChallengeDetails(vm.challengeId)
.then(function(data) {
vm.challenge = data.data
vm.challenge = data
})

ReviewService.getUsersPeerReviews(vm.challengeId)
.then(function(data) {
vm.reviews = data.data.result.content
vm.reviews = data.plain()
vm.completed = Helpers.countCompleted(vm.reviews)
// Move calls to $q.all(), and move this to the success callback there
vm.loaded = true
})

ChallengeService.getReviewEndDate(vm.challengeId).then(function(data) {
vm.reviewsDue = data.data.result.content[0].scheduledEndTime
ChallengeService.getPhase(vm.challengeId, 'REVIEW').then(function(data) {
vm.reviewsDue = data.scheduledEndTime
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/peer-review/review-status/review-status.jade
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.review-status-container(ng-show="vm.loaded")
.back-link
.arrow

p #[a.back(href="https://www.{{vm.domain}}/challenge-details/{{vm.challengeId}}/?type=develop") Back to Challenge]

h1(ng-bind="vm.challenge.challengeName")
Expand Down Expand Up @@ -30,6 +31,6 @@

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

button.start-review(type="button", ng-click="vm.getNextReview()") Start another review
5 changes: 3 additions & 2 deletions app/peer-review/review-status/review-status.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ describe('Review Status Controller', function() {
getChallengeDetails: function() {
return $q.when(challenge)
},
getReviewEndDate: function() {
getPhase: function() {
return $q.when(challengeDates)
}
}

var reviewService = {
getUsersPeerReviews: function() {
userReviews.plain = function() { return this }
return $q.when(userReviews)
}
}
Expand Down Expand Up @@ -64,7 +65,7 @@ describe('Review Status Controller', function() {

it('should get a challenge', function() {
expect(controller.challenge).to.exist
expect(controller.challenge.challengeName).to.equal(challenge.data.challengeName)
expect(controller.challenge.challengeName).to.equal(challenge.challengeName)
})

it('should have a user\'s reviews', function() {
Expand Down
27 changes: 18 additions & 9 deletions app/services/challenge.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import moment from 'moment'

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

ChallengeService.$inject = ['CONSTANTS', 'ApiService', '$q']
ChallengeService.$inject = ['CONSTANTS', 'ApiService', '$q', '$log']

function ChallengeService(CONSTANTS, ApiService, $q) {
function ChallengeService(CONSTANTS, ApiService, $q, $log) {
var api = ApiService.restangularV3

var apiV2 = ApiService.restangularV2
var service = {
getChallenges: getChallenges,
getUserChallenges: getUserChallenges,
getUserMarathonMatches: getUserMarathonMatches,
getReviewEndDate: getReviewEndDate,
getPhase: getPhase,
getChallengeDetails: getChallengeDetails,
processActiveDevDesignChallenges: processActiveDevDesignChallenges,
processActiveMarathonMatches: processActiveMarathonMatches,
Expand All @@ -40,14 +40,23 @@ import moment from 'moment'
return api.one('members', handle.toLowerCase()).all('mms').getList(params)
}

function getReviewEndDate(challengeId) {
var url = CONSTANTS.API_URL + '/phases/?filter=' + encodeURIComponent('challengeId=' + challengeId + '&phaseType=4')
return ApiService.requestHandler('GET', url)
function getPhase(challengeId, phaseType) {
return api.one('challenges', challengeId).getList('phases').then(
function(phases) {
return _.find(phases, function(p) { return p.phaseType.toUpperCase() === phaseType})
},
function(err) {
$log.error(err)
}
)
}

function getChallengeDetails(challengeId) {
var url = CONSTANTS.API_URL_V2 + '/challenges/' + challengeId
return ApiService.requestHandler('GET', url, {}, true)
// var url = CONSTANTS.API_URL_V2 + '/challenges/' + challengeId
// return ApiService.requestHandler('GET', url, {}, true)
return apiV2.one('challenges', challengeId).get().then(
function(data) { return data.plain() }
)
}

function processActiveDevDesignChallenges(challenges) {
Expand Down
2 changes: 0 additions & 2 deletions app/services/helpers.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import angular from 'angular'
Helpers.$inject = ['$window', '$location', '$state', '$http', '$filter', 'ISO3166']

function Helpers($window, $location, $state, $http, $filter, ISO3166) {
// TODO: Separate helpers by submodule

var service = {
storeById: storeById,
parseQuestions: parseQuestions,
Expand Down
25 changes: 12 additions & 13 deletions app/services/review.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import angular from 'angular'
ReviewService.$inject = ['CONSTANTS', 'ApiService']

function ReviewService(CONSTANTS, ApiService) {
var api = ApiService.getApiServiceProvider('Review')

var service = {
getUsersPeerReviews: getUsersPeerReviews,
getReview: getReview,
Expand All @@ -20,39 +22,36 @@ import angular from 'angular'

///////////////
function getUsersPeerReviews(challengeId) {
var url = CONSTANTS.API_URL + '/reviews/?filter=' + encodeURIComponent('challengeId=' + challengeId)
return ApiService.requestHandler('GET', url)
return api.all('reviews').getList({filter: encodeURIComponent('challengeId=' + challengeId)})
}

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

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

function getNextReview(challengeId) {
var url = CONSTANTS.API_URL + '/reviews/' + challengeId + '/assignNextReview'
return ApiService.requestHandler('PUT', url)
return api.one('reviews', challengeId).customPUT(null, 'assignNextReview', null, null)
}

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

function markAsCompleted(reviewId) {
var url = CONSTANTS.API_URL + '/reviews/' + reviewId
var body = {
committed: 1,
id: reviewId
}

return ApiService.requestHandler('PUT', url, JSON.stringify(body))
return api.one('reviews', reviewId).customPUT(body, null, null, null)
}
}
})()
20 changes: 14 additions & 6 deletions app/services/scorecard.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import angular from 'angular'
ScorecardService.$inject = ['CONSTANTS', 'ApiService']

function ScorecardService(CONSTANTS, ApiService) {
var api = ApiService.restangularV3

var service = {
getScorecardById: getScorecardById,
getScorecard: getScorecard,
Expand All @@ -18,18 +20,24 @@ import angular from 'angular'
///////////////

function getScorecardById(scorecardId) {
var url = CONSTANTS.API_URL + '/scorecards/?filter=' + encodeURIComponent('scorecardId=' + scorecardId)
return ApiService.requestHandler('GET', url)
return api.all('scorecards').getList({filter: encodeURIComponent('scorecardId='+scorecardId)})
.then(function(data) {
return data.plain()
})
}

function getScorecard(challengeId) {
var url = CONSTANTS.API_URL + '/scorecards/?filter=' + encodeURIComponent('challengeId=' + challengeId)
return ApiService.requestHandler('GET', url)
return api.all('scorecards').getList({filter: encodeURIComponent('challengeId='+challengeId)})
.then(function(data) {
return data.plain()
})
}

function getScorecardQuestions(scorecardId) {
var url = CONSTANTS.API_URL + '/scorecardQuestions/?filter=' + encodeURIComponent('scorecardId=' + scorecardId)
return ApiService.requestHandler('GET', url)
return api.all('scorecardQuestions').getList({filter: encodeURIComponent('scorecardId='+scorecardId)})
.then(function(data) {
return data.plain()
})
}
}
})()
Loading