admin: add the ability to sync only one exercice
This commit is contained in:
parent
dc4a4925e3
commit
2ccc59b4fa
|
@ -52,6 +52,11 @@ func init() {
|
||||||
router.PUT("/api/exercices/:eid/tags", apiHandler(exerciceHandler(updateExerciceTags)))
|
router.PUT("/api/exercices/:eid/tags", apiHandler(exerciceHandler(updateExerciceTags)))
|
||||||
|
|
||||||
// Synchronize
|
// Synchronize
|
||||||
|
router.POST("/api/sync/themes/:thid/exercices/:eid", apiHandler(themedExerciceHandler(
|
||||||
|
func(theme fic.Theme, exercice fic.Exercice, _ []byte) (interface{}, error) {
|
||||||
|
_, _, errs := sync.SyncExercice(sync.GlobalImporter, theme, exercice.Path, nil)
|
||||||
|
return errs, nil
|
||||||
|
})))
|
||||||
router.POST("/api/sync/exercices/:eid/files", apiHandler(exerciceHandler(
|
router.POST("/api/sync/exercices/:eid/files", apiHandler(exerciceHandler(
|
||||||
func(exercice fic.Exercice, _ []byte) (interface{}, error) {
|
func(exercice fic.Exercice, _ []byte) (interface{}, error) {
|
||||||
return sync.SyncExerciceFiles(sync.GlobalImporter, exercice), nil
|
return sync.SyncExerciceFiles(sync.GlobalImporter, exercice), nil
|
||||||
|
|
|
@ -907,26 +907,12 @@ angular.module("FICApp")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$scope.deleteTheme = function() {
|
$scope.deleteTheme = function() {
|
||||||
this.theme.$remove(function() { $location.url("/themes/");});
|
this.theme.$remove(function() {
|
||||||
}
|
$location.url("/themes/");
|
||||||
$scope.inSync = false;
|
|
||||||
$scope.syncExo = function() {
|
|
||||||
$scope.inSync = true;
|
|
||||||
$http({
|
|
||||||
url: "/api/sync/themes/" + $scope.theme.id + "/exercices",
|
|
||||||
method: "POST"
|
|
||||||
}).then(function(response) {
|
|
||||||
$scope.inSync = false;
|
|
||||||
$scope.theme = Theme.get({ themeId: $routeParams.themeId });
|
|
||||||
if (response.data)
|
|
||||||
$rootScope.newBox('warning', null, response.data, -1);
|
|
||||||
else
|
|
||||||
$rootScope.newBox('success', 'Synchronisation de la liste des exercices terminée avec succès.');
|
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
$scope.inSync = false;
|
$rootScope.newBox('danger', 'An error occurs when trying to delete theme:', response.data.errmsg);
|
||||||
$rootScope.newBox('danger', 'An error occurs when synchrinizing exercices:', response.data);
|
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller("AllExercicesListController", function($scope, Exercice, $routeParams, $location, $rootScope, $http, $filter) {
|
.controller("AllExercicesListController", function($scope, Exercice, $routeParams, $location, $rootScope, $http, $filter) {
|
||||||
|
@ -995,15 +981,34 @@ angular.module("FICApp")
|
||||||
$scope.syncHints = true;
|
$scope.syncHints = true;
|
||||||
$scope.syncFlags = true;
|
$scope.syncFlags = true;
|
||||||
})
|
})
|
||||||
.controller("ExercicesListController", function($scope, ThemedExercice, $routeParams, $location) {
|
.controller("ExercicesListController", function($scope, ThemedExercice, $routeParams, $location, $rootScope, $http) {
|
||||||
$scope.exercices = ThemedExercice.query({ themeId: $routeParams.themeId });
|
$scope.exercices = ThemedExercice.query({ themeId: $routeParams.themeId });
|
||||||
$scope.fields = ["title", "statement", "overview", "videoURI"];
|
$scope.fields = ["title", "statement", "overview", "videoURI"];
|
||||||
|
|
||||||
$scope.show = function(id) {
|
$scope.show = function(id) {
|
||||||
$location.url("/themes/" + $routeParams.themeId + "/exercices/" + id);
|
$location.url("/themes/" + $routeParams.themeId + "/exercices/" + id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.inSync = false;
|
||||||
|
$scope.syncExo = function() {
|
||||||
|
$scope.inSync = true;
|
||||||
|
$http({
|
||||||
|
url: "/api/sync/themes/" + $scope.theme.id + "/exercices",
|
||||||
|
method: "POST"
|
||||||
|
}).then(function(response) {
|
||||||
|
$scope.inSync = false;
|
||||||
|
$scope.exercices = ThemedExercice.query({ themeId: $routeParams.themeId });
|
||||||
|
if (response.data)
|
||||||
|
$rootScope.newBox('warning', null, response.data, -1);
|
||||||
|
else
|
||||||
|
$rootScope.newBox('success', 'Synchronisation de la liste des exercices terminée avec succès.');
|
||||||
|
}, function(response) {
|
||||||
|
$scope.inSync = false;
|
||||||
|
$rootScope.newBox('danger', 'An error occurs when synchrinizing exercices:', response.data.errmsg);
|
||||||
|
});
|
||||||
|
};
|
||||||
})
|
})
|
||||||
.controller("ExerciceController", function($scope, Exercice, ThemedExercice, $routeParams, $location) {
|
.controller("ExerciceController", function($scope, $rootScope, Exercice, ThemedExercice, $routeParams, $location, $http) {
|
||||||
if ($routeParams.themeId && $routeParams.exerciceId == "new") {
|
if ($routeParams.themeId && $routeParams.exerciceId == "new") {
|
||||||
$scope.exercice = new ThemedExercice();
|
$scope.exercice = new ThemedExercice();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1037,18 +1042,46 @@ angular.module("FICApp")
|
||||||
$scope.showQuizz = val || !$scope.showQuizz;
|
$scope.showQuizz = val || !$scope.showQuizz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.inSync = false;
|
||||||
|
$scope.syncExo = function() {
|
||||||
|
$scope.inSync = true;
|
||||||
|
$http({
|
||||||
|
url: "/api/sync/themes/" + $routeParams.themeId + "/exercices/" + $routeParams.exerciceId,
|
||||||
|
method: "POST"
|
||||||
|
}).then(function(response) {
|
||||||
|
$scope.inSync = false;
|
||||||
|
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
|
||||||
|
if (response.data)
|
||||||
|
$rootScope.newBox('danger', response.data);
|
||||||
|
else
|
||||||
|
$rootScope.newBox('success', "Synchronisation de l'exercice terminée avec succès.");
|
||||||
|
}, function(response) {
|
||||||
|
$scope.inSync = false;
|
||||||
|
$rootScope.newBox('danger', 'An error occurs when synchronizing exercice:', response.data.errmsg);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.deleteExercice = function() {
|
||||||
|
this.exercice.$remove(function() {
|
||||||
|
$location.url("/themes/" + $routeParams.themeId);
|
||||||
|
}, function(response) {
|
||||||
|
$rootScope.newBox('danger', 'An error occurs when trying to delete exercice:', response.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
$scope.saveExercice = function() {
|
$scope.saveExercice = function() {
|
||||||
if (this.exercice.id) {
|
if (this.exercice.id) {
|
||||||
this.exercice.$update();
|
this.exercice.$update();
|
||||||
} else if ($routeParams.themeId) {
|
} else if ($routeParams.themeId) {
|
||||||
this.exercice.$save({ themeId: $routeParams.themeId }, function() {
|
this.exercice.$save({ themeId: $routeParams.themeId }, function() {
|
||||||
$location.url("/themes/" + $scope.exercice.idTheme + "/exercices/" + $scope.exercice.id);
|
$location.url("/themes/" + $scope.exercice.idTheme + "/exercices/" + $scope.exercice.id);
|
||||||
|
}, function(response) {
|
||||||
|
$rootScope.newBox('danger', 'An error occurs when trying to save exercice:', response.data.errmsg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller("ExerciceTagsController", function($scope, ExerciceTags, $routeParams, $rootScope, $http) {
|
.controller("ExerciceTagsController", function($scope, ExerciceTags, $routeParams, $rootScope) {
|
||||||
$scope.tags = ExerciceTags.query({ exerciceId: $routeParams.exerciceId });
|
$scope.tags = ExerciceTags.query({ exerciceId: $routeParams.exerciceId });
|
||||||
|
|
||||||
$scope.addTag = function() {
|
$scope.addTag = function() {
|
||||||
|
@ -1091,7 +1124,7 @@ angular.module("FICApp")
|
||||||
$rootScope.newBox('success', "Synchronisation de la liste de fichiers terminée avec succès.");
|
$rootScope.newBox('success', "Synchronisation de la liste de fichiers terminée avec succès.");
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
$scope.inSync = false;
|
$scope.inSync = false;
|
||||||
$rootScope.newBox('danger', 'An error occurs when synchronizing flags list:', response.data);
|
$rootScope.newBox('danger', 'An error occurs when synchronizing flags list:', response.data.errmsg);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
@ -1178,7 +1211,7 @@ angular.module("FICApp")
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller("ExerciceMCQFlagsController", function($scope, ExerciceMCQFlag, $routeParams, $rootScope, $http) {
|
.controller("ExerciceMCQFlagsController", function($scope, ExerciceMCQFlag, $routeParams, $rootScope) {
|
||||||
$scope.quiz = ExerciceMCQFlag.query({ exerciceId: $routeParams.exerciceId });
|
$scope.quiz = ExerciceMCQFlag.query({ exerciceId: $routeParams.exerciceId });
|
||||||
|
|
||||||
$scope.addQuiz = function() {
|
$scope.addQuiz = function() {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<h2>{{exercice.title}}</h2>
|
<h2>
|
||||||
|
{{exercice.title}}
|
||||||
|
<button type="button" ng-click="syncExo()" ng-class="{'disabled': inSync}" class="float-right btn btn-sm btn-light"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Synchroniser</button>
|
||||||
|
</h2>
|
||||||
|
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user