1gestione.controller('AnswersList', function ($scope, $http) { 2 $scope.answers = []; 3 $scope.type_questions = [ 4 {value:0,name:'Jednokrotnego wyboru'}, 5 {value:1,name:'Wielokrotnego wyboru'} 6 ]; 7 var request = $.ajax({ 8 url: path_to_answers, 9 type: "POST", 10 data: { id : $('input[name=id]').val()} 11}); 12 request.done(function(data){ 13 14 $scope.answers = data; 15 $scope.$apply(); 16 console.log($scope.answers); 17 if($scope.answers.length == 0) { 18 $("html, body").animate({ scrollTop: $(document).height() }, "slow"); 19 } 20 var request = $.ajax({ 21 url: path_to_get_question, 22 type: "POST", 23 data:{id: $('input[name=id]').val()} 24 }); 25 request.done(function(data){ 26 $scope.type_question = $scope.type_questions[data.type_question]; 27 $scope.$apply(); 28 }) 29 }); 30 $scope.edit = function(){ 31 $scope.change(); 32 this.answer.edit = true; 33 34 }; 35 $scope.delete = function(){ 36 id = this.answer.id; 37 dialog.confirmation('Czy chcesz usunÄ Ä odpowiedź?','Usuwanie',function (){ var request = $.ajax({ 38 url: path_to_delete_answer, 39 type: "POST", 40 data: { id : id}}); 41 request.done(function(){ 42 $scope.getData(); 43 44 });},function (){return false;}) 45 46 }; 47 48 49 $scope.save = function(){ 50 if($scope.type_question.value ==0) { 51 if($('input:checked').size() >1) { 52 dialog.message('Przy wybranym typie pytania może byÄ tylko jedna odpowiedź poprawna'); 53 this.answer.correct =false; 54 return false; 55 } 56 } 57 this.answer.edit = undefined; 58 $scope.save_obj(this.answer); 59 60 } 61 $scope.change = function(){ 62 for (var i=0;i<$scope.answers.length;i++) { 63 $scope.answers[i].edit = undefined; 64 } 65 } 66 $scope.save_obj=function(obj) { 67 68 var request = $.ajax({ 69 url: path_to_edit_answer, 70 type: "POST", 71 data: { obj:obj} 72}); 73 request.done(function(data){ 74 //$scope.getData(); 75 }); 76 } 77 $scope.getData=function(){ 78 var request = $.ajax({ 79 url: path_to_answers, 80 type: "POST", 81 data: { id : $('input[name=id]').val()} 82}); 83 request.done(function(data){ 84 $scope.answers = data; 85 $scope.$apply(); 86 }); 87 } 88 $scope.add= function(){ 89 var request = $.ajax({ 90 url: path_to_add_answer, 91 type: "POST", 92 data: {question_id:$('input[name=id]').val()} 93}); 94 request.done(function(data){ 95 var request = $.ajax({ 96 url: path_to_answers, 97 type: "POST", 98 data: { id : $('input[name=id]').val()} 99}); 100 request.done(function(data){ 101 $scope.answers = data; 102 $scope.$apply(); 103 id = data[data.length-1].id 104 $('button[data-id='+id+']').trigger('click'); 105 }); 106 }); 107 } 108 $scope.changeSelect=function(){ 109 //$scope.$apply(); 110 $scope.change_type_question(); 111 /* 112 var request = $.ajax({ 113 url: path_to_change_type_question, 114 type: "POST",
115 data: { id : $('input[name=id]').val(), type:this.type_question.value} 116 }); 117 118 request.done(function(flags){ 119 console.log(flags); 120 if (flags =='clear') { 121 dialog.message('Wszystkie poprawne odpowiedzi zostaÅy oznaczone jako niepoprawne'); 122 for (var i=0;i<$scope.answers.length;i++) { 123 $scope.answers[i].correct = 0; 124 } 125 126 } 127 var request = $.ajax({ 128 url: path_to_get_question, 129 type: "POST", 130 data:{id: $('input[name=id]').val()} 131 }); 132 request.done(function(data){ 133 $scope.type_question = $scope.type_questions[data.type_question]; 134 $scope.$apply(); 135 }) 136 $scope.$apply(); 137 }); 138 */ } 139 140 $scope.change_type_question=function(){ 141 var request = $.ajax({ 142 url: path_to_change_type_question, 143 type: "POST", 144 data: { id : $('input[name=id]').val(), type:this.type_question.value} 145 }); 146 request.done(function(flags){ 147 148 if (flags =='clear') { 149 dialog.message('Wszystkie poprawne odpowiedzi zostaÅy oznaczone jako niepoprawne'); 150 for (var i in $scope.answers) { 151 $scope.answers[i].correct = 0; 152 } 153 $scope.$apply(); 154 155 156 } 157 }); 158 }; 159 160 $scope.test=function(){ 161 162 if($scope.type_question.value ==0) { 163 if($('input:checked').size() >1) { 164 dialog.message('Przy wybranym typie pytania może byÄ tylko jedna odpowiedź poprawna'); 165 this.answer.correct = false; 166 } 167 } 168 $scope.save_obj(this.answer); 169 170 } 171 172 173 174}); 175 176
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.