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 questionpool 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
 isInUse ($question_id)
 assign a meta data object to glossary object
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
 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.
 _isWriteable ($object_id, $user_id)
 Returns true, if the question pool is writeable by a given user.
getQuestionDetails ($question_ids)
 Returns an array containing the qpl_question and qpl_question_type fields for an array of question ids.
getDeleteableQuestionDetails ($question_ids)
 Returns an array containing the qpl_question and qpl_question_type fields of deleteable questions for an array of question ids.
getUsedQuestionDetails ($question_ids)
 Returns an array containing the qpl_question and qpl_question_type fields of questions which are used in a random test for an array of question ids.

Detailed Description

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


Member Function Documentation

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

References ilObject::$ilias, ilUtil::getDataDir(), and ilUtil::makeDir().

Referenced by ilObjQuestionPoolGUI::uploadQplObject().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjQuestionPool::_getImportDirectory (  ) 

get import directory of lm

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

References ilUtil::getDataDir().

Referenced by ilObjQuestionPoolGUI::importVerifiedFileObject(), and ilObjQuestionPoolGUI::uploadQplObject().

        {
                $import_dir = ilUtil::getDataDir()."/qpl_data/qpl_import";
                if(@is_dir($import_dir))
                {
                        return $import_dir;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 1110 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::_isWriteable ( object_id,
user_id 
)

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

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

Parameters:
integer $object_id The object id of the question pool
integer $user_id The database id of the user public

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

References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().

        {
                global $rbacsystem;
                global $ilDB;
                
                $result_array = array();
                $query = sprintf("SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.obj_id = %s",
                        $ilDB->quote($object_id . "")
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {               
                        include_once "./classes/class.ilObject.php";
                        if ($rbacsystem->checkAccess("write", $row["ref_id"]) && (ilObject::_hasUntrashedReference($row["obj_id"])))
                        {
                                return true;
                        }
                }
                return false;
        }

Here is the call graph for this function:

ilObjQuestionPool::create ( a_upload = false  ) 

create questionpool object

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

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

        {
                parent::create();
                
                // meta data will be created by
                // import parser
                if (!$a_upload)
                {
                        $this->createMetaData();
                }
        }

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 822 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::createQuestion ( question_type,
question_id = -1 
)

Definition at line 460 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 147 of file class.ilObjQuestionPool.php.

References ilObject::deleteMetaData(), and deleteQuestionpool().

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

                // delete meta data
                $this->deleteMetaData();

                //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 295 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 164 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 520 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 804 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 653 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 786 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 697 of file class.ilObjQuestionPool.php.

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

Referenced by exportPagesXML().

        {
                include_once("Services/MetaData/classes/class.ilMD2XML.php");
                $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
                $md2xml->setExportMode(true);
                $md2xml->startExport();
                $a_xml_writer->appendXML($md2xml->getXML());
        }

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 723 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 955 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 AND complete = %s",
                        $this->ilias->db->quote($this->getId()),
                        $this->ilias->db->quote("1")
                );
                $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::getDeleteableQuestionDetails ( question_ids  ) 

Returns an array containing the qpl_question and qpl_question_type fields of deleteable questions for an array of question ids.

Returns an array containing the qpl_question and qpl_question_type fields of deleteable questions for an array of question ids

Parameters:
array $question_ids An array containing the question ids
Returns:
array An array containing the details of the requested questions public

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

References $query, $result, $row, and ASS_Question::_isUsedInRandomTest().

        {
                global $ilDB;
                
                $result = array();
                $whereclause = join($question_ids, " OR qpl_questions.question_id = ");
                $whereclause = " AND (qpl_questions.question_id = " . $whereclause . ")";
                $query = "SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id$whereclause ORDER BY qpl_questions.title";
                $query_result = $ilDB->query($query);
                if ($query_result->numRows())
                {
                        include_once "./assessment/classes/class.assQuestion.php";
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                if (!ASS_Question::_isUsedInRandomTest($row["question_id"]))
                                {
                                        array_push($result, $row);
                                }
                        }
                }
                return $result;
        }

Here is the call graph for this function:

ilObjQuestionPool::getDescription (  ) 

get description of content object

Returns:
string description

Reimplemented from ilObject.

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

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

ilObjQuestionPool::getExportDirectory (  ) 

get export directory of questionpool

Definition at line 851 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 861 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 942 of file class.ilObjQuestionPool.php.

References ilUtil::getDataDir().

        {
                $import_dir = ilUtil::getDataDir()."/qpl_data/qpl_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 977 of file class.ilObjQuestionPool.php.

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

& ilObjQuestionPool::getQuestionDetails ( question_ids  ) 

Returns an array containing the qpl_question and qpl_question_type fields for an array of question ids.

Returns an array containing the qpl_question and qpl_question_type fields for an array of question ids

Parameters:
array $question_ids An array containing the question ids
Returns:
array An array containing the details of the requested questions public

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

References $query, $result, and $row.

        {
                global $ilDB;
                
                $result = array();
                $whereclause = join($question_ids, " OR qpl_questions.question_id = ");
                $whereclause = " AND (qpl_questions.question_id = " . $whereclause . ")";
                $query = "SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id$whereclause ORDER BY qpl_questions.title";
                $query_result = $ilDB->query($query);
                if ($query_result->numRows())
                {
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($result, $row);
                        }
                }
                return $result;
        }

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 541 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 310 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 357 of file class.ilObjQuestionPool.php.

        {
                return parent::getTitle();
        }

& ilObjQuestionPool::getUsedQuestionDetails ( question_ids  ) 

Returns an array containing the qpl_question and qpl_question_type fields of questions which are used in a random test for an array of question ids.

Returns an array containing the qpl_question and qpl_question_type fields of questions which are used in a random test for an array of question ids

Parameters:
array $question_ids An array containing the question ids
Returns:
array An array containing the details of the requested questions public

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

References $query, $result, $row, and ASS_Question::_isUsedInRandomTest().

        {
                global $ilDB;
                
                $result = array();
                $whereclause = join($question_ids, " OR qpl_questions.question_id = ");
                $whereclause = " AND (qpl_questions.question_id = " . $whereclause . ")";
                $query = "SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_type_fi = qpl_question_type.question_type_id$whereclause ORDER BY qpl_questions.title";
                $query_result = $ilDB->query($query);
                if ($query_result->numRows())
                {
                        include_once "./assessment/classes/class.assQuestion.php";
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                if (ASS_Question::_isUsedInRandomTest($row["question_id"]))
                                {
                                        array_push($result, $row);
                                }
                        }
                }
                return $result;
        }

Here is the call 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 118 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 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 1017 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);
                                                        }
                                                }
                                        }
                                }
                        }
                }
                else
                {
                        return FALSE;
                }
                return TRUE;
        }

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 204 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::isInUse ( question_id  ) 

assign a meta data object to glossary object

Parameters:
object $a_meta_data meta data object get meta data object of glossary object
Returns:
object meta data object init meta data object if needed update meta data only 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 449 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 706 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 234 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 105 of file class.ilObjQuestionPool.php.

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

ilObjQuestionPool::setDescription ( a_description  ) 

set description of content object

Reimplemented from ilObject.

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

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

ilObjQuestionPool::setTitle ( a_title  ) 

set title of glossary object

Reimplemented from ilObject.

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

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

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 998 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.

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:


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