Public Member Functions

ilObjQuestionPool Class Reference

Inheritance diagram for ilObjQuestionPool:
Collaboration diagram for ilObjQuestionPool:

Public Member Functions

 ilObjQuestionPool ($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
 ilClone ($a_parent_ref)
 copy all entries of your object.
 delete ()
 delete object and all related data
 deleteQuestionpool ()
 initDefaultRoles ()
 init default roles settings
 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.
 deleteQuestion ($question_id)
 Deletes a question from the question pool.
 getQuestiontype ($question_id)
 Returns the question type of a question with a given id.
 getDescription ()
 get description of content object
 setDescription ($a_description)
 set description of content object
 getTitle ()
 get title of glossary object
 setTitle ($a_title)
 set title of glossary object
 assignMetaData (&$a_meta_data)
 assign a meta data object to glossary object
getMetaData ()
 get meta data object of glossary object
 initMeta ()
 init meta data object if needed
 updateMetaData ()
 update meta data only
 isInUse ($question_id)
 Checks whether the question is in use or not.
createQuestion ($question_type, $question_id=-1)
 duplicateQuestion ($question_id)
 Duplicates a question for a questionpool.
 getQuestionsTable ($sortoptions, $filter_text, $sel_filter_type, $startrow=0)
 Calculates the data for the output of the questionpool.
 exportPagesXML (&$a_xml_writer, $a_inst, $a_target_dir, &$expLog, $questions)
 export pages of test to xml (see ilias_co.dtd)
 exportXMLMetaData (&$a_xml_writer)
 export content objects meta data to xml (see ilias_co.dtd)
 modifyExportIdentifier ($a_tag, $a_param, $a_value)
 exportXMLPageObjects (&$a_xml_writer, $a_inst, &$expLog, $questions)
 export page objects to xml (see ilias_co.dtd)
 exportXMLMediaObjects (&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
 export media objects to xml (see ilias_co.dtd)
 exportFileItems ($a_target_dir, &$expLog)
 export files of file itmes
 createExportDirectory ()
 creates data directory for export files (data_dir/qpl_data/qpl_<id>/export, depending on data directory that is set in ILIAS setup/ini)
 getExportDirectory ()
 get export directory of questionpool
 getExportFiles ($dir)
 get export files
 createImportDirectory ()
 creates data directory for import files (data_dir/qpl_data/qpl_<id>/import, depending on data directory that is set in ILIAS setup/ini)
 getImportDirectory ()
 get import directory of lm
getAllQuestionIds ()
 getImportMapping ()
 get array of (two) new created questions for import id
 to_xml ($questions)
 Returns a QTI xml representation of a list of questions.
 importObject ($source)
 _getQuestionCount ($questionpool_id, $complete_questions_only=FALSE)
 Returns the number of questions in a question pool.

Detailed Description

Definition at line 45 of file class.ilObjQuestionPool.php.


Member Function Documentation

ilObjQuestionPool::_getQuestionCount ( questionpool_id,
complete_questions_only = FALSE 
)

Returns the number of questions in a question pool.

Returns the number of questions in a question pool

Parameters:
integer $questonpool_id Object id of the questionpool to examine
boolean $complete_questions_only If set to TRUE, returns only the number of complete questions in the questionpool. Default is FALSE
Returns:
integer The number of questions in the questionpool object public

Definition at line 1145 of file class.ilObjQuestionPool.php.

References $query, $result, and $row.

Referenced by ilObjTestGUI::randomQuestionsObject(), and ilObjTest::saveRandomQuestionpools().

        {
                global $ilDB;
                $query = sprintf("SELECT COUNT(question_id) AS question_count FROM qpl_questions WHERE obj_fi = %s AND ISNULL(original_id)",
                        $ilDB->quote($questionpool_id . "")
                );
                if ($complete_questions_only)
                {
                        $query .= " AND complete = '1'";
                }
                $result = $ilDB->query($query);
                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                return $row["question_count"];
        }

Here is the caller graph for this function:

ilObjQuestionPool::assignMetaData ( &$  a_meta_data  ) 

assign a meta data object to glossary object

Parameters:
object $a_meta_data meta data object

Definition at line 435 of file class.ilObjQuestionPool.php.

Referenced by ilObjQuestionPool(), and initMeta().

        {
                $this->meta_data =& $a_meta_data;
        }

Here is the caller graph for this function:

ilObjQuestionPool::create ( a_upload = false  ) 

create question pool object

Definition at line 67 of file class.ilObjQuestionPool.php.

References ilObject::create(), getDescription(), ilObject::getId(), getTitle(), and ilObject::getType().

        {
                parent::create();
                if (!$a_upload)
                {
                        $this->meta_data->setId($this->getId());
                        $this->meta_data->setType($this->getType());
                        $this->meta_data->setTitle($this->getTitle());
                        $this->meta_data->setDescription($this->getDescription());
                        $this->meta_data->setObject($this);
                        $this->meta_data->create();
                }
        }

Here is the call graph for this function:

ilObjQuestionPool::createExportDirectory (  ) 

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

Definition at line 873 of file class.ilObjQuestionPool.php.

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

        {
                $qpl_data_dir = ilUtil::getDataDir()."/qpl_data";
                ilUtil::makeDir($qpl_data_dir);
                if(!is_writable($qpl_data_dir))
                {
                        $this->ilias->raiseError("Questionpool Data Directory (".$qpl_data_dir
                                .") not writeable.",$this->ilias->error_obj->FATAL);
                }
                
                // create learning module directory (data_dir/lm_data/lm_<id>)
                $qpl_dir = $qpl_data_dir."/qpl_".$this->getId();
                ilUtil::makeDir($qpl_dir);
                if(!@is_dir($qpl_dir))
                {
                        $this->ilias->raiseError("Creation of Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
                }
                // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
                $export_dir = $qpl_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:

ilObjQuestionPool::createImportDirectory (  ) 

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

Definition at line 952 of file class.ilObjQuestionPool.php.

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

        {
                $qpl_data_dir = ilUtil::getDataDir()."/qpl_data";
                ilUtil::makeDir($qpl_data_dir);
                
                if(!is_writable($qpl_data_dir))
                {
                        $this->ilias->raiseError("Questionpool Data Directory (".$qpl_data_dir
                                .") not writeable.",$this->ilias->error_obj->FATAL);
                }

                // create questionpool directory (data_dir/qpl_data/qpl_<id>)
                $qpl_dir = $qpl_data_dir."/qpl_".$this->getId();
                ilUtil::makeDir($qpl_dir);
                if(!@is_dir($qpl_dir))
                {
                        $this->ilias->raiseError("Creation of Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
                }

                // create import subdirectory (data_dir/qpl_data/qpl_<id>/import)
                $import_dir = $qpl_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:

& ilObjQuestionPool::createQuestion ( question_type,
question_id = -1 
)

Definition at line 512 of file class.ilObjQuestionPool.php.

References getQuestiontype().

Referenced by duplicateQuestion(), and to_xml().

        {
                if ((!$question_type) and ($question_id > 0))
                {
                        $question_type = $this->getQuestiontype($question_id);
                }

                switch ($question_type)
                {
                        case "qt_multiple_choice_sr":
                                $question =& new ASS_MultipleChoiceGUI();
                                $question->object->set_response(RESPONSE_SINGLE);
                                break;

                        case "qt_multiple_choice_mr":
                                $question =& new ASS_MultipleChoiceGUI();
                                $question->object->set_response(RESPONSE_MULTIPLE);
                                break;

                        case "qt_cloze":
                                $question =& new ASS_ClozeTestGUI();
                                break;

                        case "qt_matching":
                                $question =& new ASS_MatchingQuestionGUI();
                                break;

                        case "qt_ordering":
                                $question =& new ASS_OrderingQuestionGUI();
                                break;

                        case "qt_imagemap":
                                $question =& new ASS_ImagemapQuestionGUI();
                                break;

                        case "qt_javaapplet":
                                $question =& new ASS_JavaAppletGUI();
                                break;

                        case "qt_text":
                                $question =& new ASS_TextQuestionGUI();
                                break;
                }

                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:

ilObjQuestionPool::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 146 of file class.ilObjQuestionPool.php.

References deleteQuestionpool().

        {
                // always call parent delete function first!!
                if (!parent::delete())
                {
                        return false;
                }

                //put here your module specific stuff
                $this->deleteQuestionpool();

                return true;
        }

Here is the call graph for this function:

ilObjQuestionPool::deleteQuestion ( question_id  ) 

Deletes a question from the question pool.

Deletes a question from the question pool

Parameters:
integer $question_id The database id of the question private

Definition at line 291 of file class.ilObjQuestionPool.php.

Referenced by deleteQuestionpool().

        {
                $question = new ASS_Question();
                $question->delete($question_id);
        }

Here is the caller graph for this function:

ilObjQuestionPool::deleteQuestionpool (  ) 

Definition at line 160 of file class.ilObjQuestionPool.php.

References $query, $result, $row, deleteQuestion(), ilUtil::getDataDir(), and ilObject::getId().

Referenced by delete().

        {
                $query = sprintf("SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND original_id IS NULL",
                        $this->ilias->db->quote($this->getId()));

                $result = $this->ilias->db->query($query);
                $questions = array();

                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($questions, $row["question_id"]);
                }

                if (count($questions))
                {
                        foreach ($questions as $question_id)
                        {
                                $this->deleteQuestion($question_id);
                        }
                }

                // delete export files
                $qpl_data_dir = ilUtil::getDataDir()."/qpl_data";
                $directory = $qpl_data_dir."/qpl_".$this->getId();
                if (is_dir($directory))
                {
                        $directory = escapeshellarg($directory);
                        exec("rm -rf $directory");
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjQuestionPool::duplicateQuestion ( question_id  ) 

Duplicates a question for a questionpool.

Duplicates a question for a questionpool

Parameters:
integer $question_id The database id of the question public

Definition at line 572 of file class.ilObjQuestionPool.php.

References $counter, $ilUser, and createQuestion().

        {
                global $ilUser;

                $question =& $this->createQuestion("", $question_id);
                $counter = 2;
                while ($question->object->questionTitleExists($question->object->getTitle() . " ($counter)"))
                {
                        $counter++;
                }

                $question->object->duplicate(false, $question->object->getTitle() . " ($counter)", $ilUser->fullname, $ilUser->id);
        }

Here is the call graph for this function:

ilObjQuestionPool::exportFileItems ( a_target_dir,
&$  expLog 
)

export files of file itmes

Definition at line 855 of file class.ilObjQuestionPool.php.

References $file_obj.

Referenced by exportPagesXML().

        {
                include_once("classes/class.ilObjFile.php");

                foreach ($this->file_ids as $file_id)
                {
                        $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
                        $file_obj = new ilObjFile($file_id, false);
                        $file_obj->export($a_target_dir);
                        unset($file_obj);
                }
        }       

Here is the caller graph for this function:

ilObjQuestionPool::exportPagesXML ( &$  a_xml_writer,
a_inst,
a_target_dir,
&$  expLog,
questions 
)

export pages of test to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 705 of file class.ilObjQuestionPool.php.

References $ilBench, exportFileItems(), exportXMLMediaObjects(), exportXMLMetaData(), and exportXMLPageObjects().

        {
                global $ilBench;
                
                $this->mob_ids = array();
                $this->file_ids = array();

                $attrs = array();
                $attrs["Type"] = "Questionpool_Test";
                $a_xml_writer->xmlStartTag("ContentObject", $attrs);

                // MetaData
                $this->exportXMLMetaData($a_xml_writer);

                // PageObjects
                $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects");
                $ilBench->start("ContentObjectExport", "exportPageObjects");
                $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog, $questions);
                $ilBench->stop("ContentObjectExport", "exportPageObjects");
                $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects");

                // MediaObjects
                $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
                $ilBench->start("ContentObjectExport", "exportMediaObjects");
                $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
                $ilBench->stop("ContentObjectExport", "exportMediaObjects");
                $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");

                // FileItems
                $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
                $ilBench->start("ContentObjectExport", "exportFileItems");
                $this->exportFileItems($a_target_dir, $expLog);
                $ilBench->stop("ContentObjectExport", "exportFileItems");
                $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");

                $a_xml_writer->xmlEndTag("ContentObject");
        }

Here is the call graph for this function:

ilObjQuestionPool::exportXMLMediaObjects ( &$  a_xml_writer,
a_inst,
a_target_dir,
&$  expLog 
)

export media objects to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 837 of file class.ilObjQuestionPool.php.

Referenced by exportPagesXML().

        {
                include_once("content/classes/Media/class.ilObjMediaObject.php");

                foreach ($this->mob_ids as $mob_id)
                {
                        $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
                        $media_obj = new ilObjMediaObject($mob_id);
                        $media_obj->exportXML($a_xml_writer, $a_inst);
                        $media_obj->exportFiles($a_target_dir);
                        unset($media_obj);
                }
        }

Here is the caller graph for this function:

ilObjQuestionPool::exportXMLMetaData ( &$  a_xml_writer  ) 

export content objects meta data to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 749 of file class.ilObjQuestionPool.php.

References ilObject::getType().

Referenced by exportPagesXML().

        {
                $nested = new ilNestedSetXML();
                $nested->setParameterModifier($this, "modifyExportIdentifier");
                $a_xml_writer->appendXML($nested->export($this->getId(),
                        $this->getType()));
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjQuestionPool::exportXMLPageObjects ( &$  a_xml_writer,
a_inst,
&$  expLog,
questions 
)

export page objects to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 774 of file class.ilObjQuestionPool.php.

References $ilBench, and $xml.

Referenced by exportPagesXML().

        {
                global $ilBench;

                include_once "./content/classes/class.ilLMPageObject.php";

                foreach ($questions as $question_id)
                {
                        $ilBench->start("ContentObjectExport", "exportPageObject");
                        $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$question_id);

                        $attrs = array();
                        $a_xml_writer->xmlStartTag("PageObject", $attrs);

                        
                        // export xml to writer object
                        $ilBench->start("ContentObjectExport", "exportPageObject_XML");
                        $page_object = new ilPageObject("qpl", $question_id);
                        $page_object->buildDom();
                        $page_object->insertInstIntoIDs($a_inst);
                        $mob_ids = $page_object->collectMediaObjects(false);
                        $file_ids = $page_object->collectFileItems();
                        $xml = $page_object->getXMLFromDom(false, false, false, "", true);
                        $xml = str_replace("&","&amp;", $xml);
                        $a_xml_writer->appendXML($xml);
                        $page_object->freeDom();
                        unset ($page_object);
                        
                        $ilBench->stop("ContentObjectExport", "exportPageObject_XML");

                        // collect media objects
                        $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia");
                        //$mob_ids = $page_obj->getMediaObjectIDs();
                        foreach($mob_ids as $mob_id)
                        {
                                $this->mob_ids[$mob_id] = $mob_id;
                        }
                        $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia");

                        // collect all file items
                        $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems");
                        //$file_ids = $page_obj->getFileItemIds();
                        foreach($file_ids as $file_id)
                        {
                                $this->file_ids[$file_id] = $file_id;
                        }
                        $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems");
                        
                        $a_xml_writer->xmlEndTag("PageObject");
                        //unset($page_obj);

                        $ilBench->stop("ContentObjectExport", "exportPageObject");
                        

                }
        }

Here is the caller graph for this function:

& ilObjQuestionPool::getAllQuestionIds (  ) 

Definition at line 997 of file class.ilObjQuestionPool.php.

References $query, and $row.

        {
                $query = sprintf("SELECT question_id FROM qpl_questions WHERE ISNULL(original_id) AND obj_fi = %s",
                        $this->ilias->db->quote($this->getId())
                );
                $query_result = $this->ilias->db->query($query);
                $questions = array();
                if ($query_result->numRows())
                {
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($questions, $row["question_id"]);
                        }
                }
                return $questions;
        }

ilObjQuestionPool::getDescription (  ) 

get description of content object

Returns:
string description

Reimplemented from ilObject.

Definition at line 396 of file class.ilObjQuestionPool.php.

Referenced by create().

        {
                return parent::getDescription();
                //return $this->meta_data->getDescription();
        }

Here is the caller graph for this function:

ilObjQuestionPool::getExportDirectory (  ) 

get export directory of questionpool

Definition at line 902 of file class.ilObjQuestionPool.php.

References ilUtil::getDataDir().

        {
                $export_dir = ilUtil::getDataDir()."/qpl_data"."/qpl_".$this->getId()."/export";

                return $export_dir;
        }

Here is the call graph for this function:

ilObjQuestionPool::getExportFiles ( dir  ) 

get export files

Definition at line 912 of file class.ilObjQuestionPool.php.

References $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 != "." and
                                $entry != ".." and
                                substr($entry, -4) == ".zip" and
                                ereg("^[0-9]{10}_{2}[0-9]+_{2}(qpl__)*[0-9]+\.zip\$", $entry))
                        {
                                $file[] = $entry;
                        }
                }

                // close import directory
                $dir->close();

                // sort files
                sort ($file);
                reset ($file);
                return $file;
        }

ilObjQuestionPool::getImportDirectory (  ) 

get import directory of lm

Definition at line 983 of file class.ilObjQuestionPool.php.

References ilUtil::getDataDir().

        {
                $import_dir = ilUtil::getDataDir()."/qpl_data".
                        "/qpl_".$this->getId()."/import";
                if(@is_dir($import_dir))
                {
                        return $import_dir;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

ilObjQuestionPool::getImportMapping (  ) 

get array of (two) new created questions for import id

Definition at line 1018 of file class.ilObjQuestionPool.php.

        {
                if (!is_array($this->import_mapping))
                {
                        return array();
                }
                else
                {
                        return $this->import_mapping;
                }
        }

& ilObjQuestionPool::getMetaData (  ) 

get meta data object of glossary object

Returns:
object meta data object

Definition at line 445 of file class.ilObjQuestionPool.php.

        {
                return $this->meta_data;
        }

ilObjQuestionPool::getQuestionsTable ( sortoptions,
filter_text,
sel_filter_type,
startrow = 0 
)

Calculates the data for the output of the questionpool.

Calculates the data for the output of the questionpool

public

Definition at line 593 of file class.ilObjQuestionPool.php.

References $ilUser, $query, $row, ilObject::getId(), and ilUtil::getImagePath().

        {
                global $ilUser;
                $where = "";
                if (strlen($filter_text) > 0)
                {
                        switch($sel_filter_type)
                        {
                                case "title":
                                        $where = " AND qpl_questions.title LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
                                        break;

                                case "comment":
                                        $where = " AND qpl_questions.comment LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
                                        break;

                                case "author":
                                        $where = " AND qpl_questions.author LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
                                        break;
                        }
                }

            // build sort order for sql query
                $order = "";
                $images = array();
                if (count($sortoptions))
                {
                        foreach ($sortoptions as $key => $value)
                        {
                                switch($key)
                                {
                                        case "title":
                                                $order = " ORDER BY title $value";
                                                $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
                                        case "comment":
                                                $order = " ORDER BY comment $value";
                                                $images["comment"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
                                        case "type":
                                                $order = " ORDER BY question_type_id $value";
                                                $images["type"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
                                        case "author":
                                                $order = " ORDER BY author $value";
                                                $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
                                        case "created":
                                                $order = " ORDER BY created $value";
                                                $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
                                        case "updated":
                                                $order = " ORDER BY TIMESTAMP14 $value";
                                                $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
                                }
                        }
                }
                $maxentries = $ilUser->prefs["hits_per_page"];
                if ($maxentries < 1)
                {
                        $maxentries = 9999;
                }
                $query = "SELECT qpl_questions.question_id, qpl_questions.TIMESTAMP + 0 AS TIMESTAMP14 FROM qpl_questions, qpl_question_type WHERE ISNULL(qpl_questions.original_id) AND qpl_questions.question_type_fi = qpl_question_type.question_type_id AND qpl_questions.obj_fi = " . $this->getId() . " $where$order$limit";
                $query_result = $this->ilias->db->query($query);
                $max = $query_result->numRows();
                if ($startrow > $max -1)
                {
                        $startrow = $max - ($max % $maxentries);
                }
                else if ($startrow < 0)
                {
                        $startrow = 0;
                }
                $limit = " LIMIT $startrow, $maxentries";
                $query = "SELECT qpl_questions.*, qpl_questions.TIMESTAMP + 0 AS TIMESTAMP14, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE ISNULL(qpl_questions.original_id) AND qpl_questions.question_type_fi = qpl_question_type.question_type_id AND qpl_questions.obj_fi = " . $this->getId() . " $where$order$limit";
                $query_result = $this->ilias->db->query($query);
                $rows = array();
                if ($query_result->numRows())
                {
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($rows, $row);
                        }
                }
                $nextrow = $startrow + $maxentries;
                if ($nextrow > $max - 1)
                {
                        $nextrow = $startrow;
                }
                $prevrow = $startrow - $maxentries;
                if ($prevrow < 0)
                {
                        $prevrow = 0;
                }
                return array(
                        "rows" => $rows,
                        "images" => $images,
                        "startrow" => $startrow,
                        "nextrow" => $nextrow,
                        "prevrow" => $prevrow,
                        "step" => $maxentries,
                        "rowcount" => $max
                );
        }

Here is the call graph for this function:

ilObjQuestionPool::getQuestiontype ( question_id  ) 

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

Returns the question type of a question with a given id

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

Definition at line 306 of file class.ilObjQuestionPool.php.

References $data, $query, and $result.

Referenced by createQuestion().

        {
                if ($question_id < 1)
                {
                        return;
                }

                $query = sprintf("SELECT qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id AND qpl_questions.question_id = %s",
                        $this->ilias->db->quote($question_id));

                $result = $this->ilias->db->query($query);
                if ($result->numRows() == 1)
                {
                        $data = $result->fetchRow(DB_FETCHMODE_OBJECT);
                        return $data->type_tag;
                }
                else
                {
                        return;
                }
        }

Here is the caller graph for this function:

ilObjQuestionPool::getTitle (  ) 

get title of glossary object

Returns:
string title

Reimplemented from ilObject.

Definition at line 416 of file class.ilObjQuestionPool.php.

Referenced by create().

        {
                return parent::getTitle();
        }

Here is the caller graph for this function:

ilObjQuestionPool::ilClone ( a_parent_ref  ) 

copy all entries of your object.

public

Parameters:
integer ref_id of parent object
Returns:
integer new ref id

Reimplemented from ilObject.

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

References $rbacadmin.

        {
                global $rbacadmin;

                // always call parent ilClone function first!!
                $new_ref_id = parent::ilClone($a_parent_ref);

                // get object instance of ilCloned object
                //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);

                // create a local role folder & default roles
                //$roles = $newObj->initDefaultRoles();

                // ...finally assign role to creator of object
                //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");

                // always destroy objects in ilClone method because ilClone() is recursive and creates instances for each object in subtree!
                //unset($newObj);

                // ... and finally always return new reference ID!!
                return $new_ref_id;
        }

ilObjQuestionPool::ilObjQuestionPool ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

Definition at line 53 of file class.ilObjQuestionPool.php.

References assignMetaData(), and ilObject::ilObject().

        {
                $this->type = "qpl";
                $this->ilObject($a_id,$a_call_by_reference);
                if ($a_id == 0)
                {
                        $new_meta =& new ilMetaData();
                        $this->assignMetaData($new_meta);
                }
        }

Here is the call graph for this function:

ilObjQuestionPool::importObject ( source  ) 

Definition at line 1058 of file class.ilObjQuestionPool.php.

References $xml, and ilObject::getId().

        {
                $this->import_mapping = array();
                if (is_file($source))
                {
                        // import file into questionpool
                        $fh = fopen($source, "r") or die("");
                        $xml = fread($fh, filesize($source));
                        fclose($fh) or die("");
                        if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
                        {
                                foreach ($matches[1] as $index => $item)
                                {
                                        // get identifier
                                        if (preg_match("/(<item[^>]*>)/is", $item, $start_tag))
                                        {
                                                if (preg_match("/(ident=\"([^\"]*)\")/is", $start_tag[1], $ident))
                                                {
                                                        $ident = $ident[2];
                                                }
                                        }
                                        $question = "";
                                        $qt = "";
                                        if (preg_match("/<fieldlabel>QUESTIONTYPE<\/fieldlabel>\s*<fieldentry>(.*?)<\/fieldentry>/is", $item, $questiontype))
                                        {
                                                $qt = $questiontype[1];
                                        }
                                        if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
                                        {
                                                $qt = $questiontype[1];
                                        }
                                        if (strlen($qt))
                                        {
                                                switch ($qt)
                                                {
                                                        case CLOZE_TEST_IDENTIFIER:
                                                                $question = new ASS_ClozeTest();
                                                                break;
                                                        case IMAGEMAP_QUESTION_IDENTIFIER:
                                                                $question = new ASS_ImagemapQuestion();
                                                                break;
                                                        case MATCHING_QUESTION_IDENTIFIER:
                                                                $question = new ASS_MatchingQuestion();
                                                                break;
                                                        case MULTIPLE_CHOICE_QUESTION_IDENTIFIER:
                                                                $question = new ASS_MultipleChoice();
                                                                break;
                                                        case ORDERING_QUESTION_IDENTIFIER:
                                                                $question = new ASS_OrderingQuestion();
                                                                break;
                                                        case JAVAAPPLET_QUESTION_IDENTIFIER:
                                                                $question = new ASS_JavaApplet();
                                                                break;
                                                        case TEXT_QUESTION_IDENTIFIER:
                                                                $question = new ASS_TextQuestion();
                                                                break;
                                                }
                                                if ($question)
                                                {
                                                        $question->setObjId($this->getId());
                                                        if ($question->from_xml("<questestinterop>$item</questestinterop>"))
                                                        {
                                                                $question->saveToDb();
                                                                $this->import_mapping[$ident] = array(
                                                                        "pool" => $question->getId(), "test" => 0);
                                                        }
                                                        else
                                                        {
                                                                $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }

Here is the call graph for this function:

ilObjQuestionPool::initDefaultRoles (  ) 

init default roles settings

If your module does not require any default roles, delete this method (For an example how this method is used, look at ilObjForum)

public

Returns:
array object IDs of created local roles.

Reimplemented from ilObject.

Definition at line 200 of file class.ilObjQuestionPool.php.

References $rbacadmin, and $roles.

        {
                global $rbacadmin;

                // create a local role folder
                //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());

                // create moderator role and assign role to rolefolder...
                //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
                //$roles[] = $roleObj->getId();

                //unset($rfoldObj);
                //unset($roleObj);

                return $roles ? $roles : array();
        }

ilObjQuestionPool::initMeta (  ) 

init meta data object if needed

Definition at line 453 of file class.ilObjQuestionPool.php.

References assignMetaData(), ilObject::getId(), and ilObject::getType().

Referenced by updateMetaData().

        {
                if (!is_object($this->meta_data))
                {
                        if ($this->getId())
                        {
                                $new_meta =& new ilMetaData($this->getType(), $this->getId());
                        }       
                        else
                        {
                                $new_meta =& new ilMetaData();
                        }
                        $this->assignMetaData($new_meta);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjQuestionPool::isInUse ( question_id  ) 

Checks whether the question is in use or not.

Checks whether the question is in use or not

Parameters:
integer $question_id The question id of the question to be checked
Returns:
boolean The number of datasets which are affected by the use of the query. public

Definition at line 501 of file class.ilObjQuestionPool.php.

References $query, $result, and $row.

        {
                $query = sprintf("SELECT COUNT(solution_id) AS solution_count FROM tst_solutions WHERE question_fi = %s",
                        $this->ilias->db->quote("$question_id"));

                $result = $this->ilias->db->query($query);
                $row = $result->fetchRow(DB_FETCHMODE_OBJECT);

                return $row->solution_count;
        }

ilObjQuestionPool::modifyExportIdentifier ( a_tag,
a_param,
a_value 
)

Definition at line 757 of file class.ilObjQuestionPool.php.

References ilUtil::insertInstIntoID().

        {
                if ($a_tag == "Identifier" && $a_param == "Entry")
                {
                        $a_value = ilUtil::insertInstIntoID($a_value);
                }

                return $a_value;
        }

Here is the call graph for this function:

ilObjQuestionPool::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:
string event
integer reference id of object where the event occured
array passes optional parameters if required
Returns:
boolean

Reimplemented from ilObject.

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

References $_GET, $tree, 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:

ilObjQuestionPool::read ( a_force_db = false  ) 

read object data from db into object

Parameters:
boolean public

Reimplemented from ilObject.

Definition at line 104 of file class.ilObjQuestionPool.php.

References ilObject::getId(), and ilObject::getType().

        {
                parent::read($a_force_db);
                $this->meta_data =& new ilMetaData($this->getType(), $this->getId());
        }

Here is the call graph for this function:

ilObjQuestionPool::setDescription ( a_description  ) 

set description of content object

Reimplemented from ilObject.

Definition at line 405 of file class.ilObjQuestionPool.php.

Referenced by updateMetaData().

        {
                parent::setDescription($a_description);
                $this->meta_data->setDescription($a_description);
        }

Here is the caller graph for this function:

ilObjQuestionPool::setTitle ( a_title  ) 

set title of glossary object

Reimplemented from ilObject.

Definition at line 424 of file class.ilObjQuestionPool.php.

Referenced by updateMetaData().

        {
                parent::setTitle($a_title);
                $this->meta_data->setTitle($a_title);
        }

Here is the caller graph for this function:

ilObjQuestionPool::to_xml ( questions  ) 

Returns a QTI xml representation of a list of questions.

Returns a QTI xml representation of a list of questions

Parameters:
array $questions An array containing the question ids of the questions
Returns:
string The QTI xml representation of the questions public

Definition at line 1039 of file class.ilObjQuestionPool.php.

References $xml, and createQuestion().

        {
                $xml = "";
                // export button was pressed
                if (count($questions) > 0)
                {
                        foreach ($questions as $key => $value)
                        {
                                $question =& $this->createQuestion("", $value);
                                $xml .= $question->object->to_xml();
                        }
                        if (count($questions) > 1)
                        {
                                $xml = preg_replace("/<\/questestinterop>\s*<.xml.*?>\s*<questestinterop>/", "", $xml);
                        }
                }
                return $xml;
        }

Here is the call graph for this function:

ilObjQuestionPool::update (  ) 

update object data

public

Returns:
boolean

Reimplemented from ilObject.

Definition at line 87 of file class.ilObjQuestionPool.php.

Referenced by updateMetaData().

        {
                if (!parent::update())
                {
                        return false;
                }

                // put here object specific stuff

                return true;
        }

Here is the caller graph for this function:

ilObjQuestionPool::updateMetaData (  ) 

update meta data only

Definition at line 472 of file class.ilObjQuestionPool.php.

References initMeta(), setDescription(), setTitle(), and update().

        {
                $this->initMeta();
                $this->meta_data->update();
                if ($this->meta_data->section != "General")
                {
                        $meta = $this->meta_data->getElement("Title", "General");
                        $this->meta_data->setTitle($meta[0]["value"]);
                        $meta = $this->meta_data->getElement("Description", "General");
                        $this->meta_data->setDescription($meta[0]["value"]);
                }
                else
                {
                        $this->setTitle($this->meta_data->getTitle());
                        $this->setDescription($this->meta_data->getDescription());
                }
                parent::update();
        }

Here is the call graph for this function:


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