UNPKG

unserver-unify

Version:

67 lines (58 loc) 1.99 kB
angular.module('bamboo.course').controller('DragFillChapterCtrl', function($scope, $stateParams, ApiService) { this.cid = $stateParams.cid; var self = this; var resUrl = this.resUrl = ApiService.SHOST + '/lcourse/' + this.cid + '/resources/'; this.init = function(chapter) { self.chapter = chapter; self.answers = _.shuffle(angular.copy(self.chapter.options)); $scope.multiTargetList = initTargetList(); self.submitted = false; console.log(chapter); } function initTargetList() { var multiTargetList = []; for (var i = 0; i < (self.chapter.options.length-1); i++) { multiTargetList.push({jqyoui_pos:0}); } return multiTargetList; } $scope.getTrustAsHtml = function(str) { return s.unescapeHTML(str); } $scope.startCallback = function(event, ui, title) { console.log('You started draggin: ' + title.title); $scope.draggedTitle = title.title; }; $scope.stopCallback = function(event, ui) { console.log('Why did you stop draggin me?'); }; $scope.dragCallback = function(event, ui) { console.log('hey, look I`m flying'); }; $scope.dropCallback = function(event, ui) { console.log('hey, you dumped me :-(', $scope.draggedTitle); }; $scope.overCallback = function(event, ui) { console.log('Look, I`m over you'); }; $scope.outCallback = function(event, ui) { console.log('I`m not, hehe'); }; $scope.selectMultiMatch = function(opt,idx){ console.log(idx); } this.submit = function(){ self.ans = 0; angular.forEach(self.chapter.options,function(val,idx){ if($scope.multiTargetList[idx]&&val.text==$scope.multiTargetList[idx].text){ self.ans+=1; } }); self.submitted = true; } this.reset = function(){ self.answers = _.shuffle(angular.copy(self.chapter.options)); $scope.multiTargetList = initTargetList(); self.submitted = false; } });