ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSCORMValidator.php
Go to the documentation of this file.
1 <?php
2  /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22  */
23 
24 
35 
36  function validateXML($file)
37  {
38  exec(ilUtil::getJavaPath()." -jar ".ilUtil::escapeShellArg(ILIAS_ABSOLUTE_PATH."/Modules/ScormAicc/validation/vali.jar")." ".ilUtil::escapeShellArg($file)." 2>&1", $error);
39  if (count($error) != 0)
40  {
41  $this->summary[] = "";
42  $this->summary[] = "<b>File: $file</b>";
43  foreach($error as $line)
44  {
45  $this->summary[] = $line;
46 //echo "<br><b>".$line."</b>";
47  }
48  }
49  }
50 
51  function searchDir($dir) {
52  if (is_dir($dir)) {
53  if ($dh = opendir($dir)) {
54  while (($file = readdir($dh)) !== false) {
55  if (!eregi("^[\.]{1,2}",$file)) {
56  //2DO FIXME regex machen dass nur . und .. erkannt werden und nicht .lala. oder so
57  if (is_dir($dir.$file)) {
58  // This is commented because subdirecories of my scromexamples contain xml files which aren't valid!
59  //$this->searchDir($dir.$file."/");
60  }
61  if (eregi("(\.xml)$",$file)) {
62  $this->validateXML($dir.$file);
63  }
64  }
65  }
66  }
67  closedir($dh);
68  }
69  }
70 
71  function ilObjSCORMValidator($directory) {
72  $this->dir = $directory.'/';
73  }
74 
75  function validate()
76  {
77  $this->summary = array();
78  $this->searchDir($this->dir);
79  if(count($this->summary) == 0)
80  {
81  return true;
82  }
83  else
84  {
85  return false;
86  }
87  }
88 
89  function getSummary()
90  {
91  $summary = "";
92 
93  foreach ($this->summary as $line)
94  {
95  $summary .= $line."<br>";
96  }
97 
98  return $summary;
99  }
100 }
101 
102 ?>