ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilQuestionPoolPrintViewTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('./Services/Table/classes/class.ilTable2GUI.php');
5 
15 {
16  protected $outputmode;
17 
25  public function __construct($a_parent_obj, $a_parent_cmd, $outputmode = '')
26  {
27  $this->setId("qpl_print");
28  parent::__construct($a_parent_obj, $a_parent_cmd);
29 
30  global $lng, $ilCtrl;
31 
32  $this->lng = $lng;
33  $this->ctrl = $ilCtrl;
34  $this->outputmode = $outputmode;
35 
36  $this->setFormName('printviewform');
37  $this->setStyle('table', 'fullwidth');
38  $this->addColumn($this->lng->txt("title"),'title', '');
39  foreach ($this->getSelectedColumns() as $c)
40  {
41  if (strcmp($c, 'description') == 0) $this->addColumn($this->lng->txt("description"),'description', '');
42  if (strcmp($c, 'author') == 0) $this->addColumn($this->lng->txt("author"),'author', '');
43  if (strcmp($c, 'ttype') == 0) $this->addColumn($this->lng->txt("question_type"),'ttype', '');
44  if (strcmp($c, 'created') == 0) $this->addColumn($this->lng->txt("create_date"),'created', '');
45  if (strcmp($c, 'updated') == 0) $this->addColumn($this->lng->txt("last_update"),'updated', '');
46  }
47 
48  $this->addCommandButton('print', $this->lng->txt('print'), "javascript:window.print();return false;");
49 
50  $this->setRowTemplate("tpl.il_as_qpl_printview_row.html", "Modules/TestQuestionPool");
51 
52  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
53  $this->setDefaultOrderField("title");
54  $this->setDefaultOrderDirection("asc");
55  $this->setLimit(999);
56 
57  $this->enable('sort');
58  $this->enable('header');
59 // $this->disable('numinfo');
60  $this->disable('select_all');
61  }
62 
64  {
65  global $lng;
66  $cols["description"] = array(
67  "txt" => $lng->txt("description"),
68  "default" => true
69  );
70  $cols["author"] = array(
71  "txt" => $lng->txt("author"),
72  "default" => true
73  );
74  $cols["ttype"] = array(
75  "txt" => $lng->txt("question_type"),
76  "default" => true
77  );
78  $cols["created"] = array(
79  "txt" => $lng->txt("create_date"),
80  "default" => true
81  );
82  $cols["updated"] = array(
83  "txt" => $lng->txt("last_update"),
84  "default" => true
85  );
86  return $cols;
87  }
88 
96  public function fillRow($data)
97  {
99  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title']));
100  foreach ($this->getSelectedColumns() as $c)
101  {
102  if (strcmp($c, 'description') == 0)
103  {
104  $this->tpl->setCurrentBlock('description');
105  $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description']));
106  $this->tpl->parseCurrentBlock();
107  }
108  if (strcmp($c, 'author') == 0)
109  {
110  $this->tpl->setCurrentBlock('author');
111  $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author']));
112  $this->tpl->parseCurrentBlock();
113  }
114  if (strcmp($c, 'ttype') == 0)
115  {
116  $this->tpl->setCurrentBlock('ttype');
117  $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype']));
118  $this->tpl->parseCurrentBlock();
119  }
120  if(strcmp($c, 'created') == 0)
121  {
122  $this->tpl->setCurrentBlock('created');
123  $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX)));
124  $this->tpl->parseCurrentBlock();
125  }
126  if(strcmp($c, 'updated') == 0)
127  {
128  $this->tpl->setCurrentBlock('updated');
129  $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX)));
130  $this->tpl->parseCurrentBlock();
131  }
132  }
133  if ((strcmp($this->outputmode, "detailed") == 0) || (strcmp($this->outputmode, "detailed_printview") == 0))
134  {
135  $this->tpl->setCurrentBlock("overview_row_detail");
136  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
137  $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]);
138  if (strcmp($this->outputmode, "detailed") == 0)
139  {
140  $solutionoutput = $question_gui->getSolutionOutput($active_id = "", $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = FALSE, $show_feedback = FALSE, $show_correct_solution = true, $show_manual_scoring = false);
141  if (strlen($solutionoutput) == 0) $solutionoutput = $question_gui->getPreview();
142  $this->tpl->setVariable("DETAILS", $solutionoutput);
143  }
144  else
145  {
146  $this->tpl->setVariable("DETAILS", $question_gui->getPreview());
147  }
148  $this->tpl->parseCurrentBlock();
149  }
151  }
152 
157  public function numericOrdering($column)
158  {
159  if(in_array($column, array('created', 'updated')))
160  {
161  return true;
162  }
163 
164  return false;
165  }
166 }