Exam002Add.Controller.js 1.58 KB
Newer Older
Thitichaipun Wutthisak committed
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 46 47 48 49 50 51 52 53 54 55 56
'use strict'

angular.module('EXAM').controller('Exam002Add', ['$scope', '$http', 'EXAMSERVICES', function($scope, $http, EXAMSERVICES){
   $scope.questset3 = [];

   EXAMSERVICES.ManageExam002.query({examid: '0', querytype: 'ex03'})
   .$promise.then(function(data){
      $scope.questset3 = data.result;
      console.log(data);
   });


   $scope.checkSelect = function(){
      var result = [];
      $scope.questset3.forEach(function(data){
         if (data.ischeck != undefined && data.ischeck == true ){
            if (data.question_type == 1){
               result.push({
                  'questionid': data.questionset3id,
                  'question_name': data.questionset3_name,
                  'score': data.total_score,
                  'question_type': data.question_type,
                  'question_body': data.question_body
               });
            }else if (data.question_type == 0){
               result.push({
                  'questionid': data.questionset3id,
                  'question_name': data.questionset3_name,
                  'score': data.total_score,
                  'question_type': data.question_type,
                  'question_body': data.questionset4
               });
            }
         }
      });
      return result;
   }

   $scope.selectAll = function(){
      $scope.questset3.forEach(function(data){
         data.ischeck = true;
      });
   };

   $scope.deSelectAll = function(){
      $scope.questset3.forEach(function(data){
         data.ischeck = false;
      });
   };

   $scope.close = function () {
      window.close();
   }


}]);