Browse Source

Corrections mappingObjective

Mael ETIENNE 3 years ago
parent
commit
0f5e757310

+ 1
- 1
Controller/Track2004Controller.php View File

@@ -340,10 +340,10 @@ class Track2004Controller extends AbstractController
340 340
           //======================================================================================//
341 341
          //                                FIN                                                   //
342 342
         //======================================================================================//
343
+        $em->persist($primaryObjectiveInfo);
343 344
         $em->persist($track);
344 345
         $em->persist($mapTrackItem);
345 346
         $em->persist($attemptInfo);
346
-        $em->persist($primaryObjectiveInfo);
347 347
 
348 348
         // On flush toutes les données persistées jusqu'à maintenant
349 349
         $em->flush();

+ 3
- 4
EntityListener/Scorm2004ObjectiveProgressInformationListener.php View File

@@ -23,14 +23,13 @@ class Scorm2004ObjectiveProgressInformationListener
23 23
     {
24 24
         $em = $event->getEntityManager();
25 25
         $uow = $uow = $em->getUnitOfWork();
26
-        $updates = $uow->getScheduledEntityUpdates();
27 26
 
28
-        // Vérifier que l'on n'est pas sur une création d'objet
29
-        if ($objectiveProgressInfo->getObjectiveInformationId() > 0) {
27
+        // On traite l'objectif uniquement si il est élligible pour une mise à jour
28
+        if ($uow->isScheduledForUpdate($objectiveProgressInfo)) {
30 29
             $objectives = $this->scorm2004ObjectiveProgressInfoManager->updateFromObjectiveProgressInfo($objectiveProgressInfo);
31 30
 
32 31
             foreach ($objectives as $objective) {
33
-                if ($objective->getObjectiveInformationId() > 0 && $manager->contains($objective)) {
32
+                if ($objective->getObjectiveInformationId() > 0 && $em->contains($objective)) {
34 33
                     $uow->scheduleForUpdate($objective);
35 34
                 }
36 35
             }

+ 22
- 22
Repository/Scorm2004/Scorm2004ObjectiveProgressInformationRepository.php View File

@@ -133,6 +133,8 @@ class Scorm2004ObjectiveProgressInformationRepository extends EntityRepository
133 133
             return null;
134 134
         }
135 135
 
136
+        $dummyInfo = clone $localInfo;
137
+
136 138
         // On recherche si il existe un mappage avec un objectif global
137 139
         $mapInfos = $dom->getMapInfos($objective['item'], $objective['objective'], $objective['isPrimary']);
138 140
         
@@ -147,38 +149,36 @@ class Scorm2004ObjectiveProgressInformationRepository extends EntityRepository
147 149
                 // On remplace dans l'objet que l'on va retourner
148 150
                 // les valeurs spécifiques au mappage
149 151
                 if ($globalInfo) {
150
-                    if ($mapInfo['readSatisfiedStatus']) {
151
-                        $localInfo->setProgressStatus($globalInfo->getProgressStatus());
152
-                        $localInfo->setSatisfiedStatus($globalInfo->getSatisfiedStatus());
152
+                    if ($mapInfo['readSatisfiedStatus'] === 'true') {
153
+                        $dummyInfo->setProgressStatus($globalInfo->getProgressStatus());
154
+                        $dummyInfo->setSatisfiedStatus($globalInfo->getSatisfiedStatus());
153 155
                     }
154
-                    if ($mapInfo['readNormalizedMeasure']) {
155
-                        $localInfo->setMeasureStatus($globalInfo->getMeasureStatus());
156
-                        $localInfo->setNormalizedMeasure($globalInfo->getNormalizedMeasure());
156
+                    if ($mapInfo['readNormalizedMeasure'] === 'true') {
157
+                        $dummyInfo->setMeasureStatus($globalInfo->getMeasureStatus());
158
+                        $dummyInfo->setNormalizedMeasure($globalInfo->getNormalizedMeasure());
157 159
                     }
158
-                    if ($mapInfo['readCompletionStatus']) {
159
-                        $localInfo->setAttemptProgressStatus($globalInfo->getAttemptProgressStatus());
160
-                        $localInfo->setAttemptCompletionStatus($globalInfo->getAttemptCompletionStatus());
160
+                    if ($mapInfo['readCompletionStatus'] === 'true') {
161
+                        $dummyInfo->setAttemptProgressStatus($globalInfo->getAttemptProgressStatus());
162
+                        $dummyInfo->setAttemptCompletionStatus($globalInfo->getAttemptCompletionStatus());
161 163
                     }
162
-                    if ($mapInfo['readProgressMeasure']) {
163
-                        $localInfo->setAttemptCompletionAmountStatus($globalInfo->getAttemptCompletionAmountStatus());
164
-                        $localInfo->setAttemptCompletionAmount($globalInfo->getAttemptCompletionAmount());
164
+                    if ($mapInfo['readProgressMeasure'] === 'true') {
165
+                        $dummyInfo->setAttemptCompletionAmountStatus($globalInfo->getAttemptCompletionAmountStatus());
166
+                        $dummyInfo->setAttemptCompletionAmount($globalInfo->getAttemptCompletionAmount());
165 167
                     }
166
-                    if ($mapInfo['readRawScore']) {
167
-                        $localInfo->setScoreRaw($globalInfo->getScoreRaw());
168
+                    if ($mapInfo['readRawScore'] === 'true') {
169
+                        $dummyInfo->setScoreRaw($globalInfo->getScoreRaw());
168 170
                     }
169
-                    if ($mapInfo['readMinScore']) {
170
-                        $localInfo->setScoreMin($globalInfo->getScoreMin());
171
+                    if ($mapInfo['readMinScore'] === 'true') {
172
+                        $dummyInfo->setScoreMin($globalInfo->getScoreMin());
171 173
                     }
172
-                    if ($mapInfo['readMaxScore']) {
173
-                        $localInfo->setScoreMax($globalInfo->getScoreMax());
174
+                    if ($mapInfo['readMaxScore'] === 'true') {
175
+                        $dummyInfo->setScoreMax($globalInfo->getScoreMax());
174 176
                     }
175 177
                 }
176
-                
177
-                return $localInfo;
178 178
             }
179 179
         }
180
-
181
-        return null;
180
+        
181
+        return $dummyInfo;
182 182
     }
183 183
 
184 184
     /**

+ 9
- 9
Services/Scorm2004ObjectiveProgressInfoManager.php View File

@@ -56,7 +56,7 @@ class Scorm2004ObjectiveProgressInfoManager
56 56
             $isPrimary = $objectiveProgressInfo->getIsPrimary();
57 57
 
58 58
             // Controle de l'existence d'un mappage avec un objectif global
59
-            $mapinfo = $domScorm2004->getMapInfos($item, $objective, $isPrimary);
59
+            $mapInfos = $domScorm2004->getMapInfos($item, $objective, $isPrimary);
60 60
 
61 61
             if (!empty($mapInfos)) {
62 62
                 $organization = $track->getOrganizationId();
@@ -64,7 +64,7 @@ class Scorm2004ObjectiveProgressInfoManager
64 64
                 $track = $attempt->getScorm2004Track();
65 65
                 
66 66
                 foreach ($mapInfos as $mapInfo) {
67
-                    $globalObjective = $mapInfo['targetId'];
67
+                    $globalObjective = $mapInfo['targetObjectiveID'];
68 68
                     
69 69
                     // récupération des infos de l'objectif global mappé
70 70
                     $globalInfo = $this->repository->getGlobalInfo($globalObjective, $track, $isGlobalToSystem);
@@ -72,29 +72,29 @@ class Scorm2004ObjectiveProgressInfoManager
72 72
                     // On remplace dans l'objet que l'on va retourner
73 73
                     // les valeurs spécifiques au mappage
74 74
                     if ($globalInfo) {
75
-                        if ($mapinfo['writeSatisfiedStatus']) {
75
+                        if ($mapInfo['writeSatisfiedStatus'] === 'true') {
76 76
                             $globalInfo->setProgressStatus($objectiveProgressInfo->getProgressStatus());
77 77
                             $globalInfo->setSatisfiedStatus($objectiveProgressInfo->getSatisfiedStatus());
78 78
                         }
79
-                        if ($mapinfo['writeNormalizedMeasure']) {
79
+                        if ($mapInfo['writeNormalizedMeasure'] === 'true') {
80 80
                             $globalInfo->setMeasureStatus($objectiveProgressInfo->getMeasureStatus());
81 81
                             $globalInfo->setNormalizedMeasure($objectiveProgressInfo->getNormalizedMeasure());
82 82
                         }
83
-                        if ($mapinfo['writeCompletionStatus']) {
83
+                        if ($mapInfo['writeCompletionStatus'] === 'true') {
84 84
                             $globalInfo->setAttemptProgressStatus($objectiveProgressInfo->getAttemptProgressStatus());
85 85
                             $globalInfo->setAttemptCompletionStatus($objectiveProgressInfo->getAttemptCompletionStatus());
86 86
                         }
87
-                        if ($mapinfo['writeProgressMeasure']) {
87
+                        if ($mapInfo['writeProgressMeasure'] === 'true') {
88 88
                             $globalInfo->setAttemptCompletionAmountStatus($objectiveProgressInfo->getAttemptCompletionAmountStatus());
89 89
                             $globalInfo->setAttemptCompletionAmount($objectiveProgressInfo->getAttemptCompletionAmount());
90 90
                         }
91
-                        if ($mapinfo['writeRawScore']) {
91
+                        if ($mapInfo['writeRawScore'] === 'true') {
92 92
                             $globalInfo->setScoreRaw($objectiveProgressInfo->getScoreRaw());
93 93
                         }
94
-                        if ($mapinfo['writeMinScore']) {
94
+                        if ($mapInfo['writeMinScore'] === 'true') {
95 95
                             $globalInfo->setScoreMin($objectiveProgressInfo->getScoreMin());
96 96
                         }
97
-                        if ($mapinfo['writeMaxScore']) {
97
+                        if ($mapInfo['writeMaxScore'] === 'true') {
98 98
                             $globalInfo->setScoreMax($objectiveProgressInfo->getScoreMax());
99 99
                         }
100 100
                         

Loading…
Cancel
Save