libfic: Can indicate that an exercice is WIP
This commit is contained in:
parent
4b8e447b1b
commit
c415e06237
10 changed files with 63 additions and 6 deletions
|
|
@ -622,7 +622,7 @@ func createExercice(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
exercice, err := theme.AddExercice(ue.Title, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI, ue.Resolution, ue.SeeAlso, ue.Finished)
|
||||
exercice, err := theme.AddExercice(ue.Title, ue.WIP, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI, ue.Resolution, ue.SeeAlso, ue.Finished)
|
||||
if err != nil {
|
||||
log.Println("Unable to createExercice:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs during exercice creation."})
|
||||
|
|
|
|||
|
|
@ -1712,7 +1712,7 @@ angular.module("FICApp")
|
|||
});
|
||||
});
|
||||
$scope.exercices = Exercice.query();
|
||||
$scope.fields = ["title", "urlid", "statement", "headline", "overview", "finished", "depend", "gain", "coefficient", "videoURI", "resolution", "issue", "issuekind"];
|
||||
$scope.fields = ["title", "urlid", "statement", "headline", "overview", "finished", "depend", "gain", "coefficient", "videoURI", "resolution", "issue", "issuekind", "wip"];
|
||||
|
||||
$scope.inSync = false;
|
||||
$scope.syncExo = function() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@
|
|||
<div class="form-group row" ng-repeat="field in fields">
|
||||
<label for="{{ field }}" class="col-sm-1 col-form-label-sm">{{ field | capitalize }}</label>
|
||||
<div class="col-sm-11">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field != 'statement' && field != 'issue' && field != 'issuekind' && field != 'overview' && field != 'resolution' && field != 'finished' && field != 'depend' && field != 'gain' && field != 'coefficient'">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field != 'statement' && field != 'issue' && field != 'issuekind' && field != 'overview' && field != 'resolution' && field != 'finished' && field != 'depend' && field != 'gain' && field != 'coefficient' && field != 'wip'">
|
||||
<input class="form-check-input" type="checkbox" id="{{ field }}" ng-model="exercice[field]" ng-if="field == 'wip'">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field == 'gain'" integer>
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field == 'coefficient'" float>
|
||||
<textarea class="form-control form-control-sm" id="{{field}}" ng-model="exercice[field]" ng-if="field == 'statement' || field == 'overview' || field == 'finished' || field == 'resolution' || field == 'issue'"></textarea>
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ type ExerciceFlagChoice struct {
|
|||
|
||||
// ExerciceParams contains values parsed from defines.txt.
|
||||
type ExerciceParams struct {
|
||||
WIP bool `toml:"wip"`
|
||||
Gain int64
|
||||
Tags []string
|
||||
Files []ExerciceFile `toml:"file"`
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ import (
|
|||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
// Set AllowWIPExercice if WIP exercices are accepted.
|
||||
var AllowWIPExercice bool = false
|
||||
|
||||
func fixnbsp(s string) string {
|
||||
return strings.Replace(strings.Replace(strings.Replace(s, " ?", " ?", -1), " !", " !", -1), " :", " :", -1)
|
||||
}
|
||||
|
|
@ -116,6 +119,11 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
|
|||
}
|
||||
}
|
||||
|
||||
// Character reserved for WIP exercices
|
||||
if len(e.Title) > 0 && e.Title[0] == '%' {
|
||||
errs = append(errs, NewExerciceError(e, fmt.Errorf("title can't contain start by '%%'"), theme))
|
||||
}
|
||||
|
||||
e.URLId = fic.ToURLid(e.Title)
|
||||
e.Title = fixnbsp(e.Title)
|
||||
|
||||
|
|
@ -207,6 +215,11 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
|
|||
}
|
||||
}
|
||||
|
||||
e.WIP = p.WIP
|
||||
if p.WIP && !AllowWIPExercice {
|
||||
errs = append(errs, NewExerciceError(e, fmt.Errorf("exercice declared Work In Progress in challenge.txt"), theme))
|
||||
}
|
||||
|
||||
if p.Gain == 0 {
|
||||
errs = append(errs, NewChallengeTxtError(e, 0, fmt.Errorf("Undefined gain for challenge"), theme))
|
||||
} else {
|
||||
|
|
|
|||
Reference in a new issue