Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit b0cd66aa authored by Arnaud Bey's avatar Arnaud Bey
Browse files

fix JS objective

parent fc51c473
...@@ -3,7 +3,9 @@ var constraints = { ...@@ -3,7 +3,9 @@ var constraints = {
var prototype = $("#prototypes").data("prototype-constraint"); var prototype = $("#prototypes").data("prototype-constraint");
var constraints = $('#constraints'); var constraints = $('#constraints');
var constraint = prototype; var constraint = prototype;
constraint = constraint.replace(/__name__/g, $(".constraint-objective").length); var constraintObjectives = document.getElementsByClassName('constraint-objective');
var length = constraintObjectives.length;
constraint = constraint.replace(/__constraint_prot__/g, length);
constraints.append(constraint); constraints.append(constraint);
}, },
checkAll: function(){ checkAll: function(){
...@@ -28,18 +30,3 @@ $( "#constraints-tab" ).on( "change", "select", function(){ ...@@ -28,18 +30,3 @@ $( "#constraints-tab" ).on( "change", "select", function(){
$( "#constraints-tab" ).ready(function() { $( "#constraints-tab" ).ready(function() {
constraints.checkAll(); constraints.checkAll();
}); });
var features = {
add: function(btn){
var constraint = btn.closest('li');
var prototype = $("#prototypes").data("prototype-feature");
var features = $(constraint).find('.features');
var feature = prototype;
feature = feature.replace(/__name__/g, features.find(".feature-objective").length);
features.append(feature);
},
remove: function(btn){
btn.closest('li').remove();
},
};
...@@ -14,25 +14,27 @@ var objectiveConstraint = { ...@@ -14,25 +14,27 @@ var objectiveConstraint = {
for (var j = 0; j < constraints.length; j++) { for (var j = 0; j < constraints.length; j++) {
var objective = constraints[j]; var objective = constraints[j];
var objectiveId = objective[1].id; var objectiveId = objective[1].id;
// on teste si les propriétés du mot match avec l'objectif
if (this.isPertinent(objective, features)) {
console.log(objective);
// Si l'objectif est pas dans incrementedObjs
console.log("isPertinent");
if (incrementedObjs.indexOf(objectiveId) === -1) {
console.log("updateProgress");
objectives.updateProgress(objectiveId);
// on ajoute l'objectif aux constraintes réalisées
this.constraintRealized.push(objectiveId);
incrementedObjs.push(objectiveId);
// on compte si le compte est bon...
if (this.checkCompletion(objective)) {
objectives.considerAsDone(objectiveId);
activity.sendObjectiveDone(objectiveId);
}
// on évite les objectifs déjà complétés
if (this.checkCompletion(objective) === false) {
// on teste si les propriétés du mot match avec l'objectif
if (this.isPertinent(objective, features)) {
// Si l'objectif est pas dans incrementedObjs
if (incrementedObjs.indexOf(objectiveId) === -1) {
objectives.updateProgress(objectiveId);
// on ajoute l'objectif aux constraintes réalisées
this.constraintRealized.push(objectiveId);
incrementedObjs.push(objectiveId);
// on compte si le compte est bon...
if (this.checkCompletion(objective)) {
objectives.considerAsDone(objectiveId);
activity.sendObjectiveDone(objectiveId);
}
}
} }
} }
} }
//} //}
}, },
...@@ -63,7 +65,7 @@ var objectiveConstraint = { ...@@ -63,7 +65,7 @@ var objectiveConstraint = {
checkCompletion: function(objective) { checkCompletion: function(objective) {
var objectiveId = objective[1].id; var objectiveId = objective[1].id;
var numberToFind = objective[1].numberToFind; var numberToFind = objective[1].numberToFind;
if (this.countByObjective(objectiveId) >= numberToFind) { if (this.countByObjective(objectiveId) === numberToFind) {
return true; return true;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment