ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilExerciseDataSet Class Reference

Exercise data set class. More...

+ Inheritance diagram for ilExerciseDataSet:
+ Collaboration diagram for ilExerciseDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions.
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace.
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data.
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record (export)
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record.
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor.
 init ($a_entity, $a_schema_version)
 Init.
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB.
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories.
 setImportDirectory ($a_val)
 Set import directory.
 getImportDirectory ()
 Get import directory.
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix.
 getDSPrefix ()
 Get XML dataset namespace prefix.
 getDSPrefixString ()
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields.
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string.
 getJsonRepresentation ()
 Get json representation.
 getXmlRepresentation ($a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ...
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml.
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record.
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces.
 getJsonRecord ($a_set)
 Get json record for version.
 getXmlTypes ($a_entity, $a_version)
 Get xml types.
 getJsonTypes ($a_entity, $a_version)
 Get json types.
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten)
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag.
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten)
 setImport ($a_val)
 Set import object.
 getImport ()
 Get import object.

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity.
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data.
- Protected Member Functions inherited from ilDataSet
 createObjectExportId ($a_type, $a_id)
 Build ilias export id.
 parseObjectExportId ($a_id, $a_fallback_id=NULL)
 Parse export id.

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
const EXPORT_NO_INST_ID = 1
const EXPORT_ID_ILIAS_LOCAL = 2
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
const EXPORT_ID_ILIAS_REMOTE = 4
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
const EXPORT_ID = 6
const EXPORT_ID_INVALID = 7

Detailed Description

Exercise data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilExerciseDataSet.php.

Member Function Documentation

ilExerciseDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 196 of file class.ilExerciseDataSet.php.

{
switch ($a_entity)
{
case "exc":
return array (
"exc_assignment" => array("ids" => $a_rec["Id"])
);
}
return false;
}
ilExerciseDataSet::getSupportedVersions ( )

Get supported versions.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 21 of file class.ilExerciseDataSet.php.

{
return array("4.1.0", "4.4.0");
}
ilExerciseDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters
@return

Reimplemented from ilDataSet.

Definition at line 43 of file class.ilExerciseDataSet.php.

{
if ($a_entity == "exc")
{
switch ($a_version)
{
case "4.1.0":
case "4.4.0":
return array(
"Id" => "integer",
"Title" => "text",
"Description" => "text",
"PassMode" => "text",
"PassNr" => "integer",
"ShowSubmissions" => "integer");
}
}
if ($a_entity == "exc_assignment")
{
switch ($a_version)
{
case "4.1.0":
return array(
"Id" => "integer",
"ExerciseId" => "integer",
"Deadline" => "text",
"Instruction" => "text",
"Title" => "text",
"Mandatory" => "integer",
"OrderNr" => "integer",
"Dir" => "directory");
case "4.4.0":
return array(
"Id" => "integer",
"ExerciseId" => "integer",
"Type" => "integer",
"Deadline" => "integer",
"Instruction" => "text",
"Title" => "text",
"Mandatory" => "integer",
"OrderNr" => "integer",
"Dir" => "directory"
// peer
,"Peer" => "integer"
,"PeerMin" => "integer"
,"PeerDeadline" => "integer"
// global feedback
,"FeedbackFile" => "integer"
,"FeedbackCron" => "integer"
,"FeedbackDate" => "integer"
,"FeedbackDir" => "directory"
);
}
}
}
ilExerciseDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters
@return

Reimplemented from ilDataSet.

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

{
return "http://www.ilias.de/xml/Modules/Exercise/".$a_entity;
}
ilExerciseDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record (export)

Parameters
arrayabstract data record
Returns
array xml record

Reimplemented from ilDataSet.

Definition at line 163 of file class.ilExerciseDataSet.php.

References IL_CAL_DATETIME, and IL_CAL_UNIX.

{
if ($a_entity == "exc_assignment")
{
// convert server dates to utc
if($a_set["StartTime"] != "")
{
$start = new ilDateTime($a_set["StartTime"], IL_CAL_UNIX);
$a_set["StartTime"] = $start->get(IL_CAL_DATETIME,'','UTC');
}
if($a_set["Deadline"] != "")
{
$deadline = new ilDateTime($a_set["Deadline"], IL_CAL_UNIX);
$a_set["Deadline"] = $deadline->get(IL_CAL_DATETIME,'','UTC');
}
include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
$fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
$a_set["Dir"] = $fstorage->getPath();
include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
$fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
$a_set["FeedbackDir"] = $fstorage->getGlobalFeedbackPath();
}
return $a_set;
}
ilExerciseDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters
@return

Definition at line 216 of file class.ilExerciseDataSet.php.

References ilFSStorageExercise\create(), ilDataSet\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), IL_CAL_DATETIME, IL_CAL_UNIX, and ilUtil\rCopy().

{
//echo $a_entity;
//var_dump($a_rec);
switch ($a_entity)
{
case "exc":
include_once("./Modules/Exercise/classes/class.ilObjExercise.php");
if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
{
$newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
}
else
{
$newObj = new ilObjExercise();
$newObj->setType("exc");
$newObj->create(true);
}
$newObj->setTitle($a_rec["Title"]);
$newObj->setDescription($a_rec["Description"]);
$newObj->setPassMode($a_rec["PassMode"]);
$newObj->setPassNr($a_rec["PassNr"]);
$newObj->setShowSubmissions($a_rec["ShowSubmissions"]);
$newObj->update();
$newObj->saveData();
//var_dump($a_rec);
$this->current_exc = $newObj;
$a_mapping->addMapping("Modules/Exercise", "exc", $a_rec["Id"], $newObj->getId());
//var_dump($a_mapping->mappings["Services/News"]["news_context"]);
break;
case "exc_assignment":
$exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["ExerciseId"]);
if ($exc_id > 0)
{
if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id)
{
$exc = $this->current_exc;
}
else
{
include_once("./Modules/Exercise/classes/class.ilObjExercise.php");
$exc = new ilObjExercise($exc_id, false);
}
include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
$ass = new ilExAssignment();
$ass->setExerciseId($exc_id);
if ($a_rec["StartTime"] != "")
{
$start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC");
$ass->setStartTime($start->get(IL_CAL_UNIX));
}
if ($a_rec["Deadline"] != "")
{
$deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC");
$ass->setDeadline($deadline->get(IL_CAL_UNIX));
}
//var_dump($a_rec);
$ass->setInstruction($a_rec["Instruction"]);
$ass->setTitle($a_rec["Title"]);
$ass->setMandatory($a_rec["Mandatory"]);
$ass->setOrderNr($a_rec["OrderNr"]);
// 4.2
$ass->setType($a_rec["Type"]);
// 4.4
$ass->setPeerReview($a_rec["Peer"]);
$ass->setPeerReviewMin($a_rec["PeerMin"]);
$ass->setPeerReviewDeadline($a_rec["PeerDeadline"]);
$ass->setFeedbackFile($a_rec["FeedbackFile"]);
$ass->setFeedbackCron($a_rec["FeedbackCron"]);
$ass->setFeedbackDate($a_rec["FeedbackDate"]);
$ass->save();
include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
$fstorage = new ilFSStorageExercise($exc_id, $ass->getId());
$fstorage->create();
// assignment files
$dir = str_replace("..", "", $a_rec["Dir"]);
if ($dir != "" && $this->getImportDirectory() != "")
{
$source_dir = $this->getImportDirectory()."/".$dir;
$target_dir = $fstorage->getPath();
ilUtil::rCopy($source_dir, $target_dir);
}
// (4.4) global feedback file
$dir = str_replace("..", "", $a_rec["FeedbackDir"]);
if ($dir != "" && $this->getImportDirectory() != "")
{
$source_dir = $this->getImportDirectory()."/".$dir;
$target_dir = $fstorage->getGlobalFeedbackPath();
ilUtil::rCopy($source_dir, $target_dir);
}
$a_mapping->addMapping("Modules/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId());
}
break;
}
}

+ Here is the call graph for this function:

ilExerciseDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters
@return

Definition at line 108 of file class.ilExerciseDataSet.php.

References ilDataSet\getDirectDataFromQuery().

{
global $ilDB;
if (!is_array($a_ids))
{
$a_ids = array($a_ids);
}
if ($a_entity == "exc")
{
switch ($a_version)
{
case "4.1.0":
case "4.4.0":
$this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description, ".
" pass_mode, pass_nr, show_submissions".
" FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id) ".
"WHERE ".
$ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
break;
}
}
if ($a_entity == "exc_assignment")
{
switch ($a_version)
{
case "4.1.0":
$this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline, ".
" instruction, title, start_time, mandatory, order_nr".
" FROM exc_assignment ".
"WHERE ".
$ilDB->in("exc_id", $a_ids, false, "integer"));
break;
case "4.4.0":
$this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline,".
" instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline,".
" fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date".
" FROM exc_assignment".
" WHERE ".
$ilDB->in("exc_id", $a_ids, false, "integer"));
break;
}
}
}

+ Here is the call graph for this function:


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