all files / js/form/ submittedForm.directive.js

18.18% Statements 2/11
0% Branches 0/6
0% Functions 0/4
18.18% Lines 2/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                                     
/**
 * Created by cklimkowsky on 3/16/15.
 */
angular
    .module('coopEval')
    .directive('ceSubmittedForm', submittedForm);
 
function submittedForm() {
    return {
        restrict: 'E',
        scope: {
            formType: '@',
            evaluation: '='
        },
        link: function (scope, element, attr, controller) {
            /**
             * 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 the questions in a question group so that non-tabular question answers
             * are displayed outside of a table on the View Submitted Form page.
             * @param questionAnswer
             * @returns {boolean}
             */
            scope.tabularQuestionAnswerFilter = function (question) {
                return question.questionType !== 'Paragraph' && question.questionType !== 'Text'
            };
        },
        templateUrl: 'partials/form/submitted-form.html'
    }
}