Browse Source

Modification concernant la définition du standard

Mael ETIENNE 3 years ago
parent
commit
98a8566121

+ 9
- 8
LearningModels/DOMLearningModel.php View File

@@ -24,34 +24,35 @@ class DOMLearningModel
24 24
     /**
25 25
      * récupère le DOM représentant un package
26 26
      *
27
+     * @param string $key
27 28
      * @param string $XMLManifest
29
+     * @param string $standard
30
+     *
28 31
      * @return DOMSCORM
29 32
      */
30
-    final public static function getInstance(string $key, string $manifest = null) : DOMSCORM
33
+    final public static function getInstance(string $key, string $manifest = null, string $standard = DOMSCORM2004::SCORM_2004) : ?\DOMSCORM
31 34
     {
32 35
         if (isset($DOMs[$key])) {
33 36
             return self::$DOMs[$key];
34 37
         }
35 38
 
36 39
         if (isset($manifest)) {
37
-            return self::setDOM($key, $manifest);
40
+            return self::setDOM($key, $manifest, $standard);
38 41
         }
39 42
 
40 43
         return null;
41 44
     }
42 45
 
43
-    public static function setDOM(string $key, string $XMLManifest) : DOMSCORM
46
+    public static function setDOM(string $key, string $XMLManifest, string $standard) : ?\DOMSCORM
44 47
     {
45 48
         $dom = null;
46
-        
47
-        // On définit le standard
48
-        $standard = DOMSCORM::getStandard($XMLManifest);
49
+
49 50
         switch ($standard) {
50
-            case DOMSCORM::SCORM2004:
51
+            case DOMSCORM2004::SCORM2004:
51 52
                 $dom = new DOMSCORM2004($XMLManifest);
52 53
                 break;
53 54
 
54
-            case DOMSCORM::SCORM12:
55
+            case DOMSCORM12::SCORM12:
55 56
                 $dom = null;
56 57
                 break;
57 58
                 

+ 4
- 7
LearningModels/DOMSCORM.php View File

@@ -7,9 +7,7 @@ namespace Logipro\Bundle\SCORMBundle\LearningModels;
7 7
  */
8 8
 abstract class DOMSCORM implements DOMPackageInterface
9 9
 {
10
-    const SCORM_12 = 'SCORM_12';
11
-    const SCORM_2004 = 'SCORM_2004';
12
-    
10
+
13 11
     /**
14 12
      * le manifest au format DOM
15 13
      *
@@ -88,9 +86,8 @@ abstract class DOMSCORM implements DOMPackageInterface
88 86
      *
89 87
      * @return string
90 88
      */
91
-    public function getStandard()
89
+    abstract public function getStandard()
92 90
     {
93
-        return false;
94 91
     }
95 92
 
96 93
     /**
@@ -135,12 +132,12 @@ abstract class DOMSCORM implements DOMPackageInterface
135 132
             case 'CAM 1.3': //2004 2nd Edition (WTF ADL??)
136 133
             case '2004 3rd Edition':
137 134
             case '2004 4th Edition':
138
-                $standard = self::SCORM_2004;
135
+                $standard = DOMSCORM2004::SCORM_2004;
139 136
                 break;
140 137
                 
141 138
             case '1.2':
142 139
             default:
143
-                $standard = self::SCORM_12;
140
+                $standard = DOMSCORM12::SCORM_12;
144 141
         }
145 142
         
146 143
         return $standard;

+ 1
- 1
LearningModels/DOMSCORM12.php View File

@@ -4,5 +4,5 @@ namespace Logipro\Bundle\SCORMBundle\LearningModels;
4 4
 
5 5
 class DOMSCORM12 extends DOMSCORM
6 6
 {
7
-
7
+    const SCORM_12 = 'SCORM_12';
8 8
 }

+ 2
- 1
LearningModels/DOMSCORM2004.php View File

@@ -6,6 +6,7 @@ use PHPUnit\Runner\Exception;
6 6
 
7 7
 class DOMSCORM2004 extends DOMSCORM
8 8
 {
9
+    const SCORM_2004 = 'SCORM_2004';
9 10
 
10 11
     /**
11 12
      *  *
@@ -956,6 +957,6 @@ class DOMSCORM2004 extends DOMSCORM
956 957
      */
957 958
     public function getStandard()
958 959
     {
959
-        return DOMSCORM::SCORM_2004;
960
+        return self::SCORM_2004;
960 961
     }
961 962
 }

+ 3
- 2
Package/PackageValidator.php View File

@@ -39,7 +39,8 @@ class PackageValidator
39 39
 
40 40
         if ($manifest !== false) {
41 41
             // SCORM
42
-            $dom = DOMLearningModel::getInstance($zipName, $manifest);
42
+            $standard = DOMSCORM::defineStandard($manifest);
43
+            $dom = DOMLearningModel::getInstance($zipName, $manifest, $standard);
43 44
         } else {
44 45
             // Si pas de imsmanifest.xml --> possible autre standard
45 46
             return null;
@@ -47,7 +48,7 @@ class PackageValidator
47 48
 
48 49
         // Si standard identifié, on peut passé à la validation du xml
49 50
         if ($dom) {
50
-            $response['standard'] = $dom->getStandard();
51
+            $response['standard'] = $standard;
51 52
             $response['title'] = $dom->getTitle();
52 53
 
53 54
 // @TODO Validation XML reportée

Loading…
Cancel
Save