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 e65f684e authored by Arnaud Bey's avatar Arnaud Bey
Browse files

WIP fixing objectives JS

parent b4e4bc67
......@@ -64,7 +64,6 @@ class Constraint extends Objective
'type' => $this->discr,
'numberToFind' => $this->numberToFind,
'features' => $this->feature ? $this->feature->getId() : null,
);
return $jsonArray;
......
......@@ -283,17 +283,15 @@ class Round implements \JsonSerializable
];
}
foreach ($this->getConstraints() as $constraint) {
$jsonArray['constraints'][] = [
'id' => $constraint->getId(),
'numberToFind' => $constraint->getNumberToFind(),
'category' => $constraint->getCategory() ? $constraint->getCategory()->getId() : null,
'gender' => $constraint->getGender() ? $constraint->getGender()->getId() : null,
'number' => $constraint->getNumber() ? $constraint->getNumber()->getId() : null,
'tense' => $constraint->getTense() ? $constraint->getTense()->getId() : null,
'mood' => $constraint->getMood() ? $constraint->getMood()->getId() : null,
'person' => $constraint->getPerson() ? $constraint->getPerson()->getId() : null,
];
foreach ($this->getConstraints() as $c) {
$constraint = [];
$constraint["id"] = $c->getId();
$constraint["numberToFind"] = $c->getNumberToFind();
foreach ($c->getFeatures() as $feature) {
$constraint[$feature->getLabel()] = $feature->getValue();
}
$jsonArray['constraints'][] = $constraint;
}
}
......
var objectiveConstraint = {
properties: ["category", "number", "gender", "person", "mood", "tense"],
constraintRealized: [],
add: function(inflection){
var infos = gridJSON.inflections[inflection.toLowerCase()].infos;
add: function(inflection) {
var infos = gridJSON.inflections[inflection.toLowerCase()].features;
var incrementedObjs = [];
for (var i = 0; i < infos.length; i++) {
currentInflectionInfos = infos[i];
for (var j = 0; j < roundJSON.constraints.length; j++) {
var objective = roundJSON.constraints[j];
if(this.isPertinent(objective, currentInflectionInfos)){
if (this.isPertinent(objective, currentInflectionInfos)) {
if ($.inArray(objective.id, incrementedObjs) == -1) {
objectives.updateProgress(objective.id);
this.constraintRealized.push(objective.id);
incrementedObjs.push(objective.id);
if(this.checkCompletion(objective)){
if (this.checkCompletion(objective)) {
objectives.considerAsDone(objective.id);
activity.sendObjectiveDone(objective.id);
}
......@@ -24,10 +24,10 @@ var objectiveConstraint = {
}
},
countByObjective: function(objectiveId){
countByObjective: function(objectiveId) {
var count = 0;
for(var i = 0; i < this.constraintRealized.length; ++i){
if(this.constraintRealized[i] == objectiveId){
for (var i = 0; i < this.constraintRealized.length; ++i) {
if (this.constraintRealized[i] == objectiveId) {
count++;
}
}
......@@ -35,7 +35,7 @@ var objectiveConstraint = {
return count;
},
isPertinent: function(objective, infos){
isPertinent: function(objective, infos) {
for (var i = 0; i < this.properties.length; i++) {
var property = this.properties[i];
if (objective[property] != null && objective[property] != infos[property]) {
......@@ -47,8 +47,8 @@ var objectiveConstraint = {
return true;
},
checkCompletion: function(objective){
if(this.countByObjective(objective.id) == objective.numberToFind){
checkCompletion: function(objective) {
if (this.countByObjective(objective.id) == objective.numberToFind) {
return true;
}
......
......@@ -5,7 +5,7 @@ var findword = {
this.found(roundJSON.findWords[inflectionLower], inflection);
return true;
} else {
var lemmaIds = gridJSON.inflections[inflectionLower].lemmaIds;
var lemmaIds = gridJSON.inflections[inflectionLower].rootIds;
for (var i = 0; i < lemmaIds.length; i++) {
for (var key in roundJSON.findWords) {
if (!roundJSON.findWords.hasOwnProperty(key)) continue;
......
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