ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjAICCCourseInterchangeFiles Class Reference
+ Collaboration diagram for ilObjAICCCourseInterchangeFiles:

Public Member Functions

 ilObjAICCCourseInterchangeFiles ()
 
 findFiles ($dir)
 
 readFiles ()
 
 getDescriptor ($system_id)
 
 validate ()
 
 checkRequiredKeys ()
 
 checkCourseFile ($fileSuffix, $data, $requiredKeys, $group=0)
 
 checkColumnCount ($fileSuffix, $data)
 
 checkStructure ()
 
 readCRS ($filename)
 
 readCSVFile ($filename)
 
 getAllFiles ($dir, $arr=array())
 
 arraykeys_tolower ($arr)
 
 writeToDatabase ($alm_id)
 

Data Fields

 $coursefiles
 
 $data
 
 $errorText
 
 $requiredFiles =array("crs", "au", "cst", "des")
 
 $optionalFiles =array("cmp", "ort", "pre")
 

Detailed Description

Definition at line 27 of file class.ilObjAICCCourseInterchangeFiles.php.

Member Function Documentation

◆ arraykeys_tolower()

ilObjAICCCourseInterchangeFiles::arraykeys_tolower (   $arr)

Definition at line 230 of file class.ilObjAICCCourseInterchangeFiles.php.

230 {
231 $arr=array_change_key_case($arr, CASE_LOWER);
232 foreach ($arr as $k=>$v) {
233 if (is_array($v))
234 $arr[$k]=$this->arraykeys_tolower($v);
235 }
236 return $arr;
237 }

References arraykeys_tolower().

Referenced by arraykeys_tolower(), and readFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkColumnCount()

ilObjAICCCourseInterchangeFiles::checkColumnCount (   $fileSuffix,
  $data 
)

Definition at line 137 of file class.ilObjAICCCourseInterchangeFiles.php.

137 {
138 if (count($data)>0) {
139 $colcount=-1;
140 for ($colnr=0;$colnr<count($data);$colnr++) {
141 if ($colcount==-1)
142 $colcount=count($data[$colnr]);
143 else if ($colcount!=count($data[$colnr]))
144 $this->errorText[]=strtoupper($fileSuffix)."-File: unexpected number of columns in line ".($colnr+2);
145 }
146 }
147 }

References $data.

Referenced by checkRequiredKeys().

+ Here is the caller graph for this function:

◆ checkCourseFile()

ilObjAICCCourseInterchangeFiles::checkCourseFile (   $fileSuffix,
  $data,
  $requiredKeys,
  $group = 0 
)

Definition at line 117 of file class.ilObjAICCCourseInterchangeFiles.php.

117 {
118
119 if (count($data)>0 && is_array($data[$group])) {
120
121 $keys=array_keys($data[$group]);
122
123 $missingKeys = array_diff ($requiredKeys, $keys);
124 $optionalKeys = array_diff ($keys, $requiredKeys);
125
126 if (count($missingKeys)>0)
127 $this->errorText[]="missing keys in ".strtoupper($fileSuffix)."-File: ".implode(",", $missingKeys);
128
129 } else if (count($data)>0 && !is_array($data[$group])) {
130 $this->errorText[]="missing Group in ".strtoupper($fileSuffix)."-File: $group";
131 } else {
132 $this->errorText[]="empty ".strtoupper($fileSuffix)."-File";
133 }
134
135 }

References $data.

Referenced by checkRequiredKeys().

+ Here is the caller graph for this function:

◆ checkRequiredKeys()

ilObjAICCCourseInterchangeFiles::checkRequiredKeys ( )

Definition at line 88 of file class.ilObjAICCCourseInterchangeFiles.php.

88 {
89 //AU
90 $requiredKeys=array("system_id", "type", "command_line", "file_name",
91 "max_score", "mastery_score", "max_time_allowed",
92 "time_limit_action", "system_vendor", "core_vendor",
93 "web_launch", "au_password");
94 $this->checkCourseFile("au", $this->data["au"], $requiredKeys);
95 $this->checkColumnCount("au", $this->data["au"]);
96
97 //DES
98 $requiredKeys=array("system_id", "title", "description", "developer_id");
99 $this->checkCourseFile("des", $this->data["des"], $requiredKeys);
100 $this->checkColumnCount("des", $this->data["des"]);
101
102 //CRS
103 $requiredKeys=array("course_creator", "course_id", "course_system", "course_title",
104 "level", "max_fields_cst", "total_aus", "total_blocks", "version");
105 $this->checkCourseFile("crs", $this->data["crs"], $requiredKeys, "course");
106 $requiredKeys=array("max_normal");
107 $this->checkCourseFile("crs", $this->data["crs"], $requiredKeys, "course_behavior");
108
109 //CST
110 $requiredKeys=array("block", "member");
111 $this->checkCourseFile("cst", $this->data["cst"], $requiredKeys,0);
112 $this->checkColumnCount("cst", $this->data["cst"]);
113
114 return $errorText;
115 }
checkCourseFile($fileSuffix, $data, $requiredKeys, $group=0)

References $errorText, checkColumnCount(), and checkCourseFile().

Referenced by validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkStructure()

ilObjAICCCourseInterchangeFiles::checkStructure ( )

Definition at line 149 of file class.ilObjAICCCourseInterchangeFiles.php.

149 {
150
151 //max member fields in cst-file
152 $max=$this->data[crs][course][max_fields_cst];
153 for ($row=0;$row<count($this->data[cst]);$row++) {
154 $value=$this->data[cst][$row][member];
155 if ((is_array($value) && count($value)>$max) || (!is_array($value) && $max==1)) {
156 $this->errorText[]="CRS-File: max_fields_cst does not match number of fields in the CST-File";
157 return;
158 }
159 }
160
161 //additional validation statements
162 //
163 //
164
165 }

References $row.

Referenced by validate().

+ Here is the caller graph for this function:

◆ findFiles()

ilObjAICCCourseInterchangeFiles::findFiles (   $dir)

Definition at line 44 of file class.ilObjAICCCourseInterchangeFiles.php.

44 {
45 $suffixes=array_merge($this->requiredFiles,$this->optionalFiles);
46 $files=$this->getAllFiles($dir);
47 foreach ($files as $file) {
48 foreach($suffixes as $suffix) {
49 if (strcasecmp(substr($file, -(strlen($suffix)+1)), ".".$suffix)==0)
50 $this->coursefiles[$suffix] = $file;
51 }
52 }
53
54 //check for required files
55 $missingFiles = array_diff ($this->requiredFiles, array_keys($this->coursefiles));
56 if (count($missingFiles)==4)
57 $this->errorText[]="Missing all required files.<br>You want to check if your learning module is of a different type.";
58 else if (count($missingFiles)>0)
59 $this->errorText[]="Missing required file(s): ".implode("<bR>", $missingFiles);
60 }
print $file

References $file, and getAllFiles().

+ Here is the call graph for this function:

◆ getAllFiles()

ilObjAICCCourseInterchangeFiles::getAllFiles (   $dir,
  $arr = array() 
)

Definition at line 213 of file class.ilObjAICCCourseInterchangeFiles.php.

213 {
214 if (substr($dir, -1)!="/")
215 $dir.="/";
216
217 $handle=opendir($dir);
218 while ($file = readdir ($handle)) {
219 if ($file != "." && $file != "..") {
220 if (is_dir($dir.$file))
221 $arr=$this->getAllFiles($dir.$file, $arr);
222 else
223 $arr[]=$dir.$file;
224 }
225 }
226 closedir($handle);
227 return $arr;
228 }

References $file, and getAllFiles().

Referenced by findFiles(), and getAllFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescriptor()

ilObjAICCCourseInterchangeFiles::getDescriptor (   $system_id)

Definition at line 76 of file class.ilObjAICCCourseInterchangeFiles.php.

76 {
77 foreach ($this->data["des"] as $row) {
78 if (strcasecmp ($row["system_id"],$system_id)==0)
79 return $row;
80 }
81 }

References $row.

Referenced by writeToDatabase().

+ Here is the caller graph for this function:

◆ ilObjAICCCourseInterchangeFiles()

ilObjAICCCourseInterchangeFiles::ilObjAICCCourseInterchangeFiles ( )

Definition at line 35 of file class.ilObjAICCCourseInterchangeFiles.php.

35 {
36 $this->errorText=array();
37 $this->coursefiles=array();
38
39 }

◆ readCRS()

ilObjAICCCourseInterchangeFiles::readCRS (   $filename)

Definition at line 168 of file class.ilObjAICCCourseInterchangeFiles.php.

168 {
169 $data=@parse_ini_file($filename, TRUE);
170
171 //crs-file is not a valid iniFile
172 //thats why reading the file again to get course_description
173 $lines=file($filename);
174 for($i=0;$i<count($lines);$i++) {
175 if (trim($lines[$i])=="[Course_Description]") {
176 for ($i++;$i<count($lines);$i++) {
177 if (strlen(trim($lines[$i]))>0) {
178 $data["Course_Description"][description]=$lines[$i];
179 break;
180 }
181 }
182 }
183 }
184
185 return $data;
186 }
$filename
Definition: buildRTE.php:89

References $data, and $filename.

Referenced by readFiles().

+ Here is the caller graph for this function:

◆ readCSVFile()

ilObjAICCCourseInterchangeFiles::readCSVFile (   $filename)

Definition at line 188 of file class.ilObjAICCCourseInterchangeFiles.php.

188 {
189 $row=1;
190 $handle = fopen($filename, "r");
191 while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
192 if ($row++==1) {
194 } else if (count($data)>1) {
195 $data2=array();
196 for ($col=0; $col<count($data); $col++) {
197 if (array_key_exists($header[$col], $data2)) {
198 $value=$data2[$header[$col]];
199 if (!is_array($value))
200 $data2[$header[$col]]=array($value, utf8_encode($data[$col]));
201 else
202 $data2[$header[$col]][]=utf8_encode($data[$col]);
203 } else
204 $data2[$header[$col]]=utf8_encode($data[$col]);
205 }
206 $rows[]=$data2;
207 }
208 }
209 fclose($handle);
210 return $rows;
211 }
$header

References $data, $filename, $header, and $row.

Referenced by readFiles().

+ Here is the caller graph for this function:

◆ readFiles()

ilObjAICCCourseInterchangeFiles::readFiles ( )

Definition at line 62 of file class.ilObjAICCCourseInterchangeFiles.php.

62 {
63 $this->data=array();
64
65 foreach ($this->coursefiles as $suffix=>$filename) {
66 if ($suffix=="crs")
67 $this->data[$suffix]=$this->readCRS($filename);
68 else
69 $this->data[$suffix]=$this->readCSVFile($filename);
70 }
71
72 //Prepare Data-Array: all keys to lower
73 $this->data=$this->arraykeys_tolower($this->data);
74 }

References $filename, arraykeys_tolower(), readCRS(), and readCSVFile().

+ Here is the call graph for this function:

◆ validate()

ilObjAICCCourseInterchangeFiles::validate ( )

◆ writeToDatabase()

ilObjAICCCourseInterchangeFiles::writeToDatabase (   $alm_id)

Definition at line 239 of file class.ilObjAICCCourseInterchangeFiles.php.

239 {
240 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCTree.php");
241 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCCourse.php");
242 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
243 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCBlock.php");
244
245 //write course to database
246 $course=new ilAICCCourse();
247 $course->setALMId($alm_id);
248 $course->setSystemId("root");
249 $course->setTitle($this->data["crs"]["course"]["course_title"]);
250 $course->setDescription($this->data["crs"]["course_description"]["description"]);
251
252 $course->setCourseCreator($this->data["crs"]["course"]["course_creator"]);
253 $course->setCourseId($this->data["crs"]["course"]["course_id"]);
254 $course->setCourseSystem($this->data["crs"]["course"]["course_system"]);
255 $course->setCourseTitle($this->data["crs"]["course"]["course_title"]);
256 $course->setLevel($this->data["crs"]["course"]["level"]);
257 $course->setMaxFieldsCst($this->data["crs"]["course"]["max_fields_cst"]);
258 $course->setMaxFieldsOrt($this->data["crs"]["course"]["max_fields_ort"]);
259 $course->setTotalAUs($this->data["crs"]["course"]["total_aus"]);
260 $course->setTotalBlocks($this->data["crs"]["course"]["total_blocks"]);
261 $course->setTotalComplexObj($this->data["crs"]["course"]["total_complex_obj"]);
262 $course->setTotalObjectives($this->data["crs"]["course"]["total_objectives"]);
263 $course->setVersion($this->data["crs"]["course"]["version"]);
264 $course->setMaxNormal($this->data["crs"]["course_behavior"]["max_normal"]);
265 $course->setDescription($this->data["crs"]["course_description"]["description"]);
266 $course->create();
267 $identifier["root"]=$course->getId();
268
269 //all blocks
270 foreach ($this->data["cst"] as $row) {
271 $system_id=strtolower($row["block"]);
272 if ($system_id!="root") {
273 $unit=new ilAICCBlock();
274 $description=$this->getDescriptor($system_id);
275 $unit->setALMId($alm_id);
276 $unit->setType("sbl");
277 $unit->setTitle($description["title"]);
278 $unit->setDescription($description["description"]);
279 $unit->setDeveloperId($description["developer_id"]);
280 $unit->setSystemId($description["system_id"]);
281 $unit->create();
282 $identifier[$system_id]=$unit->getId();
283 }
284 }
285
286 //write assignable units to database
287 foreach ($this->data["au"] as $row) {
288 $sysid=strtolower($row["system_id"]);
289 $unit=new ilAICCUnit();
290
291 $unit->setAUType($row["c_type"]);
292 $unit->setCommand_line($row["command_line"]);
293 $unit->setMaxTimeAllowed($row["max_time_allowed"]);
294 $unit->setTimeLimitAction($row["time_limit_action"]);
295 $unit->setMaxScore($row["max_score"]);
296 $unit->setCoreVendor($row["core_vendor"]);
297 $unit->setSystemVendor($row["system_vendor"]);
298 $unit->setFilename($row["file_name"]);
299 $unit->setMasteryScore($row["mastery_score"]);
300 $unit->setWebLaunch($row["web_launch"]);
301 $unit->setAUPassword($row["au_password"]);
302
303 $description=$this->getDescriptor($sysid);
304 $unit->setALMId($alm_id);
305 $unit->setType("sau");
306 $unit->setTitle($description["title"]);
307 $unit->setDescription($description["description"]);
308 $unit->setDeveloperId($description["developer_id"]);
309 $unit->setSystemId($description["system_id"]);
310 $unit->create();
311 $identifier[$sysid]=$unit->getId();
312 }
313
314 //write tree
315 $tree =& new ilAICCTree($alm_id);
316 $tree->addTree($alm_id, $identifier["root"]);
317
318 //writing members
319 foreach ($this->data["cst"] as $row) {
320 $members=$row["member"];
321 if (!is_array($members))
322 $members=array($members);
323 $parentid=$identifier[strtolower($row["block"])];
324
325 foreach($members as $member) {
326 $memberid=$identifier[strtolower($member)];
327 $tree->insertNode($memberid, $parentid);
328 }
329 }
330 }
AICC Object Tree.

References $row, and getDescriptor().

+ Here is the call graph for this function:

Field Documentation

◆ $coursefiles

ilObjAICCCourseInterchangeFiles::$coursefiles

Definition at line 29 of file class.ilObjAICCCourseInterchangeFiles.php.

◆ $data

ilObjAICCCourseInterchangeFiles::$data

◆ $errorText

ilObjAICCCourseInterchangeFiles::$errorText

Definition at line 31 of file class.ilObjAICCCourseInterchangeFiles.php.

Referenced by checkRequiredKeys().

◆ $optionalFiles

ilObjAICCCourseInterchangeFiles::$optionalFiles =array("cmp", "ort", "pre")

Definition at line 33 of file class.ilObjAICCCourseInterchangeFiles.php.

◆ $requiredFiles

ilObjAICCCourseInterchangeFiles::$requiredFiles =array("crs", "au", "cst", "des")

Definition at line 32 of file class.ilObjAICCCourseInterchangeFiles.php.


The documentation for this class was generated from the following file: