/**
* Created by cklimkowsky on 4/22/15.
*/
angular
.module('coopEval')
.controller('ViewEvaluationsController', ViewEvaluationsController);
function ViewEvaluationsController($scope, $stateParams, $rootScope, $location, formService) {
// Indicates the current view mode on the View Evaluations page
$scope.currentEvaluationsView = 'Both';
// Get the student work report and employer evaluation for a particular placement
if ($stateParams.placementId) {
formService.getStudentWorkReport($stateParams.placementId)
.success(function (result) {
$scope.studentEvaluation = result;
for (var i = 0; i < $scope.studentEvaluation.questionGroups.length; i++) {
for (var j = 0; j < $scope.studentEvaluation.questionGroups[i].questions.length; j++) {
$scope.studentEvaluation.questionGroups[i].questions[j].isCommentAllowed = parseInt($scope.studentEvaluation.questionGroups[i].questions[j].isCommentAllowed);
$scope.studentEvaluation.questionGroups[i].questions[j].isRequired = parseInt($scope.studentEvaluation.questionGroups[i].questions[j].isRequired);
if ($scope.studentEvaluation.questionGroups[i].questions[j].questionType == 'Numeric') {
if ($scope.studentEvaluation.questionGroups[i].questions[j].answer) {
$scope.studentEvaluation.questionGroups[i].questions[j].answer = parseFloat($scope.studentEvaluation.questionGroups[i].questions[j].answer);
}
} else if ($scope.studentEvaluation.questionGroups[i].questions[j].questionType == 'DoubleLikert') {
if ($scope.studentEvaluation.questionGroups[i].questions[j].answer) {
var answers = $scope.studentEvaluation.questionGroups[i].questions[j].answer.split(',');
$scope.studentEvaluation.questionGroups[i].questions[j].answer = answers[0];
$scope.studentEvaluation.questionGroups[i].questions[j].answer2 = answers[1];
$scope.studentEvaluation.questionGroups[i].questions[j].answer3 = answers[2];
} else {
$scope.studentEvaluation.questionGroups[i].questions[j].answer = null;
$scope.studentEvaluation.questionGroups[i].questions[j].answer2 = null;
$scope.studentEvaluation.questionGroups[i].questions[j].answer3 = false;
}
}
}
}
});
formService.getEmployerEvaluation($stateParams.placementId)
.success(function (result) {
$scope.employerEvaluation = result;
for (var i = 0; i < $scope.employerEvaluation.questionGroups.length; i++) {
for (var j = 0; j < $scope.employerEvaluation.questionGroups[i].questions.length; j++) {
$scope.employerEvaluation.questionGroups[i].questions[j].isCommentAllowed = parseInt($scope.employerEvaluation.questionGroups[i].questions[j].isCommentAllowed);
$scope.employerEvaluation.questionGroups[i].questions[j].isRequired = parseInt($scope.employerEvaluation.questionGroups[i].questions[j].isRequired);
if ($scope.employerEvaluation.questionGroups[i].questions[j].questionType == 'Numeric') {
if ($scope.employerEvaluation.questionGroups[i].questions[j].answer) {
$scope.employerEvaluation.questionGroups[i].questions[j].answer = parseFloat($scope.employerEvaluation.questionGroups[i].questions[j].answer);
}
} else if ($scope.employerEvaluation.questionGroups[i].questions[j].questionType == 'DoubleLikert') {
if ($scope.employerEvaluation.questionGroups[i].questions[j].answer) {
var answers = $scope.employerEvaluation.questionGroups[i].questions[j].answer.split(',');
$scope.employerEvaluation.questionGroups[i].questions[j].answer = answers[0];
$scope.employerEvaluation.questionGroups[i].questions[j].answer2 = answers[1];
$scope.employerEvaluation.questionGroups[i].questions[j].answer3 = answers[2];
} else {
$scope.employerEvaluation.questionGroups[i].questions[j].answer = null;
$scope.employerEvaluation.questionGroups[i].questions[j].answer2 = null;
$scope.employerEvaluation.questionGroups[i].questions[j].answer3 = false;
}
}
}
}
});
}
/**
* Approves the current student evaluation.
*/
$scope.approveEvaluation = function () {
formService.approveEvaluation($scope.studentEvaluation)
.success(function (result) {
$rootScope.message = {
type: 'success',
content: '<strong>Evaluation for ' +
$scope.studentEvaluation.studentFirstName + ' ' +
$scope.studentEvaluation.studentLastName + ', term ' +
$scope.studentEvaluation.termCode + ' was successfully approved.</strong><br>' +
'An email was successfully sent to the student informing them of this approval.',
location: $location.path()
};
$scope.studentEvaluation.evaluationApproval.approvalStatus = 'Approved';
});
};
/**
* Rejects the current student evaluation.
*/
$scope.rejectEvaluation = function () {
formService.rejectEvaluation($scope.studentEvaluation)
.success(function (result) {
$rootScope.message = {
type: 'danger',
content: '<strong>Evaluation for ' +
$scope.studentEvaluation.studentFirstName + ' ' +
$scope.studentEvaluation.studentLastName + ', term ' +
$scope.studentEvaluation.termCode + ' was rejected.</strong><br>' +
'An email was successfully sent to the student informing them of this rejection, ' +
'requesting they update their work report for re-evaluation.',
location: $location.path()
};
$scope.studentEvaluation.evaluationApproval.approvalStatus = 'Rejected';
});
};
}
|