ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 Returns the answer specific feedback for the question. More...
 
 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 ()
 
 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)
 
 buildFileDownloadLink ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from the request and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 

Protected Member Functions

 writePostData (bool $always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} 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_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)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 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 ()
 
 resetSavedPreviewSession ()
 

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$ \ @ilCtrl_Calls 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.

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 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class for image map questions.
ILIAS Setting Class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addCircle()

assImagemapQuestionGUI::addCircle ( )

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

215 : void
216 {
217 $this->areaEditor('circle');
218 }

◆ addPoly()

assImagemapQuestionGUI::addPoly ( )

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

220 : void
221 {
222 $this->areaEditor('poly');
223 }

◆ addRect()

assImagemapQuestionGUI::addRect ( )

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

210 : void
211 {
212 $this->areaEditor('rect');
213 }

◆ aggregateAnswers()

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

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

818 : array
819 {
820 $answeringFequencies = [];
821
822 foreach ($existingAnswerOptions as $answerIndex => $answerOption) {
823 $answeringFequencies[$answerIndex] = 0;
824 }
825
826 foreach ($givenSolutionRows as $solutionRow) {
827 $answeringFequencies[$solutionRow['value1']]++;
828 }
829
830 return $answeringFequencies;
831 }

◆ areaEditor()

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

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

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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static signFile(string $path_to_file)
$c
Definition: deliver.php:25

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

+ Here is the call graph for this function:

◆ back()

assImagemapQuestionGUI::back ( )

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

383 : void
384 {
385 $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_cancel'), true);
386 $this->ctrl->redirect($this, 'editQuestion');
387 }

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

+ Here is the call graph for this function:

◆ buildAreaLinkTarget()

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

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

715 : string
716 {
717 $href = $this->ctrl->getLinkTargetByClass(
718 $this->getTargetGuiClass(),
719 $this->getQuestionActionCmd()
720 );
721
723 $href,
724 $this->buildSelectionParameter($currentSelection, $areaIndex)
725 );
726
727 return $href;
728 }
buildSelectionParameter($currentSelection, $areaIndex=null)
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)

References ilUtil\appendUrlParameterString(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ buildEditForm()

assImagemapQuestionGUI::buildEditForm ( )
protected
Returns
ilPropertyFormGUI

Reimplemented from assQuestionGUI.

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

140 {
141 $form = $this->buildBasicEditFormObject();
142
143 $this->addBasicQuestionFormProperties($form);
145 $this->populateTaxonomyFormSection($form);
146 $this->addQuestionFormCommandButtons($form);
147
148 return $form;
149 }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.

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

Referenced by editQuestion(), and writePostData().

+ 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 730 of file class.assImagemapQuestionGUI.php.

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

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

+ Here is the call graph for this function:

◆ completeTestOutputFormAction()

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

Reimplemented from assQuestionGUI.

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 }
$info
Definition: entry_point.php:21

◆ deleteImage()

assImagemapQuestionGUI::deleteImage ( )

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

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 }

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

+ Here is the call graph for this function:

◆ editQuestion()

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

Reimplemented from assQuestionGUI.

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

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)

References buildEditForm().

Referenced by writePostData().

+ 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 799 of file class.assImagemapQuestionGUI.php.

799 : array
800 {
801 return [];
802 }

◆ 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 813 of file class.assImagemapQuestionGUI.php.

813 : array
814 {
815 return [];
816 }

◆ getAnswersFrequency()

assImagemapQuestionGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

854 : array
855 {
856 $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
857
858 $answers = [];
859
860 foreach ($this->object->getAnswers() as $answerIndex => $ans) {
861 $answers[] = [
862 'answer' => $ans->getAnswerText(),
863 'frequency' => $agg[$answerIndex]
864 ];
865 }
866
867 return $answers;
868 }
aggregateAnswers($givenSolutionRows, $existingAnswerOptions)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

577 : string {
578 if (is_object($this->getPreviewSession())) {
579 $user_solution = [];
580
581 if (is_array($this->getPreviewSession()->getParticipantsSolution())) {
582 $user_solution = array_values($this->getPreviewSession()->getParticipantsSolution());
583 }
584
585 $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename());
586 foreach ($user_solution as $idx => $solution_value) {
587 if ($solution_value !== '') {
588 $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);
589 }
590 }
591 $preview->createPreview();
592 $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->getImageFilename());
593 } else {
594 $user_solution = [];
595 $imagepath = $this->object->getImagePathWeb() . $this->object->getImageFilename();
596 }
597
598 // generate the question output
599 $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
600
601 if ($this->getQuestionActionCmd() && !is_null($this->getTargetGuiClass())) {
602 $hrefArea = $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd());
603 } else {
604 $hrefArea = null;
605 }
606
607 foreach ($this->object->answers as $answer_id => $answer) {
608 $parameter = "&amp;selImage=$answer_id";
609 if (is_array($user_solution) && in_array($answer_id, $user_solution)) {
610 $parameter = "&amp;remImage=$answer_id";
611 }
612
613 if ($hrefArea) {
614 $template->setCurrentBlock("imagemap_area_href");
615 $template->setVariable("HREF_AREA", $hrefArea . $parameter);
616 $template->parseCurrentBlock();
617 }
618
619 $template->setCurrentBlock("imagemap_area");
620 $template->setVariable("SHAPE", $answer->getArea());
621 $template->setVariable("COORDS", $answer->getCoords());
622 $template->setVariable("ALT", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
623 $template->setVariable("TITLE", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
624 $template->parseCurrentBlock();
625 }
626 $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
627 try {
628 $template->setVariable("IMG_SRC", ilWACSignedPath::signFile($imagepath));
629 } catch (ilWACException $e) {
630
631 }
632 $template->setVariable("IMG_ALT", $this->lng->txt("imagemap"));
633 $template->setVariable("IMG_TITLE", $this->lng->txt("imagemap"));
634 $questionoutput = $template->get();
635 if (!$show_question_only) {
636 $questionoutput = $this->getILIASPage($questionoutput);
637 }
638 return $questionoutput;
639 }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareFormOutput($a_str, bool $a_strip=false)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getPreviousSolutionConfirmationCheckboxHtml()

assImagemapQuestionGUI::getPreviousSolutionConfirmationCheckboxHtml ( )
protected

Reimplemented from assQuestionGUI.

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

833 : string
834 {
835 if (!count($this->object->currentSolution)) {
836 return '';
837 }
838
839 global $DIC;
840 $button = $DIC->ui()->factory()->link()->standard(
841 $this->lng->txt('use_previous_solution'),
843 $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd()),
844 $this->buildSelectionParameter($this->object->currentSolution, null)
845 )
846 );
847
848 $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'components/ILIAS/TestQuestionPool');
849 $tpl->setVariable('BUTTON', $DIC->ui()->renderer()->render($button));
850
851 return $tpl->get();
852 }
ilGlobalPageTemplate $tpl
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
global $DIC
Definition: shib_login.php:26

References $DIC, ilUtil\appendUrlParameterString(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ 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 
)

Reimplemented from assQuestionGUI.

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

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,)

◆ getSpecificFeedbackOutput()

assImagemapQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

Parameters
array$userSolution($userSolution[<value1>] = <value2>)

Reimplemented from assQuestionGUI.

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

767 : string
768 {
769 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
770 return '';
771 }
772
773 $output = '<table class="test_specific_feedback"><tbody>';
774
775 foreach ($this->object->getAnswers() as $idx => $answer) {
776 $feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
777 $this->object->getId(),
778 0,
779 $idx
780 );
781
782 $output .= "<tr><td>{$answer->getAnswerText()}</td><td>{$feedback}</td></tr>";
783 }
784
785 $output .= '</tbody></table>';
786
788 }
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,...

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

+ 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 
)

Reimplemented from assQuestionGUI.

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

647 : string {
648 if ($active_id) {
649 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
650 // hey.
651
652 $userSelection = [];
653 $selectionIndex = 0;
654
655 $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename());
656
657 foreach ($solutions as $idx => $solution_value) {
658 if ($solution_value["value1"] !== null) {
659 $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);
660 $userSelection[$selectionIndex] = $solution_value["value1"];
661
662 $selectionIndex = $this->object->getIsMultipleChoice() ? ++$selectionIndex : $selectionIndex;
663 }
664 }
665
666 $preview->createPreview();
667
668 $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->getImageFilename());
669 } else {
670 $imagepath = $this->object->getImagePathWeb() . $this->object->getImageFilename();
671 }
672
673 // generate the question output
674 $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", true, true, "components/ILIAS/TestQuestionPool");
675 $this->ctrl->setParameterByClass($this->getTargetGuiClass(), "formtimestamp", time());
676 foreach ($this->object->answers as $answer_id => $answer) {
677 $template->setCurrentBlock("imagemap_area");
678 $template->setVariable("HREF_AREA", $this->buildAreaLinkTarget($userSelection, $answer_id));
679 $template->setVariable("SHAPE", $answer->getArea());
680 $template->setVariable("COORDS", $answer->getCoords());
681 $template->setVariable("ALT", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
682 $template->setVariable("TITLE", ilLegacyFormElementsUtil::prepareFormOutput($answer->getAnswertext()));
683 $template->parseCurrentBlock();
684 if ($show_specific_inline_feedback) {
685 if (!$this->object->getIsMultipleChoice() && count($userSelection) && current($userSelection) == $answer_id) {
686 $feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
687 $this->object->getId(),
688 0,
689 $answer_id
690 );
691 if ($feedback !== '') {
692 $template->setCurrentBlock("feedback");
693 $template->setVariable("FEEDBACK", $feedback);
694 $template->parseCurrentBlock();
695 }
696 }
697 }
698 }
699 $template->setVariable("QUESTIONTEXT", $this->renderLatex(
700 $this->object->getQuestionForHTMLOutput()
701 ));
702 try {
703 $template->setVariable("IMG_SRC", ilWACSignedPath::signFile($imagepath));
704 } catch (ilWACException $e) {
705
706 }
707 $template->setVariable("IMG_ALT", $this->lng->txt("imagemap"));
708 $template->setVariable("IMG_TITLE", $this->lng->txt("imagemap"));
709 $questionoutput = $template->get();
710 $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
711 return $pageoutput;
712 }
buildAreaLinkTarget($currentSelection, $areaIndex)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

References ILIAS\Repository\object().

+ 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)

Reimplemented from assQuestionGUI.

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

870 : void
871 {
872 $image = new ilImagemapCorrectionsInputGUI($this->lng->txt('image'), 'image');
873 $image->setPointsUncheckedFieldEnabled($this->object->getIsMultipleChoice());
874 $image->setRequired(true);
875
876 if (strlen($this->object->getImageFilename())) {
877 $image->setImage($this->object->getImagePathWeb() . $this->object->getImageFilename());
878 $image->setValue($this->object->getImageFilename());
879 $image->setAreas($this->object->getAnswers());
880 $assessmentSetting = new ilSetting("assessment");
881 $linecolor = (strlen(
882 $assessmentSetting->get("imap_line_color")
883 )) ? "\"#" . $assessmentSetting->get("imap_line_color") . "\"" : "\"#FF0000\"";
884 $image->setLineColor($linecolor);
885 $image->setImagePath($this->object->getImagePath());
886 $image->setImagePathWeb($this->object->getImagePathWeb());
887 }
888 $form->addItem($image);
889 }

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

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assImagemapQuestionGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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 class represents an image map file property in a property form.
This class represents a property in a property form.
This class represents an option in a radio group.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), assImagemapQuestion\MODE_MULTIPLE_CHOICE, assImagemapQuestion\MODE_SINGLE_CHOICE, and ILIAS\Repository\object().

Referenced by buildEditForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

894 : void
895 {
896 $areas = $form->getItemByPostVar('image')->getAreas();
897
898 foreach ($this->object->getAnswers() as $index => $answer) {
899 if ($this->object->getIsMultipleChoice()) {
900 $answer->setPointsUnchecked((float) $areas[$index]->getPointsUnchecked());
901 }
902
903 $answer->setPoints((float) $areas[$index]->getPoints());
904 }
905 }
getItemByPostVar(string $a_post_var)

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

+ Here is the call graph for this function:

◆ saveShape()

assImagemapQuestionGUI::saveShape ( )

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

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 }

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

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

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 }

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

Referenced by writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

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

{Evaluates a posted edit form and writes the form data in the question object.

Returns
integer A positive value, if one of the required fields wasn't set, else 0
}

Reimplemented from assQuestionGUI.

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

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
79 $this->writeAnswerSpecificPostData($form);
81
82 return 0;
83 }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object.
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.

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

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

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 }

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

Referenced by writePostData().

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

◆ $linecolor

string assImagemapQuestionGUI::$linecolor
private

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


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