/**
* Created by cklimkowsky on 3/16/15.
*/
angular
.module('coopEval')
.directive('ceOpenForm', openForm);
function openForm() {
return {
restrict: 'E',
scope: {
formType: '@',
evaluation: '=',
form: '=',
submitted: '='
},
link: function (scope, element, attr, ctrl) {
/**
* Determines whether a question of the given question type exists in the given question group.
* @param questionGroup
* @param questionType
* @returns {boolean} True if questionGroup contains a question of type questionType, false otherwise.
*/
scope.questionGroupContainsQuestionType = function (questionGroup, questionType) {
if (questionGroup) {
for (var i = 0; i < questionGroup.questions.length; i++) {
if (questionGroup.questions[i].questionType == questionType) {
return true;
}
}
}
return false;
};
/**
* Filters out any questions in a question group that do not have the specified question type.
* @param questionType The type of questions that are desired
* @returns {Function}
*/
scope.questionTypeFilter = function (questionType) {
return function (question) {
return question.questionType == questionType;
}
};
},
templateUrl: 'partials/form/open-form.html'
}
} |