admin: display {hint,flag,mcq} dependancies on interface

This commit is contained in:
nemunaire 2020-01-23 14:23:02 +01:00
parent ac9361b4ce
commit 9d93331868
3 changed files with 111 additions and 5 deletions

View file

@ -250,15 +250,27 @@ angular.module("FICApp")
update: {method: 'PUT'}
})
})
.factory("ExerciceHintDeps", function($resource) {
return $resource("/api/exercices/:exerciceId/hints/:hintId/dependancies", { exerciceId: '@idExercice', hintId: '@id' })
})
.factory("ExerciceFlag", function($resource) {
return $resource("/api/exercices/:exerciceId/flags/:flagId", { exerciceId: '@idExercice', flagId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceFlagChoices", function($resource) {
return $resource("/api/exercices/:exerciceId/flags/:flagId/choices", { exerciceId: '@idExercice', flagId: '@id' })
})
.factory("ExerciceFlagDeps", function($resource) {
return $resource("/api/exercices/:exerciceId/flags/:flagId/dependancies", { exerciceId: '@idExercice', flagId: '@id' })
})
.factory("ExerciceMCQFlag", function($resource) {
return $resource("/api/exercices/:exerciceId/quiz/:mcqId", { exerciceId: '@idExercice', mcqId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceMCQDeps", function($resource) {
return $resource("/api/exercices/:exerciceId/quiz/:mcqId/dependancies", { exerciceId: '@idExercice', mcqId: '@id' })
});
angular.module("FICApp")
@ -293,6 +305,21 @@ angular.module("FICApp")
}
})
.component('dependancy', {
bindings: {
dep: '=',
deleteDep: '=',
},
controller: function() {},
template: `
<li>
<span ng-if="$ctrl.dep.label">Flag {{ $ctrl.dep.label }}</span>
<span ng-if="$ctrl.dep.title">QCM {{ $ctrl.dep.title }}</span>
<button type="button" class="btn btn-sm btn-danger" ng-if="$ctrl.deleteDep" ng-click="$ctrl.deleteDep()"><span class="glyphicon glyphicon-trash"></span></button>
</li>
`
})
.directive('color', function() {
return {
require: 'ngModel',
@ -1542,6 +1569,12 @@ angular.module("FICApp")
};
})
.controller("ExerciceHintDepsController", function($scope, $routeParams, ExerciceHintDeps) {
$scope.init = function(hint) {
$scope.deps = ExerciceHintDeps.query({ exerciceId: $routeParams.exerciceId, hintId: hint.id });
}
})
.controller("ExerciceFlagsController", function($scope, ExerciceFlag, $routeParams, $rootScope, $http) {
$scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId });
@ -1604,6 +1637,12 @@ angular.module("FICApp")
};
})
.controller("ExerciceFlagDepsController", function($scope, $routeParams, ExerciceFlagDeps) {
$scope.init = function(flag) {
$scope.deps = ExerciceFlagDeps.query({ exerciceId: $routeParams.exerciceId, flagId: flag.id });
}
})
.controller("ExerciceMCQFlagsController", function($scope, ExerciceMCQFlag, $routeParams, $rootScope) {
$scope.quiz = ExerciceMCQFlag.query({ exerciceId: $routeParams.exerciceId });
@ -1635,6 +1674,12 @@ angular.module("FICApp")
}
})
.controller("ExerciceMCQDepsController", function($scope, $routeParams, ExerciceMCQDeps) {
$scope.init = function(flag) {
$scope.deps = ExerciceMCQDeps.query({ exerciceId: $routeParams.exerciceId, mcqId: flag.id });
}
})
.controller("TeamsListController", function($scope, $rootScope, Team, $location, $http) {
$scope.teams = Team.query();
$scope.fields = ["id", "name"];