Browse Source

TLD-558 Item de Selection

www-data 3 years ago
parent
commit
cc7b2b8dcb

+ 27
- 34
Player/SCORM2004/Scorm2004PlayerLogic.php View File

@@ -1,10 +1,9 @@
1 1
 <?php
2
+
2 3
 namespace Logipro\Bundle\SCORMBundle\Player\SCORM2004;
3 4
 
4
-use Doctrine\Common\Persistence\ManagerRegistry;
5 5
 use Doctrine\ORM\EntityManagerInterface;
6 6
 use Logipro\Bundle\SCORMBundle\Crypto\Crypto;
7
-use Logipro\Bundle\SCORMBundle\Entity\Learner;
8 7
 use Logipro\Bundle\SCORMBundle\Entity\Registration;
9 8
 use Logipro\Bundle\SCORMBundle\Entity\RegistrationAttempt;
10 9
 use Logipro\Bundle\SCORMBundle\Entity\ZipFile;
@@ -33,11 +32,11 @@ class Scorm2004PlayerLogic
33 32
      * @var RouterInterface
34 33
      */
35 34
     protected $router;
36
-    
35
+
37 36
     protected $parameters;
38 37
 
39 38
     protected $em;
40
-    
39
+
41 40
     public function __construct(RouterInterface $router, ParameterBagInterface $parameters, EntityManagerInterface $em)
42 41
     {
43 42
         // Récupération des services
@@ -72,7 +71,7 @@ class Scorm2004PlayerLogic
72 71
 
73 72
         // On décrypte et désérialise les infos si fournies
74 73
         if ($data) {
75
-             // Décryptage des datas
74
+            // Décryptage des datas
76 75
             $decryptedData = Crypto::decrypt($data);
77 76
 
78 77
             // Data invalide
@@ -98,14 +97,14 @@ class Scorm2004PlayerLogic
98 97
                 return $response;
99 98
             }
100 99
         }
101
-            
100
+
102 101
 
103 102
         // Si pas de données ou pas d'organisation, cas d'une entrée dans le lecteur
104 103
         if (empty($dataArray['org'])) {
105 104
             // Récupération des différentes "Organizations"
106
-// NEED NEW DOM METHOD
105
+            // NEED NEW DOM METHOD
107 106
             // $organization = $dom->getOrganizations();
108
-            
107
+
109 108
             // Si plusieurs Orga, Affichage d'une page de sélection de l'organisation
110 109
             // if (count($organizations) {
111 110
             //     return page de choix des organization avec data pour chaque Orga
@@ -126,10 +125,10 @@ class Scorm2004PlayerLogic
126 125
                 $track = $this->createTrack($dom, $registrationKey, $attempt, $dataArray);
127 126
             }
128 127
 
129
-            
128
+
130 129
             $suspendedItem = $track->getSuspendedItemRef();
131 130
             $navigationValidator = new NavigationRequestValidator($this->parameters, $this->em, $registrationKey);
132
-            
131
+
133 132
             // Si il existe un item suspendu au niveau du track
134 133
             if ($suspendedItem) {
135 134
                 // On lance un événement 'Resume all' à partir de la racine
@@ -147,18 +146,15 @@ class Scorm2004PlayerLogic
147 146
                 } */
148 147
             } else {
149 148
                 // Aucune possibilité aux vues de l'état du system
150
-                // On propose la liste de sélection des items (item spécifique au moteur)
151
-                $track->setCurrentItemRef($track->getOrganizationId());
149
+                // On propose la liste de sélection des items - réponse spécifique
150
+                $organization = $track->getOrganizationId();
151
+                $track->setCurrentItemRef($organization);
152 152
                 $this->em->persist($track);
153 153
                 $this->em->flush();
154
-                
155
-// TODO SELECTION ITEM
156
-                // return SelectionItem;
157
-                $response = array(
158
-                    'result' => 'error',
159
-                    'error' => 'Selection SCO needed'
160
-                );
161
-    
154
+
155
+                $playerView = new Scorm2004PlayerView($this->router, $this->parameters, $this->em, $dom, $track, $registrationKey, $organization, $organization);
156
+                $response = $playerView->getSelectionResponse();
157
+
162 158
                 return $response;
163 159
             }
164 160
         }
@@ -236,11 +232,11 @@ class Scorm2004PlayerLogic
236 232
                 $objectiveInfo->setObjectiveIdentifier($global);
237 233
                 $objectiveInfo->setScorm2004Track($track);
238 234
                 $objectiveInfo->setIsPrimary(false);
239
-                
235
+
240 236
                 $this->em->persist($objectiveInfo);
241 237
             }
242 238
         }
243
-        
239
+
244 240
         $this->em->flush();
245 241
 
246 242
         // Définition des availableChildren pour chaque item (necessite que toutes les tables de mappage soit créées au préalable)
@@ -269,7 +265,7 @@ class Scorm2004PlayerLogic
269 265
         $currentItem = $data['current'];
270 266
         $navigationRequest = $data['nav'];
271 267
         $targetItem = $data['target'];
272
-            
268
+
273 269
         // Récupération du track
274 270
         $trackRepository = $this->em->getRepository(Scorm2004Track::class);
275 271
         $track = $trackRepository->findOneBy(array('registrationAttempt' => $attempt), array('track_id' => 'desc'));
@@ -337,7 +333,7 @@ class Scorm2004PlayerLogic
337 333
                     'result' => 'error',
338 334
                     'error' => $msg
339 335
                 );
340
-    
336
+
341 337
                 return $response;
342 338
             }
343 339
 
@@ -367,7 +363,7 @@ class Scorm2004PlayerLogic
367 363
                     'result' => 'error',
368 364
                     'error' => $msg
369 365
                 );
370
-    
366
+
371 367
                 return $response;
372 368
             }
373 369
 
@@ -381,7 +377,7 @@ class Scorm2004PlayerLogic
381 377
                 $response = array(
382 378
                     'result' => 'exit'
383 379
                 );
384
-    
380
+
385 381
                 return $response;
386 382
             }
387 383
 
@@ -393,13 +389,10 @@ class Scorm2004PlayerLogic
393 389
                 $this->em->persist($track);
394 390
                 $this->em->flush();
395 391
 
396
-// TODO
397
-                // Affichage du lecteur sur le Item de sélection (le Item racine)
398
-                /* $requestParamaters['action'] = do__ago_learner_space_training_reader_shared_sco;
399
-                $requestParamaters['idActivite'] = $idActivite;
400
-                $requestParamaters['node'] = $root;
401
-                $requestParamaters['isSharedSco'] = true;
402
-                return $requestParamaters; */
392
+                $playerView = new Scorm2004PlayerView($this->router, $this->parameters, $this->em, $dom, $track, $registrationKey, $organization, $organization);
393
+                $response = $playerView->getSelectionResponse();
394
+
395
+                return $response;
403 396
             }
404 397
 
405 398
             $deliveryItem = $processedSequencingRequest->getdeliveryItem();
@@ -422,7 +415,7 @@ class Scorm2004PlayerLogic
422 415
                     'result' => 'error',
423 416
                     'error' => $msg
424 417
                 );
425
-    
418
+
426 419
                 return $response;
427 420
             }
428 421
 

+ 62
- 40
Player/SCORM2004/Scorm2004PlayerView.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2
+
2 3
 namespace Logipro\Bundle\SCORMBundle\Player\SCORM2004;
3 4
 
4
-use Doctrine\Common\Persistence\ManagerRegistry;
5 5
 use Doctrine\ORM\EntityManagerInterface;
6 6
 use Logipro\Bundle\SCORMBundle\ClientAPI\ApiScorm2004;
7 7
 use Logipro\Bundle\SCORMBundle\Crypto\Crypto;
@@ -21,11 +21,11 @@ use Symfony\Component\Routing\RouterInterface;
21 21
 class Scorm2004PlayerView
22 22
 {
23 23
     protected $router;
24
-    
24
+
25 25
     protected $parameters;
26 26
 
27 27
     protected $em;
28
-    
28
+
29 29
     protected $response;
30 30
 
31 31
     protected $dom;
@@ -42,8 +42,16 @@ class Scorm2004PlayerView
42 42
 
43 43
     protected $tocValidations;
44 44
 
45
-    public function __construct(RouterInterface $router, ParameterBagInterface $parameters, EntityManagerInterface $em, DOMSCORM2004 $dom, Scorm2004Track $track, string $registrationKey, string $organization, string $item)
46
-    {
45
+    public function __construct(
46
+        RouterInterface $router,
47
+        ParameterBagInterface $parameters,
48
+        EntityManagerInterface $em,
49
+        DOMSCORM2004 $dom,
50
+        Scorm2004Track $track,
51
+        string $registrationKey,
52
+        string $organization,
53
+        string $item
54
+    ) {
47 55
         // Récupération des services
48 56
         $this->router = $router;
49 57
         $this->parameters = $parameters;
@@ -54,10 +62,10 @@ class Scorm2004PlayerView
54 62
         $this->registrationKey = $registrationKey;
55 63
         $this->organization = $organization;
56 64
         $this->item = $item;
57
-        
65
+
58 66
         $this->navUIControls = null;
59 67
         $this->tocValidations = null;
60
-        
68
+
61 69
         $this->response = array(
62 70
             'result' => 'player',
63 71
             'player' => array(
@@ -93,7 +101,21 @@ class Scorm2004PlayerView
93 101
         $this->response['player']['toc'] = $this->getToc();
94 102
         $this->response['player']['previous'] = $this->getNavigationAction(SCORM2004_HIDE_LMS_UI_PREVIOUS);
95 103
         $this->response['player']['next'] = $this->getNavigationAction(SCORM2004_HIDE_LMS_UI_CONTINUE);
96
-        
104
+
105
+        return $this->response;
106
+    }
107
+
108
+    public function getSelectionResponse()
109
+    {
110
+        $this->response['result'] = 'selection';
111
+        $this->response['player']['current'] = $this->getCurrent();
112
+        $this->response['player']['toc'] = $this->getToc();
113
+        $this->response['player']['previous'] = $this->getNavigationAction(SCORM2004_HIDE_LMS_UI_PREVIOUS);
114
+        $this->response['player']['next'] = $this->getNavigationAction(SCORM2004_HIDE_LMS_UI_CONTINUE);
115
+        $this->response['player']['exit'] = $this->getNavigationAction(SCORM2004_HIDE_LMS_UI_EXIT);
116
+        $this->response['player']['content'] = null;
117
+        $this->response['api'] = null;
118
+
97 119
         return $this->response;
98 120
     }
99 121
 
@@ -105,39 +127,39 @@ class Scorm2004PlayerView
105 127
         // init des états
106 128
         $this->navUIControls = array(
107 129
             SCORM2004_HIDE_LMS_UI_PREVIOUS => array(
108
-                    'visible' => true,
109
-                    'enable' => true,
110
-                    'nav'=> NavigationRequest::NAVIGATION_PREVIOUS
130
+                'visible' => true,
131
+                'enable' => true,
132
+                'nav' => NavigationRequest::NAVIGATION_PREVIOUS
111 133
             ),
112 134
             SCORM2004_HIDE_LMS_UI_CONTINUE => array(
113
-                    'visible' => true,
114
-                    'enable' => true,
115
-                    'nav'=> NavigationRequest::NAVIGATION_CONTINUE
135
+                'visible' => true,
136
+                'enable' => true,
137
+                'nav' => NavigationRequest::NAVIGATION_CONTINUE
116 138
             ),
117 139
             SCORM2004_HIDE_LMS_UI_EXIT => array(
118
-                    'visible' => true,
119
-                    'enable' => true,
120
-                    'nav'=> NavigationRequest::NAVIGATION_EXIT
140
+                'visible' => true,
141
+                'enable' => true,
142
+                'nav' => NavigationRequest::NAVIGATION_EXIT
121 143
             ),
122 144
             SCORM2004_HIDE_LMS_UI_EXIT_ALL => array(
123
-                    'visible' => true,
124
-                    'enable' => true,
125
-                    'nav'=> NavigationRequest::NAVIGATION_EXIT_ALL
145
+                'visible' => true,
146
+                'enable' => true,
147
+                'nav' => NavigationRequest::NAVIGATION_EXIT_ALL
126 148
             ),
127 149
             SCORM2004_HIDE_LMS_UI_ABANDON => array(
128
-                    'visible' => true,
129
-                    'enable' => true,
130
-                    'nav'=> NavigationRequest::NAVIGATION_ABANDON
150
+                'visible' => true,
151
+                'enable' => true,
152
+                'nav' => NavigationRequest::NAVIGATION_ABANDON
131 153
             ),
132 154
             SCORM2004_HIDE_LMS_UI_ABANDON_ALL => array(
133
-                    'visible' => true,
134
-                    'enable' => true,
135
-                    'nav'=> NavigationRequest::NAVIGATION_ABANDON_ALL
155
+                'visible' => true,
156
+                'enable' => true,
157
+                'nav' => NavigationRequest::NAVIGATION_ABANDON_ALL
136 158
             ),
137 159
             SCORM2004_HIDE_LMS_UI_SUSPEND_ALL => array(
138
-                    'visible' => true,
139
-                    'enable' => true,
140
-                    'nav'=> NavigationRequest::NAVIGATION_SUSPEND_ALL
160
+                'visible' => true,
161
+                'enable' => true,
162
+                'nav' => NavigationRequest::NAVIGATION_SUSPEND_ALL
141 163
             )
142 164
         );
143 165
 
@@ -153,13 +175,13 @@ class Scorm2004PlayerView
153 175
         $this->navUIControls[SCORM2004_HIDE_LMS_UI_CONTINUE]['enable'] = $navigationRequestValidator->checkContinueValidity($this->item);
154 176
     }
155 177
 
156
-     /**
178
+    /**
157 179
      * Retourne l'ensemble des données necessaires pour l'affichage des infos du noeud courant
158 180
      */
159 181
     protected function getCurrent()
160 182
     {
161 183
         $response = array();
162
-            
184
+
163 185
         // Nom de l'activité
164 186
         $response['activity'] = $this->dom->getTitle($this->organization);
165 187
         // Nom de l'item
@@ -176,9 +198,9 @@ class Scorm2004PlayerView
176 198
         // Récupération de l'état des plannodes pour une requete de type 'choice' en fonction de l'état du system
177 199
         $navigationRequestValidator = new NavigationRequestValidator($this->parameters, $this->em, $this->registrationKey);
178 200
         $this->tocValidations = $navigationRequestValidator->defineTableOfContent($this->item);
179
-        
201
+
180 202
         $response = array();
181
-        
203
+
182 204
         // Récupération des enfants disponibles
183 205
         $children = $this->dom->getChildren($this->organization);
184 206
 
@@ -193,7 +215,7 @@ class Scorm2004PlayerView
193 215
                 }
194 216
             }
195 217
         }
196
-        
218
+
197 219
         return $response;
198 220
     }
199 221
 
@@ -205,13 +227,13 @@ class Scorm2004PlayerView
205 227
         // si l'item est visible
206 228
         if ($isVisible) {
207 229
             $response = array();
208
-            
230
+
209 231
             // Nom du noeud
210 232
             $response['name'] = $this->dom->getTitle($item);
211 233
             $response['current'] = $validations['is-Active'];
212 234
             $response['state'] = $validations['state'];
213 235
             $response['enable'] = $validations['enable'];
214
-            
236
+
215 237
             // Enable/Disable
216 238
             $data = null;
217 239
             if ($validations['enable']) {
@@ -222,7 +244,7 @@ class Scorm2004PlayerView
222 244
                     'nav' => NavigationRequest::NAVIGATION_CHOICE,
223 245
                     'target' => $item
224 246
                 );
225
-        
247
+
226 248
                 $serialize = \serialize($dataArray);
227 249
                 $data = Crypto::crypt($serialize);
228 250
             }
@@ -287,7 +309,7 @@ class Scorm2004PlayerView
287 309
     protected function getNavigationAction(string $action)
288 310
     {
289 311
         $information = $this->navUIControls[$action];
290
-        
312
+
291 313
         $dataArray = array(
292 314
             'regKey' => $this->registrationKey,
293 315
             'org' => $this->organization,
@@ -311,7 +333,7 @@ class Scorm2004PlayerView
311 333
     /**
312 334
      * Retourne les données necessaires pour l'affichage du contenu
313 335
      */
314
-    protected function getContent() : string
336
+    protected function getContent(): string
315 337
     {
316 338
         // Récupérer l'url de la ressource liée à l'item
317 339
         $href = $this->dom->getHref($this->item);
@@ -322,7 +344,7 @@ class Scorm2004PlayerView
322 344
     /**
323 345
      * Retourne l'API SCORM2004 paramétrée pour l'item courant
324 346
      */
325
-    protected function getApi() : string
347
+    protected function getApi(): string
326 348
     {
327 349
         $apiScorm2004 = new ApiScorm2004($this->router, $this->parameters, $this->em);
328 350
         $api = $apiScorm2004->getAPI($this->dom, $this->registrationKey, $this->organization, $this->item);

+ 1
- 5
Services/ScormEngine.php View File

@@ -1,7 +1,6 @@
1 1
 <?php
2 2
 namespace Logipro\Bundle\SCORMBundle\Services;
3 3
 
4
-use Doctrine\Common\Persistence\ManagerRegistry;
5 4
 use Doctrine\ORM\EntityManagerInterface;
6 5
 use Logipro\Bundle\SCORMBundle\Entity\Course;
7 6
 use Logipro\Bundle\SCORMBundle\Entity\Learner;
@@ -15,13 +14,10 @@ use Logipro\Bundle\SCORMBundle\Entity\Scorm2004\Scorm2004AttemptProgressInformat
15 14
 use Logipro\Bundle\SCORMBundle\Entity\Scorm2004\Scorm2004Interaction;
16 15
 use Logipro\Bundle\SCORMBundle\LearningModels\DOMSCORM12;
17 16
 use Logipro\Bundle\SCORMBundle\LearningModels\DOMSCORM2004;
18
-use Logipro\Bundle\SCORMBundle\Package\Common\PackageTypeDetector;
19 17
 use Logipro\Bundle\SCORMBundle\Player\SCORM2004\Scorm2004PlayerLogic;
20 18
 use Logipro\Bundle\SCORMBundle\Package\PackageValidator;
21 19
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
22
-use Symfony\Component\DependencyInjection\Reference;
23 20
 use Symfony\Component\HttpFoundation\Cookie;
24
-use Symfony\Component\HttpFoundation\Request;
25 21
 use Symfony\Component\HttpFoundation\Response;
26 22
 use Symfony\Component\HttpFoundation\Session\SessionInterface;
27 23
 use Symfony\Component\Routing\RouterInterface;
@@ -493,7 +489,7 @@ class ScormEngine
493 489
     /**
494 490
      * retourne la règle de versionnig
495 491
      */
496
-    public function getCourseVersionRule()
492
+    public function getCourseVersionRule(string $courseKey)
497 493
     {
498 494
         $course = $this->requireCourse($courseKey);
499 495
 

Loading…
Cancel
Save