ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

ilObjAICCCourseInterchangeFiles::arraykeys_tolower (   $arr)

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

Referenced by readFiles().

{
$arr=array_change_key_case($arr, CASE_LOWER);
foreach ($arr as $k=>$v) {
if (is_array($v))
$arr[$k]=$this->arraykeys_tolower($v);
}
return $arr;
}

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::checkColumnCount (   $fileSuffix,
  $data 
)

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

References $data.

Referenced by checkRequiredKeys().

{
if (count($data)>0) {
$colcount=-1;
for ($colnr=0;$colnr<count($data);$colnr++) {
if ($colcount==-1)
$colcount=count($data[$colnr]);
else if ($colcount!=count($data[$colnr]))
$this->errorText[]=strtoupper($fileSuffix)."-File: unexpected number of columns in line ".($colnr+2);
}
}
}

+ Here is the caller graph for this function:

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

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

References $data.

Referenced by checkRequiredKeys().

{
if (count($data)>0 && is_array($data[$group])) {
$keys=array_keys($data[$group]);
$missingKeys = array_diff ($requiredKeys, $keys);
$optionalKeys = array_diff ($keys, $requiredKeys);
if (count($missingKeys)>0)
$this->errorText[]="missing keys in ".strtoupper($fileSuffix)."-File: ".implode(",", $missingKeys);
} else if (count($data)>0 && !is_array($data[$group])) {
$this->errorText[]="missing Group in ".strtoupper($fileSuffix)."-File: $group";
} else {
$this->errorText[]="empty ".strtoupper($fileSuffix)."-File";
}
}

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::checkRequiredKeys ( )

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

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

Referenced by validate().

{
//AU
$requiredKeys=array("system_id", "type", "command_line", "file_name",
"max_score", "mastery_score", "max_time_allowed",
"time_limit_action", "system_vendor", "core_vendor",
"web_launch", "au_password");
$this->checkCourseFile("au", $this->data["au"], $requiredKeys);
$this->checkColumnCount("au", $this->data["au"]);
//DES
$requiredKeys=array("system_id", "title", "description", "developer_id");
$this->checkCourseFile("des", $this->data["des"], $requiredKeys);
$this->checkColumnCount("des", $this->data["des"]);
//CRS
$requiredKeys=array("course_creator", "course_id", "course_system", "course_title",
"level", "max_fields_cst", "total_aus", "total_blocks", "version");
$this->checkCourseFile("crs", $this->data["crs"], $requiredKeys, "course");
$requiredKeys=array("max_normal");
$this->checkCourseFile("crs", $this->data["crs"], $requiredKeys, "course_behavior");
//CST
$requiredKeys=array("block", "member");
$this->checkCourseFile("cst", $this->data["cst"], $requiredKeys,0);
$this->checkColumnCount("cst", $this->data["cst"]);
return $errorText;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::checkStructure ( )

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

Referenced by validate().

{
//max member fields in cst-file
$max=$this->data[crs][course][max_fields_cst];
for ($row=0;$row<count($this->data[cst]);$row++) {
$value=$this->data[cst][$row][member];
if ((is_array($value) && count($value)>$max) || (!is_array($value) && $max==1)) {
$this->errorText[]="CRS-File: max_fields_cst does not match number of fields in the CST-File";
return;
}
}
//additional validation statements
//
//
}

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::findFiles (   $dir)

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

References $dir, $file, $files, and getAllFiles().

{
$suffixes=array_merge($this->requiredFiles,$this->optionalFiles);
foreach ($files as $file) {
foreach($suffixes as $suffix) {
if (strcasecmp(substr($file, -(strlen($suffix)+1)), ".".$suffix)==0)
$this->coursefiles[$suffix] = $file;
}
}
//check for required files
$missingFiles = array_diff ($this->requiredFiles, array_keys($this->coursefiles));
if (count($missingFiles)==4)
$this->errorText[]="Missing all required files.<br>You want to check if your learning module is of a different type.";
else if (count($missingFiles)>0)
$this->errorText[]="Missing required file(s): ".implode("<bR>", $missingFiles);
}

+ Here is the call graph for this function:

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

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

References $dir, and $file.

Referenced by findFiles().

{
if (substr($dir, -1)!="/")
$dir.="/";
$handle=opendir($dir);
while ($file = readdir ($handle)) {
if ($file != "." && $file != "..") {
if (is_dir($dir.$file))
$arr=$this->getAllFiles($dir.$file, $arr);
else
$arr[]=$dir.$file;
}
}
closedir($handle);
return $arr;
}

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::getDescriptor (   $system_id)

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

Referenced by writeToDatabase().

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

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::ilObjAICCCourseInterchangeFiles ( )

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

{
$this->errorText=array();
$this->coursefiles=array();
}
ilObjAICCCourseInterchangeFiles::readCRS (   $filename)

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

References $data, and $filename.

Referenced by readFiles().

{
$data=@parse_ini_file($filename, TRUE);
//crs-file is not a valid iniFile
//thats why reading the file again to get course_description
$lines=file($filename);
for($i=0;$i<count($lines);$i++) {
if (trim($lines[$i])=="[Course_Description]") {
for ($i++;$i<count($lines);$i++) {
if (strlen(trim($lines[$i]))>0) {
$data["Course_Description"][description]=$lines[$i];
break;
}
}
}
}
return $data;
}

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::readCSVFile (   $filename)

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

References $data, and $filename.

Referenced by readFiles().

{
$row=1;
$handle = fopen($filename, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row++==1) {
$header=$data;
} else if (count($data)>1) {
$data2=array();
for ($col=0; $col<count($data); $col++) {
if (array_key_exists($header[$col], $data2)) {
$value=$data2[$header[$col]];
if (!is_array($value))
$data2[$header[$col]]=array($value, utf8_encode($data[$col]));
else
$data2[$header[$col]][]=utf8_encode($data[$col]);
} else
$data2[$header[$col]]=utf8_encode($data[$col]);
}
$rows[]=$data2;
}
}
fclose($handle);
return $rows;
}

+ Here is the caller graph for this function:

ilObjAICCCourseInterchangeFiles::readFiles ( )

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

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

{
$this->data=array();
foreach ($this->coursefiles as $suffix=>$filename) {
if ($suffix=="crs")
$this->data[$suffix]=$this->readCRS($filename);
else
$this->data[$suffix]=$this->readCSVFile($filename);
}
//Prepare Data-Array: all keys to lower
$this->data=$this->arraykeys_tolower($this->data);
}

+ Here is the call graph for this function:

ilObjAICCCourseInterchangeFiles::validate ( )

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

References checkRequiredKeys(), and checkStructure().

{
$this->checkStructure();
}

+ Here is the call graph for this function:

ilObjAICCCourseInterchangeFiles::writeToDatabase (   $alm_id)

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

References getDescriptor().

{
include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCTree.php");
include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCCourse.php");
include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCBlock.php");
//write course to database
$course=new ilAICCCourse();
$course->setALMId($alm_id);
$course->setSystemId("root");
$course->setTitle($this->data["crs"]["course"]["course_title"]);
$course->setDescription($this->data["crs"]["course_description"]["description"]);
$course->setCourseCreator($this->data["crs"]["course"]["course_creator"]);
$course->setCourseId($this->data["crs"]["course"]["course_id"]);
$course->setCourseSystem($this->data["crs"]["course"]["course_system"]);
$course->setCourseTitle($this->data["crs"]["course"]["course_title"]);
$course->setLevel($this->data["crs"]["course"]["level"]);
$course->setMaxFieldsCst($this->data["crs"]["course"]["max_fields_cst"]);
$course->setMaxFieldsOrt($this->data["crs"]["course"]["max_fields_ort"]);
$course->setTotalAUs($this->data["crs"]["course"]["total_aus"]);
$course->setTotalBlocks($this->data["crs"]["course"]["total_blocks"]);
$course->setTotalComplexObj($this->data["crs"]["course"]["total_complex_obj"]);
$course->setTotalObjectives($this->data["crs"]["course"]["total_objectives"]);
$course->setVersion($this->data["crs"]["course"]["version"]);
$course->setMaxNormal($this->data["crs"]["course_behavior"]["max_normal"]);
$course->setDescription($this->data["crs"]["course_description"]["description"]);
$course->create();
$identifier["root"]=$course->getId();
//all blocks
foreach ($this->data["cst"] as $row) {
$system_id=strtolower($row["block"]);
if ($system_id!="root") {
$unit=new ilAICCBlock();
$description=$this->getDescriptor($system_id);
$unit->setALMId($alm_id);
$unit->setType("sbl");
$unit->setTitle($description["title"]);
$unit->setDescription($description["description"]);
$unit->setDeveloperId($description["developer_id"]);
$unit->setSystemId($description["system_id"]);
$unit->create();
$identifier[$system_id]=$unit->getId();
}
}
//write assignable units to database
foreach ($this->data["au"] as $row) {
$sysid=strtolower($row["system_id"]);
$unit=new ilAICCUnit();
$unit->setAUType($row["type"]);
$unit->setCommand_line($row["command_line"]);
$unit->setMaxTimeAllowed($row["max_time_allowed"]);
$unit->setTimeLimitAction($row["time_limit_action"]);
$unit->setMaxScore($row["max_score"]);
$unit->setCoreVendor($row["core_vendor"]);
$unit->setSystemVendor($row["system_vendor"]);
$unit->setFilename($row["file_name"]);
$unit->setMasteryScore($row["mastery_score"]);
$unit->setWebLaunch($row["web_launch"]);
$unit->setAUPassword($row["au_password"]);
$description=$this->getDescriptor($sysid);
$unit->setALMId($alm_id);
$unit->setType("sau");
$unit->setTitle($description["title"]);
$unit->setDescription($description["description"]);
$unit->setDeveloperId($description["developer_id"]);
$unit->setSystemId($description["system_id"]);
$unit->create();
$identifier[$sysid]=$unit->getId();
}
//write tree
$tree =& new ilAICCTree($alm_id);
$tree->addTree($alm_id, $identifier["root"]);
//writing members
foreach ($this->data["cst"] as $row) {
$members=$row["member"];
if (!is_array($members))
$members=array($members);
$parentid=$identifier[strtolower($row["block"])];
foreach($members as $member) {
$memberid=$identifier[strtolower($member)];
$tree->insertNode($memberid, $parentid);
}
}
}

+ Here is the call graph for this function:

Field Documentation

ilObjAICCCourseInterchangeFiles::$coursefiles

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

ilObjAICCCourseInterchangeFiles::$data
ilObjAICCCourseInterchangeFiles::$errorText

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

Referenced by checkRequiredKeys().

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

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

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: