ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjSurveyQuestionPool Class Reference
+ Inheritance diagram for ilObjSurveyQuestionPool:
+ Collaboration diagram for ilObjSurveyQuestionPool:

Public Member Functions

 ilObjSurveyQuestionPool ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 create ($a_upload=false)
 create question pool object
 update ()
 update object data
 read ($a_force_db=false)
 read object data from db into object
 cloneObject ($a_target_id, $a_copy_id=0)
 Creates a 1:1 copy of the object and places the copy in a given repository.
createQuestion ($question_type, $question_id=-1)
 copyQuestion ($question_id, $questionpool_to)
 Copies a question into another question pool.
 loadFromDb ()
 Loads a ilObjQuestionpool object from a database.
 saveToDb ()
 Saves a ilObjSurveyQuestionPool object to a database.
 delete ()
 delete object and all related data
 deleteAllData ()
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts.
 getTitle ()
 get title of survey question pool object
 setTitle ($a_title)
 set title of survey question pool object
 removeQuestion ($question_id)
 Removes a question from the question pool.
 getQuestiontype ($question_id)
 Returns the question type of a question with a given id.
 isInUse ($question_id)
 Checks if a question is in use by a survey.
 paste ($question_id)
 Pastes a question in the question pool.
getQuestionsInfo ($question_array)
 Retrieves the datase entries for questions from a given array.
 duplicateQuestion ($question_id, $obj_id="")
 Duplicates a question for a questionpool.
 getQuestionsData ($arrFilter)
 Calculates the data for the output of the questionpool.
 createExportDirectory ()
 creates data directory for export files (data_dir/spl_data/spl_<id>/export, depending on data directory that is set in ILIAS setup/ini)
 getExportDirectory ()
 get export directory of survey
 getExportFiles ($dir)
 get export files
 createImportDirectory ()
 creates data directory for import files (data_dir/spl_data/spl_<id>/import, depending on data directory that is set in ILIAS setup/ini)
 getImportDirectory ()
 get import directory of survey
 toXML ($questions)
 export questions to xml
getQuestions ()
 importObject ($source, $spl_exists=FALSE)
 Imports survey questions into ILIAS.
 setOnline ($a_online_status)
 Sets the questionpool online status.
 getOnline ()
 _lookupOnline ($a_obj_id)
 _isWriteable ($object_id, $user_id)
 Returns true, if the question pool is writeable by a given user.
_getQuestiontypes ()
 Creates a list of all available question types.
_getAvailableQuestionpools ($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
 Returns the available question pools for the active user.
 isPluginActive ($a_pname)
 Checks whether or not a question plugin with a given name is active.
 getQuestionInfos ($question_ids)
 Returns title, description and type for an array of question id's.
 purgeQuestions ()
 copyToClipboard ($question_id)
 Copies a question to the clipboard.
 moveToClipboard ($question_id)
 Moves a question to the clipboard.
 pasteFromClipboard ()
 Copies/Moves a question from the clipboard.
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public.
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not)
 getId ()
 get object id public
 setId ($a_id)
 set object id public
 setRefId ($a_id)
 set reference id public
 getRefId ()
 get reference id public
 getType ()
 get object type public
 setType ($a_type)
 set object type public
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions
 getUntranslatedTitle ()
 get untranslated object title public
 getDescription ()
 get object description
 setDescription ($a_desc)
 set object description
 getLongDescription ()
 get object long description (stored in object_description)
 getImportId ()
 get import id
 setImportId ($a_import_id)
 set import id
 getOwner ()
 get object owner
 getOwnerName ()
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id
 setOwner ($a_owner)
 set object owner
 getCreateDate ()
 get create date public
 getLastUpdateDate ()
 get last update date public
 getDiskUsage ()
 Gets the disk usage of the object in bytes.
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class)
 create ()
 create
 MDUpdateListener ($a_element)
 Meta data update listener.
 createMetaData ()
 create meta data entry
 updateMetaData ()
 update meta data entry
 deleteMetaData ()
 delete meta data entry
 updateOwner ()
 update owner of object in db
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _lookupOwner ($a_id)
 lookup object owner
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects.
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static)
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static)
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static)
 _isInTrash ($a_ref_id)
 checks wether object is in trash
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash
 _lookupObjectId ($a_ref_id)
 lookup object id
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!?
 setPermissions ($a_parent_ref)
 set permissions of object
 createReference ()
 creates reference for object
 countReferences ()
 count references of object
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public
 createRoleFolder ()
 creates a local role folder
 applyDidacticTemplate ($a_tpl_id)
 Apply template.
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 getXMLZip ()
 getHTMLDirectory ()
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ...
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container.
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies.
 cloneMetaData ($target_obj)
 Copy meta data.

Static Public Member Functions

static _setOnline ($a_obj_id, $a_online_status)
static & _getQuestionTypeTranslations ()
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupDescription ($a_id)
 lookup object description
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
 _exists ($a_id, $a_reference=false)
 checks if an object exists in object_data
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection.
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item.
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies.
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies.

Data Fields

 $online
- Data Fields inherited from ilObject
const TITLE_LENGTH = 128
 max length of object title
 $ilias
 $lng
 $id
 $ref_id
 $type
 $title
 $untranslatedTitle
 $desc
 $long_desc
 $owner
 $create_date
 $last_update
 $import_id
 $register = false
 $referenced
 $objectList
 $max_title
 $max_desc
 $add_dots
 $obj_data_record
 object_data record

Detailed Description

Definition at line 37 of file class.ilObjSurveyQuestionPool.php.

Member Function Documentation

& ilObjSurveyQuestionPool::_getAvailableQuestionpools (   $use_object_id = FALSE,
  $could_be_offline = FALSE,
  $showPath = FALSE,
  $permission = "read" 
)

Returns the available question pools for the active user.

Returns
array The available question pools public

Definition at line 988 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, ilObject\$ref_id, $result, $row, ilUtil\_getObjectsByOperations(), ilObject\_lookupObjectId(), and ilObject\_prepareCloneSelection().

Referenced by ilSurveyQuestionbrowserTableGUI\__construct(), ilObjSurvey\getAvailableQuestionpools(), and ilObjSurvey\getQuestionpoolTitles().

{
global $ilUser;
global $ilDB;
$result_array = array();
$qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
$titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
$allqpls = array();
$result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
while ($row = $ilDB->fetchAssoc($result))
{
$allqpls[$row['obj_fi']] = $row['isonline'];
}
foreach ($qpls as $ref_id)
{
$obj_id = ilObject::_lookupObjectId($ref_id);
if (($could_be_offline) || ($allqpls[$obj_id]['isonline'] == 1))
{
if ($use_object_id)
{
$result_array[$obj_id] = $titles[$ref_id];
}
else
{
$result_array[$ref_id] = $titles[$ref_id];
}
}
}
return $result_array;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilObjSurveyQuestionPool::_getQuestiontypes ( )

Creates a list of all available question types.

Returns
array An array containing the available questiontypes public

Definition at line 916 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, ilObject\$lng, $row, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by ilSurveyPageGUI\addQuestion(), ilSurveyPageGUI\addQuestionToolbarForm(), ilSurveyPageGUI\getPageNodes(), ilSurveyQuestionTableGUI\importData(), and ilObjSurveyGUI\questionsObject().

{
global $ilDB;
global $lng;
$lng->loadLanguageModule("survey");
$types = array();
$query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
while ($row = $ilDB->fetchAssoc($query_result))
{
//array_push($questiontypes, $row["type_tag"]);
if ($row["plugin"] == 0)
{
$types[$lng->txt($row["type_tag"])] = $row;
}
else
{
global $ilPluginAdmin;
$pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
foreach ($pl_names as $pl_name)
{
$pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0)
{
$types[$pl->getQuestionTypeTranslation()] = $row;
}
}
}
}
ksort($types);
return $types;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static& ilObjSurveyQuestionPool::_getQuestionTypeTranslations ( )
static

Definition at line 949 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $ilLog, ilObject\$lng, $result, $row, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by ilObjSurvey\getQuestionsTable().

{
global $ilDB;
global $lng;
global $ilLog;
global $ilPluginAdmin;
$lng->loadLanguageModule("survey");
$result = $ilDB->query("SELECT * FROM svy_qtype");
$types = array();
while ($row = $ilDB->fetchAssoc($result))
{
if ($row["plugin"] == 0)
{
$types[$row['type_tag']] = $lng->txt($row["type_tag"]);
}
else
{
$pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
foreach ($pl_names as $pl_name)
{
$pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0)
{
$types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
}
}
}
}
ksort($types);
return $types;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::_isWriteable (   $object_id,
  $user_id 
)

Returns true, if the question pool is writeable by a given user.

Parameters
integer$object_idThe object id of the question pool
integer$user_idThe database id of the user public

Definition at line 893 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, ilObject\_getAllReferences(), and ilObject\_hasUntrashedReference().

{
global $rbacsystem;
global $ilDB;
$refs = ilObject::_getAllReferences($object_id);
$result = false;
foreach ($refs as $ref)
{
if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id)))
{
$result = true;
}
}
return $result;
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::_lookupOnline (   $a_obj_id)

Definition at line 870 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, and $row.

Referenced by ilObjSurveyQuestionPoolListGUI\getProperties().

{
global $ilDB;
$result = $ilDB->queryF("SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
array('integer'),
array($a_obj_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return $row["isonline"];
}
return 0;
}

+ Here is the caller graph for this function:

static ilObjSurveyQuestionPool::_setOnline (   $a_obj_id,
  $a_online_status 
)
static

Definition at line 825 of file class.ilObjSurveyQuestionPool.php.

References $ilDB.

{
global $ilDB;
$status = "0";
switch ($a_online_status)
{
case 0:
case 1:
$status = "$a_online_status";
break;
}
$affectedRows = $ilDB->manipulateF("UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
array('text','integer'),
array($status, $a_obj_id)
);
}
ilObjSurveyQuestionPool::cloneObject (   $a_target_id,
  $a_copy_id = 0 
)

Creates a 1:1 copy of the object and places the copy in a given repository.

public

Definition at line 105 of file class.ilObjSurveyQuestionPool.php.

References $ilLog, ilObject\getId(), getOnline(), getQuestions(), and ilObject\getType().

{
global $ilLog;
$newObj = parent::cloneObject($a_target_id,$a_copy_id);
$newObj->setOnline($this->getOnline());
$newObj->saveToDb();
// clone the questions in the question pool
$questions =& $this->getQuestions();
foreach ($questions as $question_id)
{
$newObj->copyQuestion($question_id, $newObj->getId());
}
// clone meta data
include_once "./Services/MetaData/classes/class.ilMD.php";
$md = new ilMD($this->getId(),0,$this->getType());
$new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
// update the metadata with the new title of the question pool
$newObj->updateMetaData();
return $newObj;
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::copyQuestion (   $question_id,
  $questionpool_to 
)

Copies a question into another question pool.

Parameters
integer$question_idDatabase id of the question
integer$questionpool_toDatabase id of the target questionpool public

Definition at line 154 of file class.ilObjSurveyQuestionPool.php.

References createQuestion(), duplicateQuestion(), and ilObject\getId().

Referenced by pasteFromClipboard().

{
$question_gui =& $this->createQuestion("", $question_id);
if ($question_gui->object->getObjId() == $questionpool_to)
{
// the question is copied into the same question pool
$this->duplicateQuestion($question_id);
}
else
{
// the question is copied into another question pool
$newtitle = $question_gui->object->getTitle();
if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to))
{
$counter = 2;
while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() . " ($counter)", $questionpool_to))
{
$counter++;
}
$newtitle = $question_gui->object->getTitle() . " ($counter)";
}
$question_gui->object->copyObject($this->getId(), $newtitle);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::copyToClipboard (   $question_id)

Copies a question to the clipboard.

Parameters
integer$question_idObject id of the question

Definition at line 1089 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION.

{
if (!array_key_exists("spl_clipboard", $_SESSION))
{
$_SESSION["spl_clipboard"] = array();
}
$_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
}
ilObjSurveyQuestionPool::create (   $a_upload = false)

create question pool object

Definition at line 61 of file class.ilObjSurveyQuestionPool.php.

References ilObject\create(), and ilObject\createMetaData().

{
if(!$a_upload)
{
$this->createMetaData();
}
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::createExportDirectory ( )

creates data directory for export files (data_dir/spl_data/spl_<id>/export, depending on data directory that is set in ILIAS setup/ini)

Definition at line 565 of file class.ilObjSurveyQuestionPool.php.

References ilUtil\getDataDir(), ilObject\getId(), and ilUtil\makeDir().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$spl_data_dir = ilUtil::getDataDir()."/spl_data";
ilUtil::makeDir($spl_data_dir);
if(!is_writable($spl_data_dir))
{
$this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
.") not writeable.",$this->ilias->error_obj->FATAL);
}
// create learning module directory (data_dir/lm_data/lm_<id>)
$spl_dir = $spl_data_dir."/spl_".$this->getId();
ilUtil::makeDir($spl_dir);
if(!@is_dir($spl_dir))
{
$this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
}
// create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
$export_dir = $spl_dir."/export";
ilUtil::makeDir($export_dir);
if(!@is_dir($export_dir))
{
$this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
}
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::createImportDirectory ( )

creates data directory for import files (data_dir/spl_data/spl_<id>/import, depending on data directory that is set in ILIAS setup/ini)

Definition at line 645 of file class.ilObjSurveyQuestionPool.php.

References ilUtil\getDataDir(), ilObject\getId(), and ilUtil\makeDir().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$spl_data_dir = ilUtil::getDataDir()."/spl_data";
ilUtil::makeDir($spl_data_dir);
if(!is_writable($spl_data_dir))
{
$this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
.") not writeable.",$this->ilias->error_obj->FATAL);
}
// create test directory (data_dir/spl_data/spl_<id>)
$spl_dir = $spl_data_dir."/spl_".$this->getId();
ilUtil::makeDir($spl_dir);
if(!@is_dir($spl_dir))
{
$this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
}
// create import subdirectory (data_dir/spl_data/spl_<id>/import)
$import_dir = $spl_dir."/import";
ilUtil::makeDir($import_dir);
if(!@is_dir($import_dir))
{
$this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
}
}

+ Here is the call graph for this function:

& ilObjSurveyQuestionPool::createQuestion (   $question_type,
  $question_id = -1 
)

Definition at line 128 of file class.ilObjSurveyQuestionPool.php.

References getQuestiontype().

Referenced by copyQuestion().

{
if ((!$question_type) and ($question_id > 0))
{
$question_type = $this->getQuestiontype($question_id);
}
include_once "./Modules/SurveyQuestionPool/classes/class.".$question_type."GUI.php";
$question_type_gui = $question_type . "GUI";
$question =& new $question_type_gui();
if ($question_id > 0)
{
$question->object->loadFromDb($question_id);
}
return $question;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::delete ( )

delete object and all related data

public

Returns
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 235 of file class.ilObjSurveyQuestionPool.php.

References deleteAllData(), and ilObject\deleteMetaData().

{
$remove = parent::delete();
// always call parent delete function first!!
if (!$remove)
{
return false;
}
// delete all related questions
$this->deleteAllData();
// delete meta data
$this->deleteMetaData();
return true;
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::deleteAllData ( )

Definition at line 253 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, $row, ilUtil\delDir(), ilUtil\getDataDir(), ilObject\getId(), and removeQuestion().

Referenced by delete().

{
global $ilDB;
$result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
array('integer'),
array($this->getId())
);
$found_questions = array();
while ($row = $ilDB->fetchAssoc($result))
{
$this->removeQuestion($row["question_id"]);
}
// delete export files
include_once "./Services/Utilities/classes/class.ilUtil.php";
$spl_data_dir = ilUtil::getDataDir()."/spl_data";
$directory = $spl_data_dir."/spl_".$this->getId();
if (is_dir($directory))
{
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::duplicateQuestion (   $question_id,
  $obj_id = "" 
)

Duplicates a question for a questionpool.

Parameters
integer$question_idThe database id of the question public

Definition at line 483 of file class.ilObjSurveyQuestionPool.php.

References SurveyQuestion\_instanciateQuestion().

Referenced by copyQuestion(), and paste().

{
global $ilUser;
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question = SurveyQuestion::_instanciateQuestion($question_id);
$suffix = "";
$counter = 1;
while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
{
$counter++;
if ($counter > 1) $suffix = " ($counter)";
}
if ($obj_id)
{
$question->setObjId($obj_id);
}
$question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::getExportDirectory ( )

get export directory of survey

Definition at line 595 of file class.ilObjSurveyQuestionPool.php.

References ilUtil\getDataDir().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$export_dir = ilUtil::getDataDir()."/spl_data"."/spl_".$this->getId()."/export";
return $export_dir;
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::getExportFiles (   $dir)

get export files

Definition at line 605 of file class.ilObjSurveyQuestionPool.php.

References $dir, and $file.

{
// quit if import dir not available
if (!@is_dir($dir) or
!is_writeable($dir))
{
return array();
}
// open directory
$dir = dir($dir);
// initialize array
$file = array();
// get files and save the in the array
while ($entry = $dir->read())
{
if ($entry != "." &&
$entry != ".." &&
ereg("^[0-9]{10}_{2}[0-9]+_{2}(spl_)*[0-9]+\.[A-Za-z]{3}\$", $entry))
{
$file[] = $entry;
}
}
// close import directory
$dir->close();
// sort files
sort ($file);
reset ($file);
return $file;
}
ilObjSurveyQuestionPool::getImportDirectory ( )

get import directory of survey

Definition at line 677 of file class.ilObjSurveyQuestionPool.php.

References ilUtil\getDataDir().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$import_dir = ilUtil::getDataDir()."/spl_data".
"/spl_".$this->getId()."/import";
if(@is_dir($import_dir))
{
return $import_dir;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::getOnline ( )

Definition at line 864 of file class.ilObjSurveyQuestionPool.php.

References $online.

Referenced by cloneObject(), saveToDb(), and toXML().

{
if (strcmp($this->online, "") == 0) $this->online = "0";
return $this->online;
}

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::getQuestionInfos (   $question_ids)

Returns title, description and type for an array of question id's.

Parameters
array$question_idsAn array of question id's
Returns
array Array of associated arrays with title, description, type_tag

Definition at line 1045 of file class.ilObjSurveyQuestionPool.php.

References $data, and $ilDB.

{
global $ilDB;
$found = array();
$query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
"WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
"AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
"ORDER BY svy_question.title");
if ($query_result->numRows() > 0)
{
while ($data = $ilDB->fetchAssoc($query_result))
{
if (in_array($data["question_id"], $question_ids))
{
array_push($found, array('title' => $data["title"], 'description' => $data["description"], 'type_tag' => $data["type_tag"]));
}
}
}
return $found;
}
& ilObjSurveyQuestionPool::getQuestions ( )

Definition at line 756 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, $row, and ilObject\getId().

Referenced by cloneObject(), and toXML().

{
global $ilDB;
$questions = array();
$result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
array('integer'),
array($this->getId())
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
array_push($questions, $row["question_id"]);
}
}
return $questions;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::getQuestionsData (   $arrFilter)

Calculates the data for the output of the questionpool.

public

Definition at line 507 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $row, ilObject\getId(), and isPluginActive().

{
global $ilUser;
global $ilDB;
$where = "";
if (is_array($arrFilter))
{
foreach ($arrFilter as $key => $value)
{
$arrFilter[$key] = str_replace('%', '', $arrFilter[$key]);
}
if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title']))
{
$where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
}
if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description']))
{
$where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
}
if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author']))
{
$where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
}
if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type']))
{
$where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
}
}
$query_result = $ilDB->queryF("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin FROM svy_question, svy_qtype WHERE svy_question.original_id IS NULL AND svy_question.tstamp > 0 AND svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.obj_fi = %s" . $where,
array('integer'),
array($this->getId())
);
$rows = array();
if ($query_result->numRows())
{
while ($row = $ilDB->fetchAssoc($query_result))
{
if ($row["plugin"])
{
if ($this->isPluginActive($row["type_tag"]))
{
array_push($rows, $row);
}
}
else
{
array_push($rows, $row);
}
}
}
return $rows;
}

+ Here is the call graph for this function:

& ilObjSurveyQuestionPool::getQuestionsInfo (   $question_array)

Retrieves the datase entries for questions from a given array.

Parameters
array$question_arrayAn array containing the id's of the questions
Returns
array An array containing the database rows of the given question id's public

Definition at line 455 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, $row, and isPluginActive().

{
global $ilDB;
$result_array = array();
$result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin FROM svy_question, svy_qtype WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_array, false, 'integer'));
while ($row = $ilDB->fetchAssoc($result))
{
if ($row["plugin"])
{
if ($this->isPluginActive($row["type_tag"]))
{
array_push($result_array, $row);
}
}
else
{
array_push($result_array, $row);
}
}
return $result_array;
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::getQuestiontype (   $question_id)

Returns the question type of a question with a given id.

Parameters
integer$question_idThe database id of the question
Returns
string The question type string private

Definition at line 383 of file class.ilObjSurveyQuestionPool.php.

References $data, $ilDB, and $result.

Referenced by createQuestion(), and toXML().

{
global $ilDB;
if ($question_id < 1) return;
$result = $ilDB->queryF("SELECT svy_qtype.type_tag FROM svy_question, svy_qtype WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
return $data["type_tag"];
}
else
{
return;
}
}

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::getTitle ( )

get title of survey question pool object

Returns
string title

Reimplemented from ilObject.

Definition at line 348 of file class.ilObjSurveyQuestionPool.php.

Referenced by toXML().

{
//return $this->title;
return parent::getTitle();
}

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::ilObjSurveyQuestionPool (   $a_id = 0,
  $a_call_by_reference = true 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 52 of file class.ilObjSurveyQuestionPool.php.

References ilObject\ilObject().

{
$this->type = "spl";
$this->ilObject($a_id,$a_call_by_reference);
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::importObject (   $source,
  $spl_exists = FALSE 
)

Imports survey questions into ILIAS.

Parameters
string$sourceThe filename of an XML import file public

Definition at line 780 of file class.ilObjSurveyQuestionPool.php.

References ilUtil\delDir(), ilObject\getId(), and ilUtil\unzip().

{
if (is_file($source))
{
$isZip = (strcmp(strtolower(substr($source, -3)), 'zip') == 0);
if ($isZip)
{
// unzip file
ilUtil::unzip($source);
// determine filenames of xml files
$subdir = basename($source, ".zip");
$source = dirname($source)."/".$subdir."/".$subdir.".xml";
}
$fh = fopen($source, "r") or die("");
$xml = fread($fh, filesize($source));
fclose($fh) or die("");
if ($isZip)
{
$subdir = basename($source, ".zip");
if (@is_dir(dirname($source)."/".$subdir))
{
ilUtil::delDir(dirname($source)."/".$subdir);
}
}
if (strpos($xml, "questestinterop") > 0)
{
// survey questions for ILIAS < 3.8
include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
$import = new SurveyImportParserPre38($this->getId(), "", $spl_exists);
$import->setXMLContent($xml);
$import->startParsing();
}
else
{
// survey questions for ILIAS >= 3.8
include_once "./Services/Survey/classes/class.SurveyImportParser.php";
$import = new SurveyImportParser($this->getId(), "", $spl_exists);
$import->setXMLContent($xml);
$import->startParsing();
}
}
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::isInUse (   $question_id)

Checks if a question is in use by a survey.

Parameters
integer$question_idThe database id of the question
Returns
mixed An array of the surveys which use the question, when the question is in use by at least one survey, otherwise false public

Definition at line 409 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, and $row.

{
global $ilDB;
// check out the already answered questions
$result = $ilDB->queryF("SELECT answer_id FROM svy_answer WHERE question_fi = %s",
array('integer'),
array($question_id)
);
$answered = $result->numRows();
// check out the questions inserted in surveys
$result = $ilDB->queryF("SELECT svy_svy.* FROM svy_svy, svy_svy_qst WHERE svy_svy_qst.survey_fi = svy_svy.survey_id AND svy_svy_qst.question_fi = %s",
array('integer'),
array($question_id)
);
$inserted = $result->numRows();
if (($inserted + $answered) == 0)
{
return false;
}
$result_array = array();
while ($row = $ilDB->fetchObject($result))
{
array_push($result_array, $row);
}
return $result_array;
}
ilObjSurveyQuestionPool::isPluginActive (   $a_pname)

Checks whether or not a question plugin with a given name is active.

Parameters
string$a_pnameThe plugin name public

Definition at line 1026 of file class.ilObjSurveyQuestionPool.php.

References IL_COMP_MODULE.

Referenced by getQuestionsData(), and getQuestionsInfo().

{
global $ilPluginAdmin;
if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::loadFromDb ( )

Loads a ilObjQuestionpool object from a database.

public

Definition at line 184 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, $row, ilObject\getId(), and setOnline().

Referenced by read().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_qpl WHERE obj_fi = %s",
array('integer'),
array($this->getId())
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$this->setOnline($row["isonline"]);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::moveToClipboard (   $question_id)

Moves a question to the clipboard.

Parameters
integer$question_idObject id of the question

Definition at line 1103 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION.

{
if (!array_key_exists("spl_clipboard", $_SESSION))
{
$_SESSION["spl_clipboard"] = array();
}
$_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
}
ilObjSurveyQuestionPool::notify (   $a_event,
  $a_ref_id,
  $a_parent_non_rbac_id,
  $a_node_id,
  $a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

If you are not required to handle any events related to your module, just delete this method. (For an example how this method is used, look at ilObjGroup)

public

Parameters
stringevent
integerreference id of object where the event occured
arraypasses optional parameters if required
Returns
boolean

Reimplemented from ilObject.

Definition at line 290 of file class.ilObjSurveyQuestionPool.php.

References $_GET, and ilObject\getType().

{
global $tree;
switch ($a_event)
{
case "link":
//var_dump("<pre>",$a_params,"</pre>");
//echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
//exit;
break;
case "cut":
//echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
//exit;
break;
case "copy":
//var_dump("<pre>",$a_params,"</pre>");
//echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
//exit;
break;
case "paste":
//echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
//exit;
break;
case "new":
//echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
//exit;
break;
}
// At the beginning of the recursive process it avoids second call of the notify function with the same parameter
if ($a_node_id==$_GET["ref_id"])
{
$parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
$parent_type = $parent_obj->getType();
if($parent_type == $this->getType())
{
$a_node_id = (int) $tree->getParentId($a_node_id);
}
}
parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::paste (   $question_id)

Pastes a question in the question pool.

Parameters
integer$question_idThe database id of the question public

Definition at line 443 of file class.ilObjSurveyQuestionPool.php.

References duplicateQuestion(), and ilObject\getId().

{
$this->duplicateQuestion($question_id, $this->getId());
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

Definition at line 1115 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION, $ilDB, $result, $row, copyQuestion(), ilObject\getId(), ilUtil\makeDirParents(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
global $ilDB;
if (array_key_exists("spl_clipboard", $_SESSION))
{
foreach ($_SESSION["spl_clipboard"] as $question_object)
{
if (strcmp($question_object["action"], "move") == 0)
{
$result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
array('integer'),
array($question_object["question_id"])
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$source_questionpool = $row["obj_fi"];
if ($this->getId() != $source_questionpool)
{
// change the questionpool id in the qpl_questions table
$affectedRows = $ilDB->manipulateF("UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
array('integer','integer'),
array($this->getId(), $question_object["question_id"])
);
// move question data to the new target directory
$source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
if (@is_dir($source_path))
{
$target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
if (!@is_dir($target_path))
{
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::makeDirParents($target_path);
}
@rename($source_path, $target_path . $question_object["question_id"]);
}
}
else
{
ilUtil::sendFailure($this->lng->txt("spl_move_same_pool"), true);
return;
}
}
}
else
{
$this->copyQuestion($question_object["question_id"], $this->getId());
}
}
}
ilUtil::sendSuccess($this->lng->txt("spl_paste_success"), true);
unset($_SESSION["spl_clipboard"]);
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::purgeQuestions ( )

Definition at line 1070 of file class.ilObjSurveyQuestionPool.php.

References $data, $ilDB, $result, and removeQuestion().

{
global $ilDB, $ilUser;
$result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
array("integer", "integer"),
array($ilUser->getId(), 0)
);
while ($data = $ilDB->fetchAssoc($result))
{
$this->removeQuestion($data["question_id"]);
}
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::read (   $a_force_db = false)

read object data from db into object

Parameters
booleanpublic

Reimplemented from ilObject.

Definition at line 94 of file class.ilObjSurveyQuestionPool.php.

References loadFromDb().

{
parent::read($a_force_db);
$this->loadFromDb();
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::removeQuestion (   $question_id)

Removes a question from the question pool.

Parameters
integer$question_idThe database id of the question private

Definition at line 368 of file class.ilObjSurveyQuestionPool.php.

References SurveyQuestion\_instanciateQuestion().

Referenced by deleteAllData(), and purgeQuestions().

{
if ($question_id < 1) return;
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question =& SurveyQuestion::_instanciateQuestion($question_id);
$question->delete($question_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::saveToDb ( )

Saves a ilObjSurveyQuestionPool object to a database.

public

Definition at line 204 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $query, $result, ilObject\getId(), and getOnline().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_qpl WHERE obj_fi = %s",
array('integer'),
array($this->getId())
);
if ($result->numRows() == 1)
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
array('text','integer','integer'),
array($this->getOnline(), time(), $this->getId())
);
}
else
{
$next_id = $ilDB->nextId('svy_qpl');
$query = $ilDB->manipulateF("INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
array('integer', 'text', 'integer', 'integer'),
array($next_id, $this->getOnline(), $this->getId(), time())
);
}
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::setOnline (   $a_online_status)

Sets the questionpool online status.

Parameters
integer$a_online_statusOnline status of the questionpool
See Also
online User interface

Definition at line 850 of file class.ilObjSurveyQuestionPool.php.

Referenced by loadFromDb().

{
switch ($a_online_status)
{
case 0:
case 1:
$this->online = $a_online_status;
break;
default:
$this->online = 0;
break;
}
}

+ Here is the caller graph for this function:

ilObjSurveyQuestionPool::setTitle (   $a_title)

set title of survey question pool object

Reimplemented from ilObject.

Definition at line 357 of file class.ilObjSurveyQuestionPool.php.

{
parent::setTitle($a_title);
}
ilObjSurveyQuestionPool::toXML (   $questions)

export questions to xml

Definition at line 695 of file class.ilObjSurveyQuestionPool.php.

References SurveyQuestion\_includeClass(), ilObject\getId(), getOnline(), getQuestions(), getQuestiontype(), getTitle(), ilObject\getType(), and ilXmlWriter\xmlHeader().

{
if (!is_array($questions))
{
$questions =& $this->getQuestions();
}
if (count($questions) == 0)
{
$questions =& $this->getQuestions();
}
$xml = "";
include_once("./Services/Xml/classes/class.ilXmlWriter.php");
$a_xml_writer = new ilXmlWriter;
// set xml header
$a_xml_writer->xmlHeader();
$attrs = array(
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
);
$a_xml_writer->xmlStartTag("surveyobject", $attrs);
$attrs = array(
"id" => "qpl_" . $this->getId(),
"label" => $this->getTitle(),
"online" => $this->getOnline()
);
$a_xml_writer->xmlStartTag("surveyquestions", $attrs);
$a_xml_writer->xmlElement("dummy", NULL, "dummy");
// add ILIAS specific metadata
$a_xml_writer->xmlStartTag("metadata");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
include_once "./Services/MetaData/classes/class.ilMD.php";
$md = new ilMD($this->getId(),0, $this->getType());
$writer = new ilXmlWriter();
$md->toXml($writer);
$metadata = $writer->xmlDumpMem();
$a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlEndTag("metadata");
$a_xml_writer->xmlEndTag("surveyquestions");
$a_xml_writer->xmlEndTag("surveyobject");
$xml = $a_xml_writer->xmlDumpMem(FALSE);
$questionxml = "";
foreach ($questions as $key => $value)
{
$questiontype = $this->getQuestiontype($value);
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question = new $questiontype();
$question->loadFromDb($value);
$questionxml .= $question->toXML(false);
}
$xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
return $xml;
}

+ Here is the call graph for this function:

ilObjSurveyQuestionPool::update ( )

update object data

public

Returns
boolean

Reimplemented from ilObject.

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

References ilObject\updateMetaData().

{
$this->updateMetaData();
if (!parent::update())
{
return false;
}
// put here object specific stuff
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilObjSurveyQuestionPool::$online

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

Referenced by getOnline().


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