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

This commit is contained in:
nemunaire 2020-01-23 14:23:02 +01:00
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"];

View file

@ -75,11 +75,7 @@
Dépend de la validation de :
<span ng-if="!file.depends">aucun flag</span>
<ul ng-if="file.depends">
<li ng-repeat="dep in file.depends">
<span ng-if="dep.label">Flag {{ dep.label }}</span>
<span ng-if="dep.title">QCM {{ dep.title }}</span>
<button type="button" class="btn btn-sm btn-danger" ng-click="deleteFileDep()"><span class="glyphicon glyphicon-trash"></span></button>
</li>
<dependancy ng-repeat="dep in file.depends" dep="dep" deleteDep="deleteFileDep"></dependancy>
</ul>
</div>
</form>
@ -118,6 +114,13 @@
<button type="button" ng-click="deleteHint()" class="btn btn-sm btn-danger" ng-show="hint.id"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
</div>
</div>
<div ng-controller="ExerciceHintDepsController" ng-init="init(hint)">
Dépendances&nbsp;:
<ul ng-if="deps.length > 0">
<dependancy ng-repeat="dep in deps" dep="dep"></dependancy>
</ul>
<span ng-if="deps.length == 0"> sans</span>
</div>
</form>
</div>
</div>
@ -177,6 +180,13 @@
<button class="btn btn-sm btn-warning" type="submit"><span class="glyphicon glyphicon-play" aria-hidden="true"></span></button>
</div>
</div>
<div ng-controller="ExerciceFlagDepsController" ng-init="init(flag)">
Dépendances&nbsp;:
<ul ng-if="deps.length > 0">
<dependancy ng-repeat="dep in deps" dep="dep"></dependancy>
</ul>
<span ng-if="deps.length == 0"> sans</span>
</div>
</form>
</div>
</div>
@ -222,6 +232,13 @@
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
</div>
</div>
<div ng-controller="ExerciceMCQDepsController" ng-init="init(q)">
Dépendances&nbsp;:
<ul ng-if="deps.length > 0">
<dependancy ng-repeat="dep in deps" dep="dep"></dependancy>
</ul>
<span ng-if="deps.length == 0"> sans</span>
</div>
</form>
</div>
</div>