ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
16
18 {
19 exec(ilUtil::getJavaPath()." -jar ".ilUtil::escapeShellArg(ILIAS_ABSOLUTE_PATH."/Modules/ScormAicc/validation/vali.jar")." ".ilUtil::escapeShellArg($file)." 2>&1", $error);
20 if (count($error) != 0)
21 {
22 $this->summary[] = "";
23 $this->summary[] = "<b>File: $file</b>";
24 foreach($error as $line)
25 {
26 $this->summary[] = $line;
27//echo "<br><b>".$line."</b>";
28 }
29 }
30 }
31
32 function searchDir($dir) {
33 if (is_dir($dir)) {
34 if ($dh = opendir($dir)) {
35 while (($file = readdir($dh)) !== false) {
36 if (!eregi("^[\.]{1,2}",$file)) {
37 //2DO FIXME regex machen dass nur . und .. erkannt werden und nicht .lala. oder so
38 if (is_dir($dir.$file)) {
39 // This is commented because subdirecories of my scromexamples contain xml files which aren't valid!
40 //$this->searchDir($dir.$file."/");
41 }
42 if (eregi("(\.xml)$",$file)) {
43
44 // we skip index.xml and indexMD.xml which come from the
45 // scorm editor and currently do not validate against anything
46 if ($file != "index.xml" && $file != "indexMD.xml")
47 {
48 $this->validateXML($dir.$file);
49 }
50 }
51 }
52 }
53 }
54 closedir($dh);
55 }
56 }
57
58 function ilObjSCORMValidator($directory) {
59 $this->dir = $directory.'/';
60 }
61
62 function validate()
63 {
64 $this->summary = array();
65 $this->searchDir($this->dir);
66 if(count($this->summary) == 0)
67 {
68 return true;
69 }
70 else
71 {
72 return false;
73 }
74 }
75
76 function getSummary()
77 {
78 $summary = "";
79
80 foreach ($this->summary as $line)
81 {
82 $summary .= $line."<br>";
83 }
84
85 return $summary;
86 }
87}
88
89?>
print $file
Validation of SCORM-XML Files.
static getJavaPath()
get full java path (dir + java command)
static escapeShellArg($a_arg)
const ILIAS_ABSOLUTE_PATH