admin: implement MCQ edition in interface

This commit is contained in:
nemunaire 2018-06-24 18:12:26 +02:00 committed by Pierre-Olivier Mercier
commit 3a65363ebb
3 changed files with 137 additions and 0 deletions

View file

@ -222,6 +222,11 @@ angular.module("FICApp")
return $resource("/api/exercices/:exerciceId/keys/:keyId", { exerciceId: '@idExercice', keyId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceMCQKey", function($resource) {
return $resource("/api/exercices/:exerciceId/quiz/:mcqId", { exerciceId: '@idExercice', mcqId: '@id' }, {
update: {method: 'PUT'}
})
});
String.prototype.capitalize = function() {
@ -1127,6 +1132,35 @@ angular.module("FICApp")
};
})
.controller("ExerciceMCQKeysController", function($scope, ExerciceMCQKey, $routeParams, $rootScope, $http) {
$scope.quiz = ExerciceMCQKey.query({ exerciceId: $routeParams.exerciceId });
$scope.addQuiz = function() {
$scope.quiz.push(new ExerciceMCQKey());
}
$scope.deleteQuiz = function() {
this.q.$delete(function() {
$scope.quiz.splice($scope.quiz.indexOf(this.q), 1);
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when trying to delete flag:', response.data);
});
}
$scope.saveQuiz = function() {
if (this.q.id) {
this.q.$update();
} else {
this.q.$save({ exerciceId: $routeParams.exerciceId });
}
}
$scope.addChoice = function() {
this.quiz[this.qk].entries.push({label: "", response: false})
}
$scope.deleteChoice = function() {
this.quiz[this.qk].entries.splice(this.quiz[this.qk].entries.indexOf(this.choice), 1);
}
})
.controller("TeamsListController", function($scope, Team, $location) {
$scope.teams = Team.query();
$scope.fields = ["id", "name"];