ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
assImagemapQuestionGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assImagemapQuestionGUI:
+ Collaboration diagram for assImagemapQuestionGUI:

Public Member Functions

 __construct (int $id=-1)
 assImagemapQuestionGUI constructor More...
 
 deleteImage ()
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from the request and applies them to the data object. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 addRect ()
 
 addCircle ()
 
 addPoly ()
 
 saveShape ()
 
 areaEditor (string $shape='')
 
 back ()
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass (string $targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 

Protected Member Functions

 writePostData (bool $always=false)
 {} More...
 
 buildEditForm ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 buildAreaLinkTarget ($currentSelection, $areaIndex)
 
 buildSelectionParameter ($currentSelection, $areaIndex=null)
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Private Member Functions

 aggregateAnswers ($givenSolutionRows, $existingAnswerOptions)
 

Private Attributes

string $linecolor
 
ilPropertyFormGUI $edit_form = null
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Data Fields inherited from assQuestionGUI
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const CMD_SYNC_QUESTION_AND_RETURN = 'syncQuestionReturn'
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Image map question GUI representation

The assImagemapQuestionGUI class encapsulates the GUI representation for image map questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$ \ assImagemapQuestionGUI: ilPropertyFormGUI, ilFormPropertyDispatchGUI

Definition at line 33 of file class.assImagemapQuestionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

assImagemapQuestionGUI::__construct ( int  $id = -1)

assImagemapQuestionGUI constructor

The constructor takes possible arguments an creates an instance of the assImagemapQuestionGUI object.

Parameters
integer$idThe database id of a image map question object.

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

References $id, and ILIAS\GlobalScreen\Provider\__construct().

46  {
48  $this->object = new assImagemapQuestion();
49  if ($id >= 0) {
50  $this->object->loadFromDb($id);
51  }
52  $this->linecolor = '#' . (new ilSetting('assessment'))->get('imap_line_color') ?? 'FF0000';
53  }
Class for image map questions.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addCircle()

assImagemapQuestionGUI::addCircle ( )

Definition at line 215 of file class.assImagemapQuestionGUI.php.

References areaEditor().

215  : void
216  {
217  $this->areaEditor('circle');
218  }
+ Here is the call graph for this function:

◆ addPoly()

assImagemapQuestionGUI::addPoly ( )

Definition at line 220 of file class.assImagemapQuestionGUI.php.

References areaEditor().

220  : void
221  {
222  $this->areaEditor('poly');
223  }
+ Here is the call graph for this function:

◆ addRect()

assImagemapQuestionGUI::addRect ( )

Definition at line 210 of file class.assImagemapQuestionGUI.php.

References areaEditor().

210  : void
211  {
212  $this->areaEditor('rect');
213  }
+ Here is the call graph for this function:

◆ aggregateAnswers()

assImagemapQuestionGUI::aggregateAnswers (   $givenSolutionRows,
  $existingAnswerOptions 
)
private

Definition at line 814 of file class.assImagemapQuestionGUI.php.

Referenced by getAnswersFrequency().

814  : array
815  {
816  $answeringFequencies = [];
817 
818  foreach ($existingAnswerOptions as $answerIndex => $answerOption) {
819  $answeringFequencies[$answerIndex] = 0;
820  }
821 
822  foreach ($givenSolutionRows as $solutionRow) {
823  $answeringFequencies[$solutionRow['value1']]++;
824  }
825 
826  return $answeringFequencies;
827  }
+ Here is the caller graph for this function:

◆ areaEditor()

assImagemapQuestionGUI::areaEditor ( string  $shape = '')

Definition at line 255 of file class.assImagemapQuestionGUI.php.

References $c, Vendor\Package\$e, $linecolor, ilImagemapPreview\addArea(), assImagemapQuestion\AVAILABLE_SHAPES, ILIAS\Repository\ctrl(), assQuestionGUI\getQuestionTemplate(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilWACSignedPath\signFile().

Referenced by addCircle(), addPoly(), and addRect().

255  : void
256  {
257  $this->getQuestionTemplate();
258  $editor_tpl = new ilTemplate('tpl.il_as_qpl_imagemap_question.html', true, true, 'components/ILIAS/TestQuestionPool');
259 
260  $shape = $shape !== '' ? $shape : $this->request_data_collector->string('shape');
261  $shape_title = $this->request_data_collector->string('shapetitle');
262  $image = $this->request_data_collector->raw('image', 2);
263  $coords = $image['mapcoords'] ?? [];
264 
265  $cmd = $this->request_data_collector->raw('cmd');
266  if ($cmd !== null && array_key_exists('areaEditor', $cmd) && is_array($cmd['areaEditor']['image'])) {
267  $coords[] = $cmd['areaEditor']['image'][0] . ',' . $cmd['areaEditor']['image'][1];
268  }
269  foreach ($coords as $value) {
270  $editor_tpl->setCurrentBlock('hidden');
271  $editor_tpl->setVariable('HIDDEN_NAME', 'image[mapcoords][]');
272  $editor_tpl->setVariable('HIDDEN_VALUE', $value);
273  $editor_tpl->parseCurrentBlock();
274  }
275 
276  $editor_tpl->setCurrentBlock('hidden');
277  $editor_tpl->setVariable('HIDDEN_NAME', 'shape');
278  $editor_tpl->setVariable(
279  'HIDDEN_VALUE',
280  $shape
281  );
282  $editor_tpl->parseCurrentBlock();
283 
284  $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename());
285  foreach ($this->object->answers as $index => $answer) {
286  $preview->addArea($index, $answer->getArea(), $answer->getCoords(), $answer->getAnswertext(), '', '', true, $this->linecolor);
287  }
288  $hidearea = false;
289  $disabled_save = ' disabled=\"disabled\"';
290  $c = '';
291  $coords_count = count($coords);
292  switch ($shape) {
294  switch ($coords_count) {
295  case 0:
296  $this->tpl->setOnScreenMessage('info', $this->lng->txt('rectangle_click_tl_corner'));
297  break;
298  case 1:
299  $this->tpl->setOnScreenMessage('info', $this->lng->txt('rectangle_click_br_corner'));
300  $preview->addPoint($preview->getAreaCount(), implode(',', $coords), true, 'blue');
301  break;
302  case 2:
303  $c = implode(',', $coords);
304  $hidearea = true;
305  $disabled_save = '';
306  break;
307  }
308  break;
310  switch ($coords_count) {
311  case 0:
312  $this->tpl->setOnScreenMessage('info', $this->lng->txt('circle_click_center'));
313  break;
314  case 1:
315  $this->tpl->setOnScreenMessage('info', $this->lng->txt('circle_click_circle'));
316  $preview->addPoint($preview->getAreaCount(), implode(',', $coords), true, 'blue');
317  break;
318  case 2:
319  if (preg_match("/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $coords[0] . ' ' . $coords[1], $matches)) {
320  $c = "$matches[1],$matches[2]," . (int) sqrt((($matches[3] - $matches[1]) * ($matches[3] - $matches[1])) + (($matches[4] - $matches[2]) * ($matches[4] - $matches[2])));
321  }
322  $hidearea = true;
323  $disabled_save = '';
324  break;
325  }
326  break;
328  switch ($coords_count) {
329  case 0:
330  $this->tpl->setOnScreenMessage('info', $this->lng->txt('polygon_click_starting_point'));
331  break;
332  case 1:
333  $this->tpl->setOnScreenMessage('info', $this->lng->txt('polygon_click_next_point'));
334  $preview->addPoint($preview->getAreaCount(), implode(',', $coords), true, 'blue');
335  break;
336  default:
337  $this->tpl->setOnScreenMessage('info', $this->lng->txt('polygon_click_next_or_save'));
338  $disabled_save = '';
339  $c = implode(',', $coords);
340  break;
341  }
342  break;
343  }
344 
345  if ($c !== '') {
346  $preview->addArea($preview->getAreaCount(), $shape, $c, $shape_title, '', '', true, 'blue');
347  }
348  $preview->createPreview();
349  $image_path = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->getImageFilename()) . '?img=' . time();
350  if (!$hidearea) {
351  $editor_tpl->setCurrentBlock('maparea');
352  $editor_tpl->setVariable('IMAGEMAP_NAME', 'image');
353  } else {
354  $editor_tpl->setCurrentBlock('imagearea');
355  $editor_tpl->setVariable('ALT_IMAGE', $this->lng->txt('imagemap'));
356  }
357  try {
358  $editor_tpl->setVariable('IMAGE_SOURCE', ilWACSignedPath::signFile($image_path));
359  } catch (ilWACException $e) {
360 
361  }
362  $editor_tpl->parseCurrentBlock();
363 
364  if ($shape_title !== '') {
365  $editor_tpl->setCurrentBlock('shapetitle');
366  $editor_tpl->setVariable('VALUE_SHAPETITLE', $shape_title);
367  $editor_tpl->parseCurrentBlock();
368  }
369 
370  $editor_tpl->setVariable('TEXT_IMAGEMAP', $this->lng->txt('imagemap'));
371  $editor_tpl->setVariable('TEXT_SHAPETITLE', $this->lng->txt('ass_imap_hint'));
372  $editor_tpl->setVariable('CANCEL', $this->lng->txt('cancel'));
373  $editor_tpl->setVariable('SAVE', $this->lng->txt('save'));
374  $editor_tpl->setVariable('DISABLED_SAVE', $disabled_save);
375 
376  if (in_array($shape, assImagemapQuestion::AVAILABLE_SHAPES, true)) {
377  $editor_tpl->setVariable('FORMACTION', $this->ctrl->getFormaction($this, 'add' . ucfirst($shape)));
378  }
379 
380  $this->tpl->setVariable('QUESTION_DATA', $editor_tpl->get());
381  }
$c
Definition: deliver.php:9
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static signFile(string $path_to_file)
addArea( $index, $shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ back()

assImagemapQuestionGUI::back ( )

Definition at line 383 of file class.assImagemapQuestionGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

383  : void
384  {
385  $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_cancel'), true);
386  $this->ctrl->redirect($this, 'editQuestion');
387  }
+ Here is the call graph for this function:

◆ buildAreaLinkTarget()

assImagemapQuestionGUI::buildAreaLinkTarget (   $currentSelection,
  $areaIndex 
)
protected

Definition at line 711 of file class.assImagemapQuestionGUI.php.

References ilUtil\appendUrlParameterString(), buildSelectionParameter(), ILIAS\Repository\ctrl(), assQuestionGUI\getQuestionActionCmd(), and assQuestionGUI\getTargetGuiClass().

Referenced by getTestOutput().

711  : string
712  {
713  $href = $this->ctrl->getLinkTargetByClass(
714  $this->getTargetGuiClass(),
715  $this->getQuestionActionCmd()
716  );
717 
719  $href,
720  $this->buildSelectionParameter($currentSelection, $areaIndex)
721  );
722 
723  return $href;
724  }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
buildSelectionParameter($currentSelection, $areaIndex=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildEditForm()

assImagemapQuestionGUI::buildEditForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 139 of file class.assImagemapQuestionGUI.php.

References assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\buildBasicEditFormObject(), populateQuestionSpecificFormPart(), and assQuestionGUI\populateTaxonomyFormSection().

Referenced by editQuestion(), and writePostData().

140  {
141  $form = $this->buildBasicEditFormObject();
142 
143  $this->addBasicQuestionFormProperties($form);
144  $this->populateQuestionSpecificFormPart($form);
145  $this->populateTaxonomyFormSection($form);
146  $this->addQuestionFormCommandButtons($form);
147 
148  return $form;
149  }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildSelectionParameter()

assImagemapQuestionGUI::buildSelectionParameter (   $currentSelection,
  $areaIndex = null 
)
protected

Definition at line 726 of file class.assImagemapQuestionGUI.php.

References assQuestion\implodeKeyValues(), and ILIAS\Repository\object().

Referenced by buildAreaLinkTarget(), and getPreviousSolutionConfirmationCheckboxHtml().

726  : string
727  {
728  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
729  $reuseSelection = [];
730 
731  if ($areaIndex === null) {
732  $reuseSelection = $currentSelection;
733  } elseif ($this->object->getIsMultipleChoice()) {
734  if (!in_array($areaIndex, $currentSelection)) {
735  $reuseSelection[] = $areaIndex;
736  }
737 
738  foreach (array_diff($currentSelection, [$areaIndex]) as $otherSelectedArea) {
739  $reuseSelection[] = $otherSelectedArea;
740  }
741  } else {
742  $reuseSelection[] = $areaIndex;
743  }
744 
745  $selection = assQuestion::implodeKeyValues($reuseSelection);
746  $action = 'reuseSelection';
747  } elseif ($areaIndex !== null) {
748  if (!$this->object->getIsMultipleChoice() || !in_array($areaIndex, $currentSelection)) {
749  $areaAction = 'selImage';
750  } else {
751  $areaAction = 'remImage';
752  }
753 
754  $selection = $areaIndex;
755  $action = $areaAction;
756  } else {
757  return '';
758  }
759 
760  return "{$action}={$selection}";
761  }
static implodeKeyValues(array $keyValues)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ completeTestOutputFormAction()

assImagemapQuestionGUI::completeTestOutputFormAction ( string  $form_action,
int  $active_id,
int  $pass 
)
protected

Definition at line 389 of file class.assImagemapQuestionGUI.php.

393  : string {
394  $info = $this->object->getTestOutputSolutions($active_id, $pass);
395  return $form_action . (($info !== [] && $info[0]['value1'] !== '') ? '&selImage=' . $info[0]['value1'] : '');
396  }

◆ deleteImage()

assImagemapQuestionGUI::deleteImage ( )

Definition at line 55 of file class.assImagemapQuestionGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

55  : void
56  {
57  $this->object->deleteImage();
58  $this->object->saveToDb();
59  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
60  $this->ctrl->redirect($this, 'editQuestion');
61  }
+ Here is the call graph for this function:

◆ editQuestion()

assImagemapQuestionGUI::editQuestion ( bool  $checkonly = false,
?bool  $is_save_cmd = null 
)

Definition at line 151 of file class.assImagemapQuestionGUI.php.

References $edit_form, buildEditForm(), and assQuestionGUI\renderEditForm().

Referenced by writePostData().

154  : bool {
155  $form = $this->edit_form;
156  if ($form === null) {
157  $form = $this->buildEditForm();
158  }
159 
160  $this->renderEditForm($form);
161  return false;
162  }
renderEditForm(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assImagemapQuestionGUI::getAfterParticipationSuppressionAnswerPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

Definition at line 795 of file class.assImagemapQuestionGUI.php.

795  : array
796  {
797  return [];
798  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assImagemapQuestionGUI::getAfterParticipationSuppressionQuestionPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

Definition at line 809 of file class.assImagemapQuestionGUI.php.

809  : array
810  {
811  return [];
812  }

◆ getAnswersFrequency()

assImagemapQuestionGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 850 of file class.assImagemapQuestionGUI.php.

References aggregateAnswers(), and ILIAS\Repository\object().

850  : array
851  {
852  $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
853 
854  $answers = [];
855 
856  foreach ($this->object->getAnswers() as $answerIndex => $ans) {
857  $answers[] = [
858  'answer' => $ans->getAnswerText(),
859  'frequency' => $agg[$answerIndex]
860  ];
861  }
862 
863  return $answers;
864  }
aggregateAnswers($givenSolutionRows, $existingAnswerOptions)
+ Here is the call graph for this function:

◆ getPreview()

assImagemapQuestionGUI::getPreview ( bool  $show_question_only = false,
bool  $show_inline_feedback = false 
)

Definition at line 572 of file class.assImagemapQuestionGUI.php.

References Vendor\Package\$e, $linecolor, ilImagemapPreview\addArea(), ILIAS\Repository\ctrl(), assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), assQuestionGUI\getQuestionActionCmd(), assQuestionGUI\getTargetGuiClass(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilWACSignedPath\signFile().

575  : string {
576  if (is_object($this->getPreviewSession())) {
577  $user_solution = [];
578 
579  if (is_array($this->getPreviewSession()->getParticipantsSolution())) {
580  $user_solution = array_values($this->getPreviewSession()->getParticipantsSolution());
581  }
582 
583  $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename());
584  foreach ($user_solution as $idx => $solution_value) {
585  if ($solution_value !== '') {
586  $preview->addArea($solution_value, $this->object->answers[$solution_value]->getArea(), $this->object->answers[$solution_value]->getCoords(), $this->object->answers[$solution_value]->getAnswertext(), "", "", true, $this->linecolor);
587  }
588  }
589  $preview->createPreview();
590  $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->getImageFilename());
591  } else {
592  $user_solution = [];
593  $imagepath = $this->object->getImagePathWeb() . $this->object->getImageFilename();
594  }
595 
596  // generate the question output
597  $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
598 
599  if ($this->getQuestionActionCmd() && !is_null($this->getTargetGuiClass())) {
600  $hrefArea = $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd());
601  } else {
602  $hrefArea = null;
603  }
604 
605  foreach ($this->object->answers as $answer_id => $answer) {
606  $parameter = "&amp;selImage=$answer_id";
607  if (is_array($user_solution) && in_array($answer_id, $user_solution)) {
608  $parameter = "&amp;remImage=$answer_id";
609  }
610 
611  if ($hrefArea) {
612  $template->setCurrentBlock("imagemap_area_href");
613  $template->setVariable("HREF_AREA", $hrefArea . $parameter);
614  $template->parseCurrentBlock();
615  }
616 
617  $template->setCurrentBlock("imagemap_area");
618  $template->setVariable("SHAPE", $answer->getArea());
619  $template->setVariable("COORDS", $answer->getCoords());
620  $template->setVariable("ALT", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
621  $template->setVariable("TITLE", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
622  $template->parseCurrentBlock();
623  }
624  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
625  try {
626  $template->setVariable("IMG_SRC", ilWACSignedPath::signFile($imagepath));
627  } catch (ilWACException $e) {
628 
629  }
630  $template->setVariable("IMG_ALT", $this->lng->txt("imagemap"));
631  $template->setVariable("IMG_TITLE", $this->lng->txt("imagemap"));
632  $questionoutput = $template->get();
633  if (!$show_question_only) {
634  $questionoutput = $this->getILIASPage($questionoutput);
635  }
636  return $questionoutput;
637  }
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static signFile(string $path_to_file)
addArea( $index, $shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")
+ Here is the call graph for this function:

◆ getPreviousSolutionConfirmationCheckboxHtml()

assImagemapQuestionGUI::getPreviousSolutionConfirmationCheckboxHtml ( )
protected

Definition at line 829 of file class.assImagemapQuestionGUI.php.

References $DIC, assQuestionGUI\$tpl, ilUtil\appendUrlParameterString(), buildSelectionParameter(), ILIAS\Repository\ctrl(), ilGlobalPageTemplate\get(), assQuestionGUI\getQuestionActionCmd(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilGlobalPageTemplate\setVariable().

829  : string
830  {
831  if (!count($this->object->currentSolution)) {
832  return '';
833  }
834 
835  global $DIC;
836  $button = $DIC->ui()->factory()->link()->standard(
837  $this->lng->txt('use_previous_solution'),
839  $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd()),
840  $this->buildSelectionParameter($this->object->currentSolution, null)
841  )
842  );
843 
844  $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'components/ILIAS/TestQuestionPool');
845  $tpl->setVariable('BUTTON', $DIC->ui()->renderer()->render($button));
846 
847  return $tpl->get();
848  }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
ilGlobalPageTemplate $tpl
buildSelectionParameter($currentSelection, $areaIndex=null)
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
global $DIC
Definition: shib_login.php:25
setVariable(string $variable, $value='')
Sets the given variable to the given value.
+ Here is the call graph for this function:

◆ getSolutionOutput()

assImagemapQuestionGUI::getSolutionOutput ( int  $active_id,
?int  $pass = null,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_inline_feedback = true 
)

Definition at line 398 of file class.assImagemapQuestionGUI.php.

References Vendor\Package\$e, $linecolor, ilImagemapPreview\addArea(), ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\generateCorrectnessIconsForCorrectness(), assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), assQuestionGUI\hasCorrectSolution(), assQuestionGUI\isTestPresentationContext(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareTextareaOutput(), assQuestionGUI\renderSolutionOutput(), and ilWACSignedPath\signFile().

409  : string {
410  $user_solutions = [];
411  if (($active_id > 0) && (!$show_correct_solution)) {
412  $user_solutions = $this->object->getSolutionValues($active_id, $pass);
413  } else {
414  if (!$this->object->getIsMultipleChoice()) {
415  $found_index = -1;
416  $max_points = 0;
417  foreach ($this->object->answers as $index => $answer) {
418  if ($answer->getPoints() > $max_points) {
419  $max_points = $answer->getPoints();
420  $found_index = $index;
421  }
422  }
423  array_push($user_solutions, ["value1" => $found_index]);
424  } else {
425  // take the correct solution instead of the user solution
426  foreach ($this->object->answers as $index => $answer) {
427  $points_checked = $answer->getPoints();
428  $points_unchecked = $answer->getPointsUnchecked();
429  if ($points_checked > $points_unchecked) {
430  if ($points_checked > 0) {
431  array_push($user_solutions, ["value1" => $index]);
432  }
433  }
434  }
435  }
436  }
437 
438  return $this->renderSolutionOutput(
439  $user_solutions,
440  $active_id,
441  $pass,
442  $graphical_output,
443  $result_output,
444  $show_question_only,
445  $show_feedback,
446  $show_correct_solution,
447  $show_manual_scoring,
448  $show_question_text,
449  false,
450  $show_inline_feedback,
451  );
452  }
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assImagemapQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

Definition at line 763 of file class.assImagemapQuestionGUI.php.

References ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

763  : string
764  {
765  if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
766  return '';
767  }
768 
769  $output = '<table class="test_specific_feedback"><tbody>';
770 
771  foreach ($this->object->getAnswers() as $idx => $answer) {
772  $feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
773  $this->object->getId(),
774  0,
775  $idx
776  );
777 
778  $output .= "<tr><td>{$answer->getAnswerText()}</td><td>{$feedback}</td></tr>";
779  }
780 
781  $output .= '</tbody></table>';
782 
784  }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ getTestOutput()

assImagemapQuestionGUI::getTestOutput ( int  $active_id,
int  $pass,
bool  $is_question_postponed = false,
array|bool  $user_post_solutions = false,
bool  $show_specific_inline_feedback = false 
)

Definition at line 639 of file class.assImagemapQuestionGUI.php.

References Vendor\Package\$e, $linecolor, ilImagemapPreview\addArea(), buildAreaLinkTarget(), ILIAS\Repository\ctrl(), assQuestionGUI\getTargetGuiClass(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\outQuestionPage(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilWACSignedPath\signFile().

645  : string {
646  if ($active_id) {
647  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
648  // hey.
649 
650  $userSelection = [];
651  $selectionIndex = 0;
652 
653  $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename());
654 
655  foreach ($solutions as $idx => $solution_value) {
656  if ($solution_value["value1"] !== null) {
657  $preview->addArea($solution_value["value1"], $this->object->answers[$solution_value["value1"]]->getArea(), $this->object->answers[$solution_value["value1"]]->getCoords(), $this->object->answers[$solution_value["value1"]]->getAnswertext(), "", "", true, $this->linecolor);
658  $userSelection[$selectionIndex] = $solution_value["value1"];
659 
660  $selectionIndex = $this->object->getIsMultipleChoice() ? ++$selectionIndex : $selectionIndex;
661  }
662  }
663 
664  $preview->createPreview();
665 
666  $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->getImageFilename());
667  } else {
668  $imagepath = $this->object->getImagePathWeb() . $this->object->getImageFilename();
669  }
670 
671  // generate the question output
672  $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
673  $this->ctrl->setParameterByClass($this->getTargetGuiClass(), "formtimestamp", time());
674  foreach ($this->object->answers as $answer_id => $answer) {
675  $template->setCurrentBlock("imagemap_area");
676  $template->setVariable("HREF_AREA", $this->buildAreaLinkTarget($userSelection, $answer_id));
677  $template->setVariable("SHAPE", $answer->getArea());
678  $template->setVariable("COORDS", $answer->getCoords());
679  $template->setVariable("ALT", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
680  $template->setVariable("TITLE", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
681  $template->parseCurrentBlock();
682  if ($show_specific_inline_feedback) {
683  if (!$this->object->getIsMultipleChoice() && count($userSelection) && current($userSelection) == $answer_id) {
684  $feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
685  $this->object->getId(),
686  0,
687  $answer_id
688  );
689  if ($feedback !== '') {
690  $template->setCurrentBlock("feedback");
691  $template->setVariable("FEEDBACK", $feedback);
692  $template->parseCurrentBlock();
693  }
694  }
695  }
696  }
697  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
698  try {
699  $template->setVariable("IMG_SRC", ilWACSignedPath::signFile($imagepath));
700  } catch (ilWACException $e) {
701 
702  }
703  $template->setVariable("IMG_ALT", $this->lng->txt("imagemap"));
704  $template->setVariable("IMG_TITLE", $this->lng->txt("imagemap"));
705  $questionoutput = $template->get();
706  $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
707  return $pageoutput;
708  }
static prepareFormOutput($a_str, bool $a_strip=false)
buildAreaLinkTarget($currentSelection, $areaIndex)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
static signFile(string $path_to_file)
addArea( $index, $shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assImagemapQuestionGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 164 of file class.assImagemapQuestionGUI.php.

165  {
166  return $form; // Nothing to do here since selectable areas are handled in question-specific-form part
167  // due to their immediate dependency to the image. I decide to not break up the interfaces
168  // more just to support this very rare case. tl;dr: See the issue, ignore it.
169  }

◆ populateCorrectionsFormProperties()

assImagemapQuestionGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 866 of file class.assImagemapQuestionGUI.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilImagemapFileInputGUI\setPointsUncheckedFieldEnabled().

866  : void
867  {
868  $image = new ilImagemapCorrectionsInputGUI($this->lng->txt('image'), 'image');
869  $image->setPointsUncheckedFieldEnabled($this->object->getIsMultipleChoice());
870  $image->setRequired(true);
871 
872  if (strlen($this->object->getImageFilename())) {
873  $image->setImage($this->object->getImagePathWeb() . $this->object->getImageFilename());
874  $image->setValue($this->object->getImageFilename());
875  $image->setAreas($this->object->getAnswers());
876  $assessmentSetting = new ilSetting("assessment");
877  $linecolor = (strlen(
878  $assessmentSetting->get("imap_line_color")
879  )) ? "\"#" . $assessmentSetting->get("imap_line_color") . "\"" : "\"#FF0000\"";
880  $image->setLineColor($linecolor);
881  $image->setImagePath($this->object->getImagePath());
882  $image->setImagePathWeb($this->object->getImagePathWeb());
883  }
884  $form->addItem($image);
885  }
setPointsUncheckedFieldEnabled($pointsUncheckedFieldEnabled)
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assImagemapQuestionGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 171 of file class.assImagemapQuestionGUI.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), assImagemapQuestion\MODE_MULTIPLE_CHOICE, assImagemapQuestion\MODE_SINGLE_CHOICE, ILIAS\Repository\object(), ilImagemapFileInputGUI\setPointsUncheckedFieldEnabled(), ilFormPropertyGUI\setRequired(), and ilRadioGroupInputGUI\setValue().

Referenced by buildEditForm().

172  {
173  $radioGroup = new ilRadioGroupInputGUI($this->lng->txt('tst_imap_qst_mode'), 'is_multiple_choice');
174  $radioGroup->setValue((string) ((int) ($this->object->getIsMultipleChoice())));
175  $modeSingleChoice = new ilRadioOption(
176  $this->lng->txt('tst_imap_qst_mode_sc'),
178  );
179  $modeMultipleChoice = new ilRadioOption(
180  $this->lng->txt('tst_imap_qst_mode_mc'),
182  );
183  $radioGroup->addOption($modeSingleChoice);
184  $radioGroup->addOption($modeMultipleChoice);
185  $form->addItem($radioGroup);
186 
187  $image = new ilImagemapFileInputGUI($this->lng->txt('image'), 'image');
188  $image->setPointsUncheckedFieldEnabled($this->object->getIsMultipleChoice());
189  $image->setRequired(true);
190 
191  if ($this->object->getImageFilename() !== '') {
192  $image->setImage($this->object->getImagePathWeb() . $this->object->getImageFilename());
193  $image->setValue($this->object->getImageFilename());
194  $image->setAreas($this->object->getAnswers());
195  $assessmentSetting = new ilSetting("assessment");
196  $linecolor = $assessmentSetting->get("imap_line_color") !== null
197  ? '"#' . $assessmentSetting->get('imap_line_color') . '"' : '"#FF0000"';
198  $image->setLineColor($linecolor);
199  $image->setImagePath($this->object->getImagePath());
200  $image->setImagePathWeb($this->object->getImagePathWeb());
201  }
202  $form->addItem($image);
203 
204  $imagemapfile = new ilHtmlImageMapFileInputGUI($this->lng->txt('add_imagemap'), 'imagemapfile');
205  $imagemapfile->setRequired(false);
206  $form->addItem($imagemapfile);
207  return $form;
208  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents an image map file property in a property form.
This class represents a property in a property form.
setRequired(bool $a_required)
setPointsUncheckedFieldEnabled($pointsUncheckedFieldEnabled)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

assImagemapQuestionGUI::saveCorrectionsFormProperties ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Definition at line 890 of file class.assImagemapQuestionGUI.php.

References ilPropertyFormGUI\getItemByPostVar(), and ILIAS\Repository\object().

890  : void
891  {
892  $areas = $form->getItemByPostVar('image')->getAreas();
893 
894  foreach ($this->object->getAnswers() as $index => $answer) {
895  if ($this->object->getIsMultipleChoice()) {
896  $answer->setPointsUnchecked((float) $areas[$index]->getPointsUnchecked());
897  }
898 
899  $answer->setPoints((float) $areas[$index]->getPoints());
900  }
901  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:

◆ saveShape()

assImagemapQuestionGUI::saveShape ( )

Definition at line 225 of file class.assImagemapQuestionGUI.php.

References assImagemapQuestion\AVAILABLE_SHAPES, ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

225  : void
226  {
227  $coords = '';
228 
229  $shape = $this->request_data_collector->string('shape');
230  $shape_title = $this->request_data_collector->string('shapetitle');
231  $image = $this->request_data_collector->raw('image', 2);
232 
233  switch ($shape) {
235  $coords = implode(',', $image['mapcoords']);
236  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_rect_added'), true);
237  break;
239  if (preg_match("/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $image['mapcoords'][0] . ' ' . $image['mapcoords'][1], $matches)) {
240  $coords = "$matches[1],$matches[2]," . (int) sqrt((($matches[3] - $matches[1]) * ($matches[3] - $matches[1])) + (($matches[4] - $matches[2]) * ($matches[4] - $matches[2])));
241  }
242  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_circle_added'), true);
243  break;
245  $coords = implode(',', $image['mapcoords']);
246  $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_poly_added'), true);
247  break;
248  }
249 
250  $this->object->addAnswer($shape_title, 0, count($this->object->getAnswers()), $coords, $shape);
251  $this->object->saveToDb();
252  $this->ctrl->redirect($this, 'editQuestion');
253  }
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assImagemapQuestionGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

Extracts the answer specific values from the request and applies them to the data object.

Implements ilGuiAnswerScoringAdjustable.

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

References ILIAS\Repository\ctrl(), ilPropertyFormGUI\getItemByPostVar(), ILIAS\Repository\object(), and ILIAS\Repository\refinery().

Referenced by writePostData().

85  : void
86  {
87  if ($this->ctrl->getCmd() !== 'deleteImage') {
88  $this->object->flushAnswers();
89 
90  $image = $this->request_data_collector->raw('image', 4);
91  if (isset($image['coords']['name'])) {
92  foreach ($image['coords']['name'] as $idx => $name) {
93  if ($this->object->getIsMultipleChoice() && isset($image['coords']['points_unchecked'])) {
94  $points_unchecked = $this->refinery->kindlyTo()->float()->transform($image['coords']['points_unchecked'][$idx]);
95  } else {
96  $points_unchecked = 0.0;
97  }
98 
99  $this->object->addAnswer(
100  $name,
101  $image['coords']['points'][$idx],
102  $idx,
103  $image['coords']['coords'][$idx],
104  $image['coords']['shape'][$idx],
105  $points_unchecked
106  );
107  }
108  }
109 
110  if ($_FILES['imagemapfile']['tmp_name'] !== '') {
111  if ($this->object->getId() < 1) {
112  $this->object->createNewQuestion();
113  }
114 
115  $this->object->uploadImagemap($form->getItemByPostVar('imagemapfile')?->getShapes());
116  }
117  }
118  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assImagemapQuestionGUI::writePostData ( bool  $always = false)
protected

{}

Definition at line 66 of file class.assImagemapQuestionGUI.php.

References buildEditForm(), editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), writeAnswerSpecificPostData(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

66  : int
67  {
68  $form = $this->buildEditForm();
69  $form->setValuesByPost();
70 
71  if (!$always && !$form->checkInput()) {
72  $this->edit_form = $form;
73  $this->editQuestion();
74  return 1;
75  }
76 
78  $this->writeQuestionSpecificPostData($form);
79  $this->writeAnswerSpecificPostData($form);
80  $this->saveTaxonomyAssignments();
81 
82  return 0;
83  }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object...
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assImagemapQuestionGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

Extracts the question specific values from the request and applies them to the data object.

Implements ilGuiQuestionScoringAdjustable.

Definition at line 120 of file class.assImagemapQuestionGUI.php.

References ILIAS\Repository\ctrl(), assImagemapQuestion\MODE_MULTIPLE_CHOICE, assImagemapQuestion\MODE_SINGLE_CHOICE, and ILIAS\Repository\object().

Referenced by writePostData().

120  : void
121  {
122  if ($this->ctrl->getCmd() !== 'deleteImage' && $_FILES['image']['tmp_name'] === '') {
123  $this->object->setImageFilename($this->request_data_collector->string('image_name'));
124  }
125  if ($_FILES['image']['tmp_name'] !== '') {
126  if ($this->object->getId() < 1) {
127  $this->object->createNewQuestion();
128  }
129  $this->object->setImageFilename($_FILES['image']['name'], $_FILES['image']['tmp_name']);
130  }
131 
132  $is_multiple_choice = $this->request_data_collector->int('is_multiple_choice') ?? assImagemapQuestion::MODE_SINGLE_CHOICE;
133  $this->object->setIsMultipleChoice($is_multiple_choice === assImagemapQuestion::MODE_MULTIPLE_CHOICE);
134  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $edit_form

ilPropertyFormGUI assImagemapQuestionGUI::$edit_form = null
private

Definition at line 36 of file class.assImagemapQuestionGUI.php.

Referenced by editQuestion().

◆ $linecolor

string assImagemapQuestionGUI::$linecolor
private

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