ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPCQuestion Class Reference

Class ilPCQuestion. More...

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

Public Member Functions

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

Static Public Member Functions

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

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

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$

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

Member Function Documentation

◆ _getPageForQuestionId()

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

Get page for question id.

Parameters

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

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

236  {
237  global $ilDB;
238 
239  $set = $ilDB->query("SELECT * FROM page_question ".
240  " WHERE question_id = ".$ilDB->quote($a_q_id, "integer")
241  );
242  while ($rec = $ilDB->fetchAssoc($set))
243  {
244  if ($a_parent_type == "" || $rec["page_parent_type"] == $a_parent_type)
245  {
246  return array("page_id" => $rec["page_id"], "parent_type" => $rec["page_parent_type"]);
247  }
248  }
249  return false;
250  }
+ Here is the caller graph for this function:

◆ _getQuestionIdsForPage()

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().

213  {
214  global $ilDB;
215 
216  $res = $ilDB->queryF("SELECT * FROM page_question WHERE page_parent_type = %s ".
217  " AND page_id = %s AND page_lang = %s",
218  array("text", "integer", "text"),
219  array($a_parent_type, $a_page_id, $a_lang));
220  $q_ids = array();
221  while ($rec = $ilDB->fetchAssoc($res))
222  {
223  $q_ids[] = $rec["question_id"];
224  }
225 
226  return $q_ids;
227  }
+ Here is the caller graph for this function:

◆ afterPageUpdate()

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

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

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

159  {
160  global $ilDB;
161 
162  include_once("./Services/COPage/classes/class.ilInternalLink.php");
163 
164  $ilDB->manipulateF("DELETE FROM page_question WHERE page_parent_type = %s ".
165  " AND page_id = %s AND page_lang = %s", array("text", "integer", "text"),
166  array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage()));
167 
168  $xpath = new DOMXPath($a_domdoc);
169  $nodes = $xpath->query('//Question');
170  $q_ids = array();
171  foreach ($nodes as $node)
172  {
173  $q_ref = $node->getAttribute("QRef");
174 
175  $inst_id = ilInternalLink::_extractInstOfTarget($q_ref);
176  if (!($inst_id > 0))
177  {
179  if ($q_id > 0)
180  {
181  $q_ids[$q_id] = $q_id;
182  }
183  }
184  }
185  foreach($q_ids as $qid)
186  {
187  $ilDB->manipulateF("INSERT INTO page_question (page_parent_type, page_id, page_lang, question_id)".
188  " VALUES (%s,%s,%s,%s)",
189  array("text", "integer", "text", "integer"),
190  array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $qid));
191  }
192 
193  }
+ Here is the call graph for this function:

◆ beforePageDelete()

static ilPCQuestion::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
objectpage object

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

201  {
202  global $ilDB;
203 
204  $ilDB->manipulateF("DELETE FROM page_question WHERE page_parent_type = %s ".
205  " AND page_id = %s AND page_lang = %s", array("text", "integer", "text"),
206  array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage()));
207  }

◆ copyPoolQuestionIntoPage()

ilPCQuestion::copyPoolQuestionIntoPage (   $a_q_id,
  $a_hier_id 
)

Copy question from pool into page.

Parameters

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

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

86  {
87  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
88  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
89  $question = assQuestion::_instanciateQuestion($a_q_id);
90  $duplicate_id = $question->copyObject(0, $question->getTitle());
91  $duplicate = assQuestion::_instanciateQuestion($duplicate_id);
92  $duplicate->setObjId(0);
93 
94  // we remove everything not supported by the non-tiny self
95  // assessment question editor
96  $q = $duplicate->getQuestion();
97 
98  // we try to save all latex tags
99  $try = true;
100  $ls = '<span class="latex">';
101  $le = '</span>';
102  while ($try)
103  {
104  // search position of start tag
105  $pos1 = strpos($q, $ls);
106  if (is_int($pos1))
107  {
108  $pos2 = strpos($q, $le, $pos1);
109  if (is_int($pos2))
110  {
111  // both found: replace end tag
112  $q = substr($q, 0, $pos2)."[/tex]".substr($q, $pos2+7);
113  $q = substr($q, 0, $pos1)."[tex]".substr($q, $pos1+20);
114  }
115  else
116  {
117  $try = false;
118  }
119  }
120  else
121  {
122  $try = false;
123  }
124  }
125 
127  $tstr = "";
128  foreach ($tags as $t)
129  {
130  $tstr.="<".$t.">";
131  }
132  $q = ilUtil::secureString($q, true, $tstr);
133  // self assessment uses nl2br, not p
134  $duplicate->setQuestion($q);
135 
136  $duplicate->saveQuestionDataToDb();
137 
138  $this->q_node->set_attribute("QRef", "il__qst_".$duplicate_id);
139  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
+ Here is the call graph for this function:

◆ create()

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.

71  {
72  $this->createPageContentNode();
73  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER);
74  $this->q_node = $this->dom->create_element("Question");
75  $this->q_node = $this->node->append_child($this->q_node);
76  $this->q_node->set_attribute("QRef", "");
77  }
const IL_INSERT_AFTER
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ getLangVars()

static ilPCQuestion::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

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

146  {
147  return array("ed_insert_pcqst", "empty_question", "pc_qst");
148  }

◆ getQuestionReference()

ilPCQuestion::getQuestionReference ( )

Get Question Reference.

Returns
string Question Reference

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

59  {
60  if (is_object($this->q_node))
61  {
62  return $this->q_node->get_attribute("QRef", $a_questionreference);
63  }
64  return false;
65  }

◆ init()

ilPCQuestion::init ( )

Init page content component.

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

References ilPageContent\setType().

27  {
28  $this->setType("pcqst");
29  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ setNode()

ilPCQuestion::setNode ( $a_node)

Set node.

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

35  {
36  parent::setNode($a_node); // this is the PageContent node
37  $this->q_node =& $a_node->first_child(); //... and this the Question
38  }

◆ setQuestionReference()

ilPCQuestion::setQuestionReference (   $a_questionreference)

Set Question Reference.

Parameters
string$a_questionreferenceQuestion Reference

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

46  {
47  if (is_object($this->q_node))
48  {
49  $this->q_node->set_attribute("QRef", $a_questionreference);
50  }
51  }

Field Documentation

◆ $dom

ilPCQuestion::$dom

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

◆ $q_node

ilPCQuestion::$q_node

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


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