Exercice: add overview field

This field is use as a high level description of the exercice. It will be
displayed on the public interface only: not to players.
This commit is contained in:
nemunaire 2017-12-17 14:30:48 +01:00
commit bc4a1ee7de
5 changed files with 28 additions and 19 deletions

View file

@ -558,7 +558,7 @@ angular.module("FICApp")
.controller("AllExercicesListController", function($scope, Exercice, $routeParams, $location, $rootScope, $http) {
$scope.exercices = Exercice.query();
$scope.fields = ["title", "statement", "videoURI"];
$scope.fields = ["title", "statement", "overview", "videoURI"];
$scope.show = function(id) {
$location.url("/exercices/" + id);
@ -607,7 +607,7 @@ angular.module("FICApp")
})
.controller("ExercicesListController", function($scope, ThemedExercice, $routeParams, $location) {
$scope.exercices = ThemedExercice.query({ themeId: $routeParams.themeId });
$scope.fields = ["title", "statement", "videoURI"];
$scope.fields = ["title", "statement", "overview", "videoURI"];
$scope.show = function(id) {
$location.url("/themes/" + $routeParams.themeId + "/exercices/" + id);
@ -620,7 +620,7 @@ angular.module("FICApp")
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
}
$scope.exercices = Exercice.query();
$scope.fields = ["title", "statement", "depend", "gain", "coefficient", "videoURI"];
$scope.fields = ["title", "statement", "overview", "depend", "gain", "coefficient", "videoURI"];
$scope.saveExercice = function() {
if (this.exercice.id) {

View file

@ -4,10 +4,10 @@
<div class="form-group" ng-repeat="field in fields">
<label for="{{ field }}" class="col-xs-1 control-label">{{ field | capitalize }}</label>
<div class="col-xs-11">
<input type="text" class="form-control" id="{{ field }}" ng-model="exercice[field]" ng-show="field != 'statement' && field != 'depend' && field != 'gain' && field != 'coefficient'">
<input type="text" class="form-control" id="{{ field }}" ng-model="exercice[field]" ng-show="field != 'statement' && field != 'overview' && field != 'depend' && field != 'gain' && field != 'coefficient'">
<input type="text" class="form-control" id="{{ field }}" ng-model="exercice[field]" ng-show="field == 'gain'" integer>
<input type="text" class="form-control" id="{{ field }}" ng-model="exercice[field]" ng-show="field == 'coefficient'" float>
<textarea class="form-control" id="{{field}}" ng-model="exercice[field]" ng-show="field == 'statement'"></textarea>
<textarea class="form-control" id="{{field}}" ng-model="exercice[field]" ng-show="field == 'statement' || field == 'overview'"></textarea>
<select class="form-control" id="{{field}}" ng-model="exercice[field]" ng-options="ex.id as ex.title for ex in exercices" ng-show="field == 'depend'">
<option value="">Aucune</option>
</select>

View file

@ -49,6 +49,12 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
emap[ename] = eid
// Overview and scenario
overview, err := getFileContent(i, path.Join(theme.Name, edir, "introduction.txt"))
if err != nil {
errs = append(errs, fmt.Sprintf("%q: introduction.txt: %s", edir, err))
}
statement, err := getFileContent(i, path.Join(theme.Name, edir, "scenario.txt"))
if err != nil {
errs = append(errs, fmt.Sprintf("%q: scenario.txt: %s", edir, err))
@ -65,13 +71,14 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
videoURI := ""
if e, err := theme.GetExerciceByTitle(ename); err != nil {
if _, err := theme.AddExercice(ename, path.Join(theme.Name, edir), statement, depend, gain, videoURI); err != nil {
if _, err := theme.AddExercice(ename, path.Join(theme.Name, edir), statement, overview, nil, gain, videoURI); err != nil {
errs = append(errs, fmt.Sprintf("%q: error on exercice add: %s", edir, err))
continue
}
} else if e.Title != ename || e.Statement != statement || (depend == nil && e.Depend != nil) || (depend != nil && e.Depend == nil) || (depend != nil && e.Depend != nil && *e.Depend != depend.Id) || e.Gain != gain || e.VideoURI != videoURI {
} else if e.Title != ename || e.Statement != statement || e.Overview != overview || (depend == nil && e.Depend != nil) || (depend != nil && e.Depend == nil) || (depend != nil && e.Depend != nil && *e.Depend != depend.Id) || e.Gain != gain || e.VideoURI != videoURI {
e.Title = ename
e.Statement = statement
e.Overview = overview
if depend != nil {
e.Depend = &depend.Id
} else {