ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 ()
 
 supportsAdjustment ()
 
- 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...
 
UIServices $ui
 
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 212 of file class.assImagemapQuestionGUI.php.

212 : void
213 {
214 $this->areaEditor('circle');
215 }

◆ addPoly()

assImagemapQuestionGUI::addPoly ( )

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

217 : void
218 {
219 $this->areaEditor('poly');
220 }

◆ addRect()

assImagemapQuestionGUI::addRect ( )

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

207 : void
208 {
209 $this->areaEditor('rect');
210 }

◆ aggregateAnswers()

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

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

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

◆ areaEditor()

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

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

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

References Vendor\Package\$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 380 of file class.assImagemapQuestionGUI.php.

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

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

712 : string
713 {
714 $href = $this->ctrl->getLinkTargetByClass(
715 $this->getTargetGuiClass(),
716 $this->getQuestionActionCmd()
717 );
718
720 $href,
721 $this->buildSelectionParameter($currentSelection, $areaIndex)
722 );
723
724 return $href;
725 }
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 136 of file class.assImagemapQuestionGUI.php.

137 {
138 $form = $this->buildBasicEditFormObject();
139
140 $this->addBasicQuestionFormProperties($form);
142 $this->populateTaxonomyFormSection($form);
143 $this->addQuestionFormCommandButtons($form);
144
145 return $form;
146 }
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 727 of file class.assImagemapQuestionGUI.php.

727 : string
728 {
729 if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
730 $reuseSelection = [];
731
732 if ($areaIndex === null) {
733 $reuseSelection = $currentSelection;
734 } elseif ($this->object->getIsMultipleChoice()) {
735 if (!in_array($areaIndex, $currentSelection)) {
736 $reuseSelection[] = $areaIndex;
737 }
738
739 foreach (array_diff($currentSelection, [$areaIndex]) as $otherSelectedArea) {
740 $reuseSelection[] = $otherSelectedArea;
741 }
742 } else {
743 $reuseSelection[] = $areaIndex;
744 }
745
746 $selection = assQuestion::implodeKeyValues($reuseSelection);
747 $action = 'reuseSelection';
748 } elseif ($areaIndex !== null) {
749 if (!$this->object->getIsMultipleChoice() || !in_array($areaIndex, $currentSelection)) {
750 $areaAction = 'selImage';
751 } else {
752 $areaAction = 'remImage';
753 }
754
755 $selection = $areaIndex;
756 $action = $areaAction;
757 } else {
758 return '';
759 }
760
761 return "{$action}={$selection}";
762 }
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 386 of file class.assImagemapQuestionGUI.php.

390 : string {
391 $info = $this->object->getTestOutputSolutions($active_id, $pass);
392 return $form_action . (($info !== [] && $info[0]['value1'] !== '') ? '&selImage=' . $info[0]['value1'] : '');
393 }
$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 148 of file class.assImagemapQuestionGUI.php.

151 : bool {
152 $form = $this->edit_form;
153 if ($form === null) {
154 $form = $this->buildEditForm();
155 }
156
157 $this->renderEditForm($form);
158 return false;
159 }
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 796 of file class.assImagemapQuestionGUI.php.

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

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

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

◆ getAnswersFrequency()

assImagemapQuestionGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

851 : array
852 {
853 $agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());
854
855 $answers = [];
856
857 foreach ($this->object->getAnswers() as $answerIndex => $ans) {
858 $answers[] = [
859 'answer' => $ans->getAnswerText(),
860 'frequency' => $agg[$answerIndex]
861 ];
862 }
863
864 return $answers;
865 }
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 571 of file class.assImagemapQuestionGUI.php.

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

830 : string
831 {
832 if (!count($this->object->currentSolution)) {
833 return '';
834 }
835
836 global $DIC;
837 $button = $DIC->ui()->factory()->link()->standard(
838 $this->lng->txt('use_previous_solution'),
840 $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd()),
841 $this->buildSelectionParameter($this->object->currentSolution, null)
842 )
843 );
844
845 $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'components/ILIAS/TestQuestionPool');
846 $tpl->setVariable('BUTTON', $DIC->ui()->renderer()->render($button));
847
848 return $tpl->get();
849 }
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, ILIAS\News\Common\Table\$tpl, ilUtil\appendUrlParameterString(), ILIAS\UICore\GlobalTemplate\get(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\UICore\GlobalTemplate\setVariable().

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

406 : string {
407 $user_solutions = [];
408 if (($active_id > 0) && (!$show_correct_solution)) {
409 $user_solutions = $this->object->getSolutionValues($active_id, $pass);
410 } else {
411 if (!$this->object->getIsMultipleChoice()) {
412 $found_index = -1;
413 $max_points = 0;
414 foreach ($this->object->answers as $index => $answer) {
415 if ($answer->getPoints() > $max_points) {
416 $max_points = $answer->getPoints();
417 $found_index = $index;
418 }
419 }
420 array_push($user_solutions, ["value1" => $found_index]);
421 } else {
422 // take the correct solution instead of the user solution
423 foreach ($this->object->answers as $index => $answer) {
424 $points_checked = $answer->getPoints();
425 $points_unchecked = $answer->getPointsUnchecked();
426 if ($points_checked > $points_unchecked) {
427 if ($points_checked > 0) {
428 array_push($user_solutions, ["value1" => $index]);
429 }
430 }
431 }
432 }
433 }
434
435 return $this->renderSolutionOutput(
436 $user_solutions,
437 $active_id,
438 $pass,
439 $graphical_output,
440 $result_output,
441 $show_question_only,
442 $show_feedback,
443 $show_correct_solution,
444 $show_manual_scoring,
445 $show_question_text,
446 false,
447 $show_inline_feedback,
448 );
449 }
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 764 of file class.assImagemapQuestionGUI.php.

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

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

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

◆ populateCorrectionsFormProperties()

assImagemapQuestionGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

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

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

169 {
170 $radioGroup = new ilRadioGroupInputGUI($this->lng->txt('tst_imap_qst_mode'), 'is_multiple_choice');
171 $radioGroup->setValue((string) ((int) ($this->object->getIsMultipleChoice())));
172 $modeSingleChoice = new ilRadioOption(
173 $this->lng->txt('tst_imap_qst_mode_sc'),
175 );
176 $modeMultipleChoice = new ilRadioOption(
177 $this->lng->txt('tst_imap_qst_mode_mc'),
179 );
180 $radioGroup->addOption($modeSingleChoice);
181 $radioGroup->addOption($modeMultipleChoice);
182 $form->addItem($radioGroup);
183
184 $image = new ilImagemapFileInputGUI($this->lng->txt('image'), 'image');
185 $image->setPointsUncheckedFieldEnabled($this->object->getIsMultipleChoice());
186 $image->setRequired(true);
187
188 if ($this->object->getImageFilename() !== '') {
189 $image->setImage($this->object->getImagePathWeb() . $this->object->getImageFilename());
190 $image->setValue($this->object->getImageFilename());
191 $image->setAreas($this->object->getAnswers());
192 $assessmentSetting = new ilSetting("assessment");
193 $linecolor = $assessmentSetting->get("imap_line_color") !== null
194 ? '"#' . $assessmentSetting->get('imap_line_color') . '"' : '"#FF0000"';
195 $image->setLineColor($linecolor);
196 $image->setImagePath($this->object->getImagePath());
197 $image->setImagePathWeb($this->object->getImagePathWeb());
198 }
199 $form->addItem($image);
200
201 $imagemapfile = new ilHtmlImageMapFileInputGUI($this->lng->txt('add_imagemap'), 'imagemapfile');
202 $imagemapfile->setRequired(false);
203 $form->addItem($imagemapfile);
204 return $form;
205 }
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 891 of file class.assImagemapQuestionGUI.php.

891 : void
892 {
893 $areas = $form->getItemByPostVar('image')->getAreas();
894
895 foreach ($this->object->getAnswers() as $index => $answer) {
896 if ($this->object->getIsMultipleChoice()) {
897 $answer->setPointsUnchecked((float) $areas[$index]->getPointsUnchecked());
898 }
899
900 $answer->setPoints((float) $areas[$index]->getPoints());
901 }
902 }
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 222 of file class.assImagemapQuestionGUI.php.

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

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 ($_FILES['image']['tmp_name'] !== '') {
123 if ($this->object->getId() < 1) {
124 $this->object->createNewQuestion();
125 }
126 $this->object->uploadImageFile($_FILES['image']['name'], $_FILES['image']['tmp_name']);
127 }
128
129 $is_multiple_choice = $this->request_data_collector->int('is_multiple_choice') ?? assImagemapQuestion::MODE_SINGLE_CHOICE;
130 $this->object->setIsMultipleChoice($is_multiple_choice === assImagemapQuestion::MODE_MULTIPLE_CHOICE);
131 }

References 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: