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

Class ilPCQuestion. More...

+ Inheritance diagram for ilPCQuestion:
+ Collaboration diagram for ilPCQuestion:

Public Member Functions

 init ()
 Init page content component.
 setNode (&$a_node)
 Set node.
 setQuestionReference ($a_questionreference)
 Set Question Reference.
 getQuestionReference ()
 Get Question Reference.
 create (&$a_pg_obj, $a_hier_id)
 Create Question Element.
 copyPoolQuestionIntoPage ($a_q_id, $a_hier_id)
 Copy question from pool into page.
 _getPageForQuestionId ($a_q_id, $a_parent_type="")
 Get page for question id.
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor.
 setPage ($a_val)
 Set page.
 getPage ()
 Get page.
 getType ()
 Get type of page content.
& getNode ()
 Get xml node of page content.
 getJavascriptFiles ()
 Get Javascript files.
 getCssFiles ()
 Get css files.
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure.
 getHierId ()
 Get hierarchical id.
 lookupHierId ()
 Get hierarchical id from dom.
 readHierId ()
 Read PC Id.
 setPcId ($a_pcid)
 Set PC Id.
 getPCId ()
 Get PC Id.
 readPCId ()
 Read PC Id.
 writePCId ($a_pc_id)
 Write pc id.
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b.
 setEnabled ($value)
 Set Enabled value for page content component.
 enable ()
 Enable page content.
 disable ()
 Disable page content.
 isEnabled ()
 Check whether page content is enabled.
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element)
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl.

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing.
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created)
static beforePageDelete ($a_page)
 Before page is being deleted.
static _getQuestionIdsForPage ($a_parent_type, $a_page_id, $a_lang="-")
 Get all questions of a page.
- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number)
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number)
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container.
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order.
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content.
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created.

Data Fields

 $dom
 $q_node
- Data Fields inherited from ilPageContent
 $hier_id
 $node
 $dom

Additional Inherited Members

- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type.

Detailed Description

Class ilPCQuestion.

Assessment Question of ilPageObject

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilPCQuestion.php 48980 2014-03-25 20:11:29Z akill

Definition at line 18 of file class.ilPCQuestion.php.

Member Function Documentation

ilPCQuestion::_getPageForQuestionId (   $a_q_id,
  $a_parent_type = "" 
)

Get page for question id.

Parameters
@returnarray

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

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM page_question ".
" WHERE question_id = ".$ilDB->quote($a_q_id, "integer")
);
while ($rec = $ilDB->fetchAssoc($set))
{
if ($a_parent_type == "" || $rec["page_parent_type"] == $a_parent_type)
{
return array("page_id" => $rec["page_id"], "parent_type" => $rec["page_parent_type"]);
}
}
return false;
}

+ Here is the caller graph for this function:

static ilPCQuestion::_getQuestionIdsForPage (   $a_parent_type,
  $a_page_id,
  $a_lang = "-" 
)
static

Get all questions of a page.

Definition at line 212 of file class.ilPCQuestion.php.

References $res.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects(), ilObjContentObject\exportHTMLPages(), ilSCORM2004Asset\exportPDFPrepareXmlNFiles(), ilSCORM2004Asset\exportXMLPageObjects(), ilObjectivesAlignmentTableGUI\fillRow(), ilLMPageObject\getQuestionIds(), and ilSCORM2004ScoGUI\sahs_questions().

{
global $ilDB;
$res = $ilDB->queryF("SELECT * FROM page_question WHERE page_parent_type = %s ".
" AND page_id = %s AND page_lang = %s",
array("text", "integer", "text"),
array($a_parent_type, $a_page_id, $a_lang));
$q_ids = array();
while ($rec = $ilDB->fetchAssoc($res))
{
$q_ids[] = $rec["question_id"];
}
return $q_ids;
}

+ Here is the caller graph for this function:

static ilPCQuestion::afterPageUpdate (   $a_page,
DOMDocument  $a_domdoc,
  $a_xml,
  $a_creation 
)
static

After page has been updated (or created)

Parameters
objectpage object
DOMDocument$a_domdocdom document
stringxml
booltrue on creation, otherwise false

Reimplemented from ilPageContent.

Definition at line 158 of file class.ilPCQuestion.php.

References ilPageContent\$node, ilInternalLink\_extractInstOfTarget(), and ilInternalLink\_extractObjIdOfTarget().

{
global $ilDB;
include_once("./Services/COPage/classes/class.ilInternalLink.php");
$ilDB->manipulateF("DELETE FROM page_question WHERE page_parent_type = %s ".
" AND page_id = %s AND page_lang = %s", array("text", "integer", "text"),
array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage()));
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query('//Question');
$q_ids = array();
foreach ($nodes as $node)
{
$q_ref = $node->getAttribute("QRef");
if (!($inst_id > 0))
{
if ($q_id > 0)
{
$q_ids[$q_id] = $q_id;
}
}
}
foreach($q_ids as $qid)
{
$ilDB->manipulateF("INSERT INTO page_question (page_parent_type, page_id, page_lang, question_id)".
" VALUES (%s,%s,%s,%s)",
array("text", "integer", "text", "integer"),
array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $qid));
}
}

+ Here is the call graph for this function:

static ilPCQuestion::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
objectpage object

Reimplemented from ilPageContent.

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

{
global $ilDB;
$ilDB->manipulateF("DELETE FROM page_question WHERE page_parent_type = %s ".
" AND page_id = %s AND page_lang = %s", array("text", "integer", "text"),
array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage()));
}
ilPCQuestion::copyPoolQuestionIntoPage (   $a_q_id,
  $a_hier_id 
)

Copy question from pool into page.

Parameters
@return

Definition at line 85 of file class.ilPCQuestion.php.

References $t, assQuestion\_instanciateQuestion(), assQuestionGUI\getSelfAssessmentTags(), and ilUtil\secureString().

{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
$question = assQuestion::_instanciateQuestion($a_q_id);
$duplicate_id = $question->copyObject(0, $question->getTitle());
$duplicate = assQuestion::_instanciateQuestion($duplicate_id);
$duplicate->setObjId(0);
// we remove everything not supported by the non-tiny self
// assessment question editor
$q = $duplicate->getQuestion();
// we try to save all latex tags
$try = true;
$ls = '<span class="latex">';
$le = '</span>';
while ($try)
{
// search position of start tag
$pos1 = strpos($q, $ls);
if (is_int($pos1))
{
$pos2 = strpos($q, $le, $pos1);
if (is_int($pos2))
{
// both found: replace end tag
$q = substr($q, 0, $pos2)."[/tex]".substr($q, $pos2+7);
$q = substr($q, 0, $pos1)."[tex]".substr($q, $pos1+20);
}
else
{
$try = false;
}
}
else
{
$try = false;
}
}
$tstr = "";
foreach ($tags as $t)
{
$tstr.="<".$t.">";
}
$q = ilUtil::secureString($q, true, $tstr);
// self assessment uses nl2br, not p
$duplicate->setQuestion($q);
$duplicate->saveQuestionDataToDb();
$this->q_node->set_attribute("QRef", "il__qst_".$duplicate_id);
}

+ Here is the call graph for this function:

ilPCQuestion::create ( &  $a_pg_obj,
  $a_hier_id 
)

Create Question Element.

Definition at line 70 of file class.ilPCQuestion.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

{
$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER);
$this->q_node = $this->dom->create_element("Question");
$this->q_node = $this->node->append_child($this->q_node);
$this->q_node->set_attribute("QRef", "");
}

+ Here is the call graph for this function:

static ilPCQuestion::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

Definition at line 145 of file class.ilPCQuestion.php.

{
return array("ed_insert_pcqst", "empty_question", "pc_qst");
}
ilPCQuestion::getQuestionReference ( )

Get Question Reference.

Returns
string Question Reference

Definition at line 58 of file class.ilPCQuestion.php.

{
if (is_object($this->q_node))
{
return $this->q_node->get_attribute("QRef", $a_questionreference);
}
return false;
}
ilPCQuestion::init ( )

Init page content component.

Reimplemented from ilPageContent.

Definition at line 26 of file class.ilPCQuestion.php.

References ilPageContent\setType().

{
$this->setType("pcqst");
}

+ Here is the call graph for this function:

ilPCQuestion::setNode ( &  $a_node)

Set node.

Reimplemented from ilPageContent.

Definition at line 34 of file class.ilPCQuestion.php.

{
parent::setNode($a_node); // this is the PageContent node
$this->q_node =& $a_node->first_child(); //... and this the Question
}
ilPCQuestion::setQuestionReference (   $a_questionreference)

Set Question Reference.

Parameters
string$a_questionreferenceQuestion Reference

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

{
if (is_object($this->q_node))
{
$this->q_node->set_attribute("QRef", $a_questionreference);
}
}

Field Documentation

ilPCQuestion::$dom

Definition at line 20 of file class.ilPCQuestion.php.

ilPCQuestion::$q_node

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


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