ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.assFlashQuestionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5require_once './Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6include_once './Modules/Test/classes/inc.AssessmentConstants.php';
7
24{
25 private $newUnitId;
26
35 function __construct($id = -1)
36 {
37 parent::__construct();
38 include_once "./Modules/TestQuestionPool/classes/class.assFlashQuestion.php";
39 $this->object = new assFlashQuestion();
40 $this->newUnitId = null;
41 if ($id >= 0)
42 {
43 $this->object->loadFromDb($id);
44 }
45 }
46
47 function getCommand($cmd)
48 {
49 if (preg_match("/suggestrange_(.*?)/", $cmd, $matches))
50 {
51 $cmd = "suggestRange";
52 }
53 return $cmd;
54 }
55
61 function suggestRange()
62 {
63 if ($this->writePostData())
64 {
66 }
67 $this->editQuestion();
68 }
69
73 protected function writePostData($always = false)
74 {
75 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
76 if (!$hasErrors)
77 {
78 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
81
83 return 0;
84 }
85 return 1;
86 }
87
89 {
90 $this->setErrorMessage( "" );
91 if ($_POST['flash']['delete'] == 1)
92 {
93 $this->object->deleteApplet();
94 }
95 else
96 {
97 $this->object->setApplet( $_POST['flash']['filename'] );
98 }
99 if ($_FILES["flash"]["tmp_name"])
100 {
101 $this->object->deleteApplet();
102 $filename = $this->object->moveUploadedFile( $_FILES["flash"]["tmp_name"], $_FILES["flash"]["name"] );
103 $this->object->setApplet( $filename );
104 }
105 $this->object->clearParameters();
106 if (is_array( $_POST["flash"]["flash_param_name"] ))
107 {
108 foreach ($_POST['flash']['flash_param_name'] as $idx => $val)
109 {
110 $this->object->addParameter( $val, $_POST['flash']['flash_param_value'][$idx] );
111 }
112 }
113 if (is_array( $_POST['flash']['flash_param_delete'] ))
114 {
115 foreach ($_POST['flash']['flash_param_delete'] as $key => $value)
116 {
117 $this->object->removeParameter( $_POST['flash']['flash_param_name'][$key] );
118 }
119 }
120
121 $this->object->setWidth( $_POST["flash"]["width"] );
122 $this->object->setHeight( $_POST["flash"]["height"] );
123 $this->object->setPoints( $_POST["points"] );
124 }
125
131 public function editQuestion($checkonly = FALSE)
132 {
133 //$save = ((strcmp($this->ctrl->getCmd(), "save") == 0) || (strcmp($this->ctrl->getCmd(), "saveEdit") == 0)) ? TRUE : FALSE;
134 $save = $this->isSaveCommand();
135 $this->getQuestionTemplate();
136
137 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
138 $form = new ilPropertyFormGUI();
139 $this->editForm = $form;
140
141 $form->setFormAction($this->ctrl->getFormAction($this));
142 $form->setTitle($this->outQuestionType());
143 $form->setMultipart(TRUE);
144 $form->setTableWidth("100%");
145 $form->setId("flash");
146
147 $this->addBasicQuestionFormProperties($form);
148 $this->populateQuestionSpecificFormPart( $form );
149
150 $this->populateTaxonomyFormSection($form);
151
152 $this->addQuestionFormCommandButtons($form);
153
154 $errors = false;
155
156 if ($save)
157 {
158 $form->setValuesByPost();
159 $errors = !$form->checkInput();
160 $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
161 if ($errors) $checkonly = false;
162 }
163
164 if (!$checkonly) $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
165 return $errors;
166 }
167
169 {
170 // flash file
171 $flash = new ilFlashFileInputGUI($this->lng->txt( "flashfile" ), "flash");
172 $flash->setRequired( TRUE );
173 if (strlen( $this->object->getApplet() ))
174 {
175 $flash->setApplet( $this->object->getApplet() );
176 $flash->setAppletPathWeb( $this->object->getFlashPathWeb() );
177 }
178 $flash->setWidth( $this->object->getWidth() );
179 $flash->setHeight( $this->object->getHeight() );
180 $flash->setParameters( $this->object->getParameters() );
181 $form->addItem( $flash );
182 if ($this->object->getId())
183 {
184 $hidden = new ilHiddenInputGUI("", "ID");
185 $hidden->setValue( $this->object->getId() );
186 $form->addItem( $hidden );
187 }
188 // points
189 $points = new ilNumberInputGUI($this->lng->txt( "points" ), "points");
190 $points->setValue( $this->object->getPoints() );
191 $points->setRequired( TRUE );
192 $points->setSize( 3 );
193 $points->setMinValue( 0.0 );
194 $form->addItem( $points );
195
196 return $form;
197 }
198
199 function flashAddParam()
200 {
201 $this->writePostData();
202 $this->object->addParameter("", "");
203 $this->editQuestion();
204 }
205
220 $active_id,
221 $pass = NULL,
222 $graphicalOutput = FALSE,
223 $result_output = FALSE,
224 $show_question_only = TRUE,
225 $show_feedback = FALSE,
226 $show_correct_solution = FALSE,
227 $show_manual_scoring = FALSE,
228 $show_question_text = TRUE
229 )
230 {
231 // get the solution of the user for the active pass or from the last pass if allowed
232 $template = new ilTemplate("tpl.il_as_qpl_flash_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
233
234 $params = array();
235 if (is_array($this->object->getParameters()))
236 {
237 foreach ($this->object->getParameters() as $name => $value)
238 {
239 array_push($params, urlencode($name) . "=" . urlencode($value));
240 }
241 }
242
243 array_push($params, "session_id=" . urlencode($_COOKIE["PHPSESSID"]));
244 array_push($params, "client=" . urlencode(CLIENT_ID));
245 array_push($params, "points_max=" . urlencode($this->object->getPoints()));
246 array_push($params, "server=" . urlencode(ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/webservice/soap/server.php?wsdl"));
247 if (!is_null($pass))
248 {
249 array_push($params, "pass=" . $pass);
250 }
251 else
252 {
253 include_once "./Modules/Test/classes/class.ilObjTest.php";
254 array_push($params, "pass=" . ilObjTest::_getPass($active_id));
255 }
256 if ($active_id)
257 {
258 array_push($params, "active_id=" . $active_id);
259 }
260 array_push($params, "question_id=" . $this->object->getId());
261
262 if ($show_correct_solution)
263 {
264 array_push($params, "solution=correct");
265 }
266 else
267 {
268 array_push($params, "solution=user");
269 }
270
271 if (($active_id > 0) && (!$show_correct_solution))
272 {
273 if ($graphicalOutput)
274 {
275 // output of ok/not ok icons for user entered solutions
276 $reached_points = $this->object->getReachedPoints($active_id, $pass);
277 if ($reached_points == $this->object->getMaximumPoints())
278 {
279 $template->setCurrentBlock("icon_ok");
280 $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
281 $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
282 $template->parseCurrentBlock();
283 }
284 else
285 {
286 $template->setCurrentBlock("icon_ok");
287 if ($reached_points > 0)
288 {
289 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.svg"));
290 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
291 }
292 else
293 {
294 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
295 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
296 }
297 $template->parseCurrentBlock();
298 }
299 }
300 }
301
302 if (count($params))
303 {
304 $template->setCurrentBlock("flash_vars");
305 $template->setVariable("FLASH_VARS", join($params, "&"));
306 $template->parseCurrentBlock();
307 $template->setCurrentBlock("applet_parameters");
308 $template->setVariable("PARAM_VALUE", join($params, "&"));
309 $template->parseCurrentBlock();
310 }
311 if ($show_question_text==true)
312 {
313 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
314 }
315 $template->setVariable("APPLET_WIDTH", $this->object->getWidth());
316 $template->setVariable("APPLET_HEIGHT", $this->object->getHeight());
317 $template->setVariable("ID", $this->object->getId());
318 $template->setVariable("APPLET_PATH", $this->object->getFlashPathWeb() . $this->object->getApplet());
319 $template->setVariable("APPLET_FILE", $this->object->getApplet());
320
321 $questionoutput = $template->get();
322 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
323 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
324 $solutionoutput = $solutiontemplate->get();
325 if (!$show_question_only)
326 {
327 // get page object output
328 $solutionoutput = $this->getILIASPage($solutionoutput);
329 }
330 return $solutionoutput;
331 }
332
333 function getPreview($show_question_only = FALSE, $showInlineFeedback = false)
334 {
335 $template = new ilTemplate("tpl.il_as_qpl_flash_question_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
336 $params = array();
337 if (is_array($this->object->getParameters()))
338 {
339 foreach ($this->object->getParameters() as $name => $value)
340 {
341 array_push($params, urlencode($name) . "=" . urlencode($value));
342 }
343 }
344 if (count($params))
345 {
346 $template->setCurrentBlock("flash_vars");
347 $template->setVariable("FLASH_VARS", join($params, "&"));
348 $template->parseCurrentBlock();
349 $template->setCurrentBlock("applet_parameters");
350 $template->setVariable("PARAM_VALUE", join($params, "&"));
351 $template->parseCurrentBlock();
352 }
353 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
354 $template->setVariable("APPLET_WIDTH", $this->object->getWidth());
355 $template->setVariable("APPLET_HEIGHT", $this->object->getHeight());
356 $template->setVariable("ID", $this->object->getId());
357 $template->setVariable("APPLET_PATH", $this->object->getFlashPathWeb() . $this->object->getApplet());
358 $template->setVariable("APPLET_FILE", $this->object->getApplet());
359 $questionoutput = $template->get();
360 if (!$show_question_only)
361 {
362 // get page object output
363 $questionoutput = $this->getILIASPage($questionoutput);
364 }
365 return $questionoutput;
366 }
367
368 // hey: prevPassSolutions - pass will be always available from now on
369 function getTestOutput($active_id, $pass, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
370 // hey.
371 {
372 // generate the question output
373 $template = new ilTemplate("tpl.il_as_qpl_flash_question_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
374 $params = array();
375 if (is_array($this->object->getParameters()))
376 {
377 foreach ($this->object->getParameters() as $name => $value)
378 {
379 array_push($params, urlencode($name) . "=" . urlencode($value));
380 }
381 }
382
383 array_push($params, "session_id=" . urlencode($_COOKIE["PHPSESSID"]));
384 array_push($params, "client=" . urlencode(CLIENT_ID));
385 array_push($params, "points_max=" . urlencode($this->object->getPoints()));
386 array_push($params, "server=" . urlencode(ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/webservice/soap/server.php?wsdl"));
387 if (strlen($pass))
388 {
389 array_push($params, "pass=" . $pass);
390 }
391 else
392 {
393 include_once "./Modules/Test/classes/class.ilObjTest.php";
394 array_push($params, "pass=" . ilObjTest::_getPass($active_id));
395 }
396 if ($active_id)
397 {
398 array_push($params, "active_id=" . $active_id);
399 }
400 array_push($params, "question_id=" . $this->object->getId());
401
402 if (count($params))
403 {
404 $template->setCurrentBlock("flash_vars");
405 $template->setVariable("FLASH_VARS", join($params, "&"));
406 $template->parseCurrentBlock();
407 $template->setCurrentBlock("applet_parameters");
408 $template->setVariable("PARAM_VALUE", join($params, "&"));
409 $template->parseCurrentBlock();
410 }
411 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
412 $template->setVariable("APPLET_WIDTH", $this->object->getWidth());
413 $template->setVariable("APPLET_HEIGHT", $this->object->getHeight());
414 $template->setVariable("ID", $this->object->getId());
415 $template->setVariable("APPLET_PATH", $this->object->getFlashPathWeb() . $this->object->getApplet());
416 $template->setVariable("APPLET_FILE", $this->object->getFlashPathWeb() . $this->object->getApplet());
417 $questionoutput = $template->get();
418
419 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
420 return $pageoutput;
421 }
422
431 {
432 global $rbacsystem, $ilTabs;
433
434 $ilTabs->clearTargets();
435
436 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
437 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
438 $q_type = $this->object->getQuestionType();
439
440 if (strlen($q_type))
441 {
442 $classname = $q_type . "GUI";
443 $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
444 $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
445 }
446
447 if ($_GET["q_id"])
448 {
449 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
450 {
451 // edit page
452 $ilTabs->addTarget("edit_page",
453 $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
454 array("edit", "insert", "exec_pg"),
455 "", "", $force_active);
456 }
457
458 $this->addTab_QuestionPreview($ilTabs);
459 }
460
461 $force_active = false;
462 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
463 {
464 $url = "";
465 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
466 $commands = $_POST["cmd"];
467 if (is_array($commands))
468 {
469 foreach ($commands as $key => $value)
470 {
471 if (preg_match("/^suggestrange_.*/", $key, $matches))
472 {
473 $force_active = true;
474 }
475 }
476 }
477 // edit question properties
478 $ilTabs->addTarget("edit_question",
479 $url,
480 array("editQuestion", "save", "flashAddParam", "saveEdit", "originalSyncForm"),
481 $classname, "", $force_active);
482 }
483
484 // add tab for question feedback within common class assQuestionGUI
485 $this->addTab_QuestionFeedback($ilTabs);
486
487 // add tab for question hint within common class assQuestionGUI
488 $this->addTab_QuestionHints($ilTabs);
489
490 // add tab for question's suggested solution within common class assQuestionGUI
491 $this->addTab_SuggestedSolution($ilTabs, $classname);
492
493 // Assessment of questions sub menu entry
494 if ($_GET["q_id"])
495 {
496 $ilTabs->addTarget("statistics",
497 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
498 array("assessment"),
499 $classname, "");
500 }
501
502 $this->addBackTab($ilTabs);
503 }
504
505 function getSpecificFeedbackOutput($active_id, $pass)
506 {
507 $output = "";
508 return $this->object->prepareTextareaOutput($output, TRUE);
509 }
510
521 {
522 return array();
523 }
524
533 public function getAggregatedAnswersView($relevant_answers)
534 {
535 // Empty implementation here since a feasible way to aggregate answer is not known.
536 return ''; //print_r($relevant_answers,true);
537 }
538}
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
The assFlashQuestionGUI class encapsulates the GUI representation for flash questions.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
suggestRange()
Suggest a range for a result.
getSpecificFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
getTestOutput($active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
getSolutionOutput( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
Get the question solution output.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
Adds the question specific forms parts to a question property form gui.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
__construct($id=-1)
assFlashQuestionGUI constructor
Class for Flash based questions.
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
setErrorMessage($errormessage)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
addBackTab(ilTabsGUI $ilTabs)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
This class represents an image file property in a property form.
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
special template class to simplify handling of ITX/PEAR
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static removeTrailingPathSeparators($path)
$params
Definition: example_049.php:96
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
Interface ilGuiQuestionScoringAdjustable.
$cmd
Definition: sahs_server.php:35
$url
Definition: shib_logout.php:72
$errors