ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjSCORMValidator.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
15{
16 public $dir;
17 public $flag;
18 public $summary;
19
20 public function validateXML($file)
21 {
22 // exec(ilUtil::getJavaPath()." -jar ".ilUtil::escapeShellArg(ILIAS_ABSOLUTE_PATH."/Modules/ScormAicc/validation/vali.jar")." ".ilUtil::escapeShellArg($file)." 2>&1", $error);
23 // if (count($error) != 0)
24 // {
25 // $this->summary[] = "";
26 // $this->summary[] = "<b>File: $file</b>";
27 // foreach($error as $line)
28 // {
29 // $this->summary[] = $line;
30// //echo "<br><b>".$line."</b>";
31 // }
32 // }
33 }
34
35 public function searchDir($dir)
36 {
37 if (is_dir($dir)) {
38 if ($dh = opendir($dir)) {
39 while (($file = readdir($dh)) !== false) {
40 if (!preg_match("~^[\.]{1,2}~i", $file)) {
41 //2DO FIXME regex machen dass nur . und .. erkannt werden und nicht .lala. oder so
42 if (is_dir($dir . $file)) {
43 // This is commented because subdirecories of my scromexamples contain xml files which aren't valid!
44 //$this->searchDir($dir.$file."/");
45 }
46 if (preg_match("~(\.xml)$~i", $file)) {
47
48 // we skip index.xml and indexMD.xml which come from the
49 // scorm editor and currently do not validate against anything
50 if ($file != "index.xml" && $file != "indexMD.xml") {
51 $this->validateXML($dir . $file);
52 }
53 }
54 }
55 }
56 }
57 closedir($dh);
58 }
59 }
60
61 public function __construct($directory)
62 {
63 $this->dir = $directory . '/';
64 }
65
66 public function validate()
67 {
68 $this->summary = array();
69 $this->searchDir($this->dir);
70 if (count($this->summary) == 0) {
71 return true;
72 } else {
73 return false;
74 }
75 }
76
77 public function getSummary()
78 {
79 $summary = "";
80
81 foreach ($this->summary as $line) {
82 $summary .= $line . "<br>";
83 }
84
85 return $summary;
86 }
87}
An exception for terminatinating execution or to throw for unit testing.
Validation of SCORM-XML Files.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file