admin: Continue refactoring of exercice view

This commit is contained in:
nemunaire 2018-11-18 21:27:35 +01:00 committed by Pierre-Olivier Mercier
parent 06dcd0c2b7
commit 1c09ae2fa8
2 changed files with 40 additions and 26 deletions

View File

@ -1023,6 +1023,26 @@ angular.module("FICApp")
$scope.exercices = Exercice.query(); $scope.exercices = Exercice.query();
$scope.fields = ["title", "urlid", "statement", "overview", "depend", "gain", "coefficient", "videoURI"]; $scope.fields = ["title", "urlid", "statement", "overview", "depend", "gain", "coefficient", "videoURI"];
$scope.showDownloads = false;
$scope.toggleDownloads = function(val) {
$scope.showDownloads = val ||!$scope.showDownloads;
}
$scope.showHints = false;
$scope.toggleHints = function(val) {
$scope.showHints = val || !$scope.showHints;
}
$scope.showFlags = false;
$scope.toggleFlags = function(val) {
$scope.showFlags = val || !$scope.showFlags;
}
$scope.showQuizz = false;
$scope.toggleQuizz = function(val) {
$scope.showQuizz = val || !$scope.showQuizz;
}
$scope.saveExercice = function() { $scope.saveExercice = function() {
if (this.exercice.id) { if (this.exercice.id) {
this.exercice.$update(); this.exercice.$update();
@ -1070,6 +1090,7 @@ angular.module("FICApp")
$scope.hints = ExerciceHint.query({ exerciceId: $routeParams.exerciceId }); $scope.hints = ExerciceHint.query({ exerciceId: $routeParams.exerciceId });
$scope.addHint = function() { $scope.addHint = function() {
$scope.toggleHints(true);
$scope.hints.push(new ExerciceHint()); $scope.hints.push(new ExerciceHint());
} }
$scope.deleteHint = function() { $scope.deleteHint = function() {
@ -1110,6 +1131,7 @@ angular.module("FICApp")
$scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId }); $scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId });
$scope.addFlag = function() { $scope.addFlag = function() {
$scope.toggleFlags(true);
$scope.flags.push(new ExerciceFlag()); $scope.flags.push(new ExerciceFlag());
} }
$scope.deleteFlag = function() { $scope.deleteFlag = function() {
@ -1150,6 +1172,7 @@ angular.module("FICApp")
$scope.quiz = ExerciceMCQFlag.query({ exerciceId: $routeParams.exerciceId }); $scope.quiz = ExerciceMCQFlag.query({ exerciceId: $routeParams.exerciceId });
$scope.addQuiz = function() { $scope.addQuiz = function() {
$scope.toggleQuizz(true);
$scope.quiz.push(new ExerciceMCQFlag()); $scope.quiz.push(new ExerciceMCQFlag());
} }
$scope.deleteQuiz = function() { $scope.deleteQuiz = function() {

View File

@ -27,11 +27,13 @@
<div class="col-md-4" ng-controller="ExerciceFilesController" ng-show="exercice.id"> <div class="col-md-4" ng-controller="ExerciceFilesController" ng-show="exercice.id">
<div class="card border-secondary"> <div class="card border-secondary">
<div class="card-header bg-secondary text-light"> <div class="card-header bg-secondary text-light">
<button ng-click="addFile()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button> <h4 class="m-0" ng-click="toggleDownloads()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showDownloads, 'glyphicon-chevron-down': showDownloads}" aria-hidden="true"></small> Téléchargements</h4>
<button ng-click="syncFiles()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
<h4 class="m-0">Téléchargements</h4>
</div> </div>
<div class="list-group"> <div class="list-group" ng-show="showDownloads">
<div class="list-group-item bg-light text-dark" style="padding: 2px">
<button ng-click="syncFiles()" class="btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Synchroniser</button>
<button ng-click="addFile()" class="btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter</button>
</div>
<form ng-submit="saveFile()" class="list-group-item bg-light text-dark" ng-repeat="file in files"> <form ng-submit="saveFile()" class="list-group-item bg-light text-dark" ng-repeat="file in files">
<div class="row form-group"> <div class="row form-group">
<input type="text" ng-model="file.name" class="col form-control form-control-sm" placeholder="Nom de fichier"> <input type="text" ng-model="file.name" class="col form-control form-control-sm" placeholder="Nom de fichier">
@ -46,22 +48,14 @@
</form> </form>
</div> </div>
</div> </div>
</div>
</div> <div class="mt-2 card border-info" ng-controller="ExerciceHintsController" ng-show="exercice.id">
<hr>
<div class="row mb-5" ng-show="exercice.id">
<div class="col-md-4" ng-controller="ExerciceHintsController">
<div class="card border-info">
<div class="card-header bg-info text-light"> <div class="card-header bg-info text-light">
<button ng-click="addHint()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button> <button ng-click="addHint()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<button ng-click="syncHints()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button> <button ng-click="syncHints()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
<h4 class="m-0">Indices</h4> <h4 class="m-0" ng-click="toggleHints()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showHints, 'glyphicon-chevron-down': showHints}" aria-hidden="true"></small> Indices</h4>
</div> </div>
<div class="list-group"> <div class="list-group" ng-show="showHints">
<form ng-submit="saveHint()" class="list-group-item form-horizontal bg-light text-dark" ng-repeat="hint in hints"> <form ng-submit="saveHint()" class="list-group-item form-horizontal bg-light text-dark" ng-repeat="hint in hints">
<input type="text" id="htitle{{hint.id}}" ng-model="hint.title" class="form-control form-control-sm" placeholder="Titre"> <input type="text" id="htitle{{hint.id}}" ng-model="hint.title" class="form-control form-control-sm" placeholder="Titre">
<textarea class="form-control form-control-sm" id="hcnt{{hint.id}}" ng-model="hint.content" ng-if="!hint.file"></textarea> <textarea class="form-control form-control-sm" id="hcnt{{hint.id}}" ng-model="hint.content" ng-if="!hint.file"></textarea>
@ -84,16 +78,14 @@
</form> </form>
</div> </div>
</div> </div>
</div>
<div class="col-md-4" ng-controller="ExerciceFlagsController"> <div class="mt-2 card border-success" ng-controller="ExerciceFlagsController" ng-show="exercice.id">
<div class="card border-success"> <div class="card-header bg-success border-success text-light">
<div class="card-header bg-success text-light">
<button ng-click="addFlag()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button> <button ng-click="addFlag()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<button ng-click="syncFlags()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button> <button ng-click="syncFlags()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
<h4>Drapeaux</h4> <h4 class="m-0" ng-click="toggleFlags()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showFlags, 'glyphicon-chevron-down': showFlags}" aria-hidden="true"></small> Drapeaux</h4>
</div> </div>
<div class="list-group"> <div class="list-group" ng-show="showFlags">
<form ng-submit="saveFlag()" class="list-group-item form-horizontal bg-light text-dark" ng-repeat="flag in flags"> <form ng-submit="saveFlag()" class="list-group-item form-horizontal bg-light text-dark" ng-repeat="flag in flags">
<div class="row" id="flag-{{flag.id}}"> <div class="row" id="flag-{{flag.id}}">
<input type="text" id="klabel{{flag.id}}" ng-model="flag.label" class="col form-control form-control-sm" placeholder="Intitulé" title="Intitulé"> <input type="text" id="klabel{{flag.id}}" ng-model="flag.label" class="col form-control form-control-sm" placeholder="Intitulé" title="Intitulé">
@ -121,15 +113,13 @@
</form> </form>
</div> </div>
</div> </div>
</div>
<div class="col-md-4" ng-controller="ExerciceFlagsController"> <div class="mt-2 card border-success" ng-controller="ExerciceMCQFlagsController" ng-show="exercice.id">
<div class="card border-success" ng-controller="ExerciceMCQFlagsController">
<div class="card-header bg-success text-light"> <div class="card-header bg-success text-light">
<button ng-click="addQuiz()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button> <button ng-click="addQuiz()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<h4>Quizz</h4> <h4 class="m-0" ng-click="toggleQuizz()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showQuizz, 'glyphicon-chevron-down': showQuizz}" aria-hidden="true"></small> Quizz</h4>
</div> </div>
<div class="list-group"> <div class="list-group" ng-show="showQuizz">
<form ng-submit="saveQuiz()" class="list-group-item form-horizontal bg-light text-dark" ng-repeat="(qk,q) in quiz"> <form ng-submit="saveQuiz()" class="list-group-item form-horizontal bg-light text-dark" ng-repeat="(qk,q) in quiz">
<div class="form-group row" id="quiz-{{q.id}}"> <div class="form-group row" id="quiz-{{q.id}}">
<input type="text" id="qlabel{{q.id}}" ng-model="q.title" class="col form-control" placeholder="Intitulé"> <input type="text" id="qlabel{{q.id}}" ng-model="q.title" class="col form-control" placeholder="Intitulé">
@ -161,6 +151,7 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>