24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
51 include_once
"./Modules/TestQuestionPool/classes/class.assFlashQuestion.php";
53 $this->newUnitId = null;
56 $this->
object->loadFromDb($id);
62 if (preg_match(
"/suggestrange_(.*?)/",
$cmd, $matches))
64 $cmd =
"suggestRange";
91 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
96 if (
$_POST[
'flash'][
'delete'] == 1)
98 $this->
object->deleteApplet();
102 $this->
object->setApplet(
$_POST[
'flash'][
'filename']);
104 if ($_FILES[
"flash"][
"tmp_name"])
106 $this->
object->deleteApplet();
107 $filename = $this->
object->moveUploadedFile($_FILES[
"flash"][
"tmp_name"], $_FILES[
"flash"][
"name"]);
110 $this->
object->clearParameters();
111 if (is_array(
$_POST[
"flash"][
"flash_param_name"]))
113 foreach (
$_POST[
'flash'][
'flash_param_name'] as $idx => $val)
115 $this->
object->addParameter($val,
$_POST[
'flash'][
'flash_param_value'][$idx]);
118 if (is_array(
$_POST[
'flash'][
'flash_param_delete']))
120 foreach (
$_POST[
'flash'][
'flash_param_delete'] as
$key => $value)
122 $this->
object->removeParameter(
$_POST[
'flash'][
'flash_param_name'][
$key]);
125 $this->
object->setTitle(
$_POST[
"title"]);
126 $this->
object->setAuthor(
$_POST[
"author"]);
127 $this->
object->setComment(
$_POST[
"comment"]);
128 $questiontext =
$_POST[
"question"];
129 $this->
object->setQuestion($questiontext);
130 $this->
object->setEstimatedWorkingTime(
131 $_POST[
"Estimated"][
"hh"],
132 $_POST[
"Estimated"][
"mm"],
135 $this->
object->setWidth(
$_POST[
"flash"][
"width"]);
136 $this->
object->setHeight(
$_POST[
"flash"][
"height"]);
137 $this->
object->setPoints(
$_POST[
"points"]);
153 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
156 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
158 $form->setFormAction($this->ctrl->getFormAction($this));
160 $form->setMultipart(TRUE);
161 $form->setTableWidth(
"100%");
162 $form->setId(
"flash");
169 if (strlen($this->object->getApplet()))
171 $flash->setApplet($this->object->getApplet());
172 $flash->setAppletPathWeb($this->object->getFlashPathWeb());
174 $flash->setWidth($this->object->getWidth());
175 $flash->setHeight($this->object->getHeight());
176 $flash->setParameters($this->object->getParameters());
177 $form->addItem($flash);
178 if ($this->object->getId())
181 $hidden->setValue($this->object->getId());
182 $form->addItem($hidden);
186 $points->setValue($this->object->getPoints());
198 $form->setValuesByPost();
199 $errors = !$form->checkInput();
200 $form->setValuesByPost();
201 if (
$errors) $checkonly =
false;
204 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
211 $this->
object->addParameter(
"",
"");
215 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
217 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
218 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
219 $this->tpl->setVariable(
"FORMACTION", $formaction);
238 $graphicalOutput = FALSE,
239 $result_output = FALSE,
240 $show_question_only = TRUE,
241 $show_feedback = FALSE,
242 $show_correct_solution = FALSE,
243 $show_manual_scoring = FALSE
247 $template =
new ilTemplate(
"tpl.il_as_qpl_flash_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
250 if (is_array($this->object->getParameters()))
252 foreach ($this->object->getParameters() as
$name => $value)
254 array_push(
$params, urlencode($name) .
"=" . urlencode($value));
259 array_push(
$params,
"client=" . urlencode(CLIENT_ID));
260 array_push(
$params,
"points_max=" . urlencode($this->object->getPoints()));
268 include_once
"./Modules/Test/classes/class.ilObjTest.php";
273 array_push(
$params,
"active_id=" . $active_id);
275 array_push(
$params,
"question_id=" . $this->object->getId());
277 if ($show_correct_solution)
282 if (($active_id > 0) && (!$show_correct_solution))
284 if ($graphicalOutput)
287 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
288 if ($reached_points == $this->object->getMaximumPoints())
290 $template->setCurrentBlock(
"icon_ok");
292 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
293 $template->parseCurrentBlock();
297 $template->setCurrentBlock(
"icon_ok");
298 if ($reached_points > 0)
301 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
306 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
308 $template->parseCurrentBlock();
315 $template->setCurrentBlock(
"flash_vars");
316 $template->setVariable(
"FLASH_VARS", join(
$params,
"&"));
317 $template->parseCurrentBlock();
318 $template->setCurrentBlock(
"applet_parameters");
319 $template->setVariable(
"PARAM_VALUE", join(
$params,
"&"));
320 $template->parseCurrentBlock();
322 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
323 $template->setVariable(
"APPLET_WIDTH", $this->object->getWidth());
324 $template->setVariable(
"APPLET_HEIGHT", $this->object->getHeight());
325 $template->setVariable(
"ID", $this->object->getId());
326 $template->setVariable(
"APPLET_PATH", $this->object->getFlashPathWeb() . $this->
object->getApplet());
327 $template->setVariable(
"APPLET_FILE", $this->object->getApplet());
329 $questionoutput = $template->get();
330 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
331 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
332 $solutionoutput = $solutiontemplate->get();
333 if (!$show_question_only)
338 return $solutionoutput;
343 $template =
new ilTemplate(
"tpl.il_as_qpl_flash_question_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
345 if (is_array($this->object->getParameters()))
347 foreach ($this->object->getParameters() as
$name => $value)
349 array_push(
$params, urlencode($name) .
"=" . urlencode($value));
354 $template->setCurrentBlock(
"flash_vars");
355 $template->setVariable(
"FLASH_VARS", join(
$params,
"&"));
356 $template->parseCurrentBlock();
357 $template->setCurrentBlock(
"applet_parameters");
358 $template->setVariable(
"PARAM_VALUE", join(
$params,
"&"));
359 $template->parseCurrentBlock();
361 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
362 $template->setVariable(
"APPLET_WIDTH", $this->object->getWidth());
363 $template->setVariable(
"APPLET_HEIGHT", $this->object->getHeight());
364 $template->setVariable(
"ID", $this->object->getId());
365 $template->setVariable(
"APPLET_PATH", $this->object->getFlashPathWeb() . $this->
object->getApplet());
366 $template->setVariable(
"APPLET_FILE", $this->object->getApplet());
367 $questionoutput = $template->get();
368 if (!$show_question_only)
373 return $questionoutput;
376 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
379 $template =
new ilTemplate(
"tpl.il_as_qpl_flash_question_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
381 if (is_array($this->object->getParameters()))
383 foreach ($this->object->getParameters() as
$name => $value)
385 array_push(
$params, urlencode($name) .
"=" . urlencode($value));
390 array_push(
$params,
"client=" . urlencode(CLIENT_ID));
391 array_push(
$params,
"points_max=" . urlencode($this->object->getPoints()));
399 include_once
"./Modules/Test/classes/class.ilObjTest.php";
404 array_push(
$params,
"active_id=" . $active_id);
406 array_push(
$params,
"question_id=" . $this->object->getId());
410 $template->setCurrentBlock(
"flash_vars");
411 $template->setVariable(
"FLASH_VARS", join(
$params,
"&"));
412 $template->parseCurrentBlock();
413 $template->setCurrentBlock(
"applet_parameters");
414 $template->setVariable(
"PARAM_VALUE", join(
$params,
"&"));
415 $template->parseCurrentBlock();
417 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
418 $template->setVariable(
"APPLET_WIDTH", $this->object->getWidth());
419 $template->setVariable(
"APPLET_HEIGHT", $this->object->getHeight());
420 $template->setVariable(
"ID", $this->object->getId());
421 $template->setVariable(
"APPLET_PATH", $this->object->getFlashPathWeb() . $this->
object->getApplet());
422 $template->setVariable(
"APPLET_FILE", $this->object->getFlashPathWeb() . $this->
object->getApplet());
423 $questionoutput = $template->get();
425 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
436 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
438 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
439 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
440 $this->
object->cleanupMediaObjectUsage();
451 global $rbacsystem, $ilTabs;
453 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
454 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
455 $q_type = $this->
object->getQuestionType();
459 $classname = $q_type .
"GUI";
460 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
461 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
466 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
469 $ilTabs->addTarget(
"edit_content",
470 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
471 array(
"edit",
"insert",
"exec_pg"),
472 "",
"", $force_active);
476 $ilTabs->addTarget(
"preview",
477 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
479 "ilPageObjectGUI",
"", $force_active);
482 $force_active =
false;
483 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
486 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
487 $commands =
$_POST[
"cmd"];
488 if (is_array($commands))
490 foreach ($commands as
$key => $value)
492 if (preg_match(
"/^suggestrange_.*/",
$key, $matches))
494 $force_active =
true;
499 $ilTabs->addTarget(
"edit_properties",
501 array(
"editQuestion",
"save",
"flashAddParam",
"saveEdit",
"originalSyncForm"),
502 $classname,
"", $force_active);
507 $ilTabs->addTarget(
"feedback",
508 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
509 array(
"feedback",
"saveFeedback"),
515 $ilTabs->addTarget(
"solution_hint",
516 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
517 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
518 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
528 $ilTabs->addTarget(
"statistics",
529 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
534 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
538 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
542 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));