ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExerciseGSToolProvider Class Reference

Taxonomy GS tool provider. More...

+ Inheritance diagram for ilExerciseGSToolProvider:
+ Collaboration diagram for ilExerciseGSToolProvider:

Public Member Functions

 isInterestedInContexts ()
 
 getToolsForContextStack (CalledContexts $called_contexts)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider
 __construct (Container $dic)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 

Data Fields

const SHOW_EXC_ASSIGNMENT_INFO = 'show_exc_assignment_info'
 
const EXC_ASS_IDS = 'exc_ass_ids'
 
const EXC_ASS_BUTTONS = "exc_ass_buttons"
 

Protected Member Functions

 addSection (ilTemplate $tpl, string $title, string $content)
 
- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 

Private Member Functions

 getAssignmentInfo (array $ass_ids, array $buttons)
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider
ToolIdentificationProviderInterface $identification_provider
 
ContextCollection $context_collection
 
ToolFactory $factory
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
Container $dic
 

Detailed Description

Taxonomy GS tool provider.

Author
Alex Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..com

Definition at line 29 of file class.ilExerciseGSToolProvider.php.

Member Function Documentation

◆ addSection()

ilExerciseGSToolProvider::addSection ( ilTemplate  $tpl,
string  $title,
string  $content 
)
protected

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

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by getAssignmentInfo().

175  : void {
176  $tpl->setCurrentBlock("section");
177  $tpl->setVariable("TITLE", $title);
178  $tpl->setVariable("CONTENT", $content);
179  $tpl->parseCurrentBlock();
180  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentInfo()

ilExerciseGSToolProvider::getAssignmentInfo ( array  $ass_ids,
array  $buttons 
)
private
Parameters
int[]$ass_ids
Button[][]$buttons
Returns
string
Exceptions
ilDateTimeException
ilExcUnknownAssignmentTypeException

Definition at line 90 of file class.ilExerciseGSToolProvider.php.

References Vendor\Package\$b, $DIC, $i, $lng, $ref_id, $tpl, ilObject\_getAllReferences(), ilLink\_getLink(), ilObject\_lookupTitle(), addSection(), and ilExAssignment\lookupExerciseId().

Referenced by getToolsForContextStack().

93  : string {
94  global $DIC;
95 
96  $lng = $DIC->language();
97  $user = $DIC->user();
98  $ui = $DIC->ui();
99  $access = $DIC->access();
100 
101  $html = "";
102 
103  foreach ($ass_ids as $ass_id) {
104  $info = new ilExAssignmentInfo($ass_id, $user->getId());
105  $exc_id = ilExAssignment::lookupExerciseId($ass_id);
106  $readable_ref_id = 0;
107  foreach (ilObject::_getAllReferences($exc_id) as $ref_id) {
108  if ($access->checkAccess("read", "", $ref_id)) {
109  $readable_ref_id = $ref_id;
110  }
111  }
112 
113  $tpl = new ilTemplate("tpl.ass_info_tool.html", true, true, "Modules/Exercise");
114  $assignment = new ilExAssignment($ass_id);
115 
116  $title = ilObject::_lookupTitle($exc_id) . ": " . $assignment->getTitle();
117  if ($readable_ref_id > 0) {
118  $title = $ui->renderer()->render(
119  $ui->factory()->link()->standard($title, ilLink::_getLink($readable_ref_id))
120  );
121  }
122 
123  $this->addSection($tpl, $lng->txt("exc_assignment"), $title);
124 
125  // schedule info
126  $schedule = $info->getScheduleInfo();
127  $list = $ui->factory()->listing()->unordered(array_map(function ($i) {
128  return $i["txt"] . ": " . $i["value"];
129  }, $schedule));
130  $this->addSection($tpl, $lng->txt("exc_schedule"), $ui->renderer()->render($list));
131 
132  // latest submission
133  $subm = $info->getSubmissionInfo();
134  if (isset($subm["submitted"])) {
135  $this->addSection($tpl, $subm["submitted"]["txt"], $subm["submitted"]["value"]);
136  }
137 
138  // instruction
139  $inst = $info->getInstructionInfo();
140  if (count($inst)) {
141  $this->addSection($tpl, $inst["instruction"]["txt"], $inst["instruction"]["value"]);
142  }
143 
144  // instruction files
145  $files = $info->getInstructionFileInfo($readable_ref_id);
146  if (is_array($files)) {
147  $list = $ui->factory()->listing()->unordered(array_map(function ($i) use ($ui) {
148  $v = $i["txt"];
149  if ($i["value"] != "") {
150  $v = $ui->renderer()->render($ui->factory()->button()->shy($v, $i["value"]));
151  }
152  return $v;
153  }, $files));
154  $this->addSection($tpl, $lng->txt("exc_instruction_files"), $ui->renderer()->render($list));
155  }
156 
157  // buttons
158  if (isset($buttons[$ass_id])) {
159  $tpl->setVariable("BUTTONS", implode(" ", array_map(function ($b) use ($ui) {
160  return $ui->renderer()->render($b);
161  }, $buttons[$ass_id])));
162  }
163 
164  $tpl->setCurrentBlock("ass_info");
165  $tpl->parseCurrentBlock();
166  $html .= $tpl->get();
167  }
168  return $html;
169  }
Exercise assignment.
$lng
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
addSection(ilTemplate $tpl, string $title, string $content)
static lookupExerciseId(int $a_ass_id)
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getToolsForContextStack()

ilExerciseGSToolProvider::getToolsForContextStack ( CalledContexts  $called_contexts)
Parameters
CalledContexts$called_contexts
Returns
Tool[] These Slates can be passed to the MainMenu dynamic for a specific location/context.
See also
DynamicProvider
Exceptions
ilExcUnknownAssignmentTypeException
ilDateTimeException

Implements ILIAS\GlobalScreen\Scope\Tool\Provider\DynamicToolProvider.

Definition at line 40 of file class.ilExerciseGSToolProvider.php.

References $DIC, $id, $lng, ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts\current(), and getAssignmentInfo().

42  : array {
43  global $DIC;
44 
45  $lng = $DIC->language();
46  $lng->loadLanguageModule("exc");
47 
48  $title = $lng->txt("exc_assignment");
49  $icon = $this->dic->ui()->factory()->symbol()->icon()->standard("exc", $title);
50 
51  $tools = [];
52  $additional_data = $called_contexts->current()->getAdditionalData();
53  if ($additional_data->is(self::SHOW_EXC_ASSIGNMENT_INFO, true)) {
54  $iff = function ($id) {
55  return $this->identification_provider->contextAwareIdentifier($id);
56  };
57  $l = function (string $content) {
58  return $this->dic->ui()->factory()->legacy($content);
59  };
60  $tools[] = $this->factory->tool($iff("exc_ass_info"))
61  ->withTitle($title)
62  ->withSymbol($icon)
63  ->withContentWrapper(
68  function () use ($l, $additional_data) {
69  $buttons = $additional_data->exists(self::EXC_ASS_BUTTONS)
70  ? $additional_data->get(self::EXC_ASS_BUTTONS)
71  : [];
72  return $l($this->getAssignmentInfo(
73  $additional_data->get(self::EXC_ASS_IDS),
74  $buttons
75  ));
76  }
77  );
78  }
79 
80  return $tools;
81  }
$lng
getAssignmentInfo(array $ass_ids, array $buttons)
global $DIC
Definition: feed.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ isInterestedInContexts()

ilExerciseGSToolProvider::isInterestedInContexts ( )

Field Documentation

◆ EXC_ASS_BUTTONS

const ilExerciseGSToolProvider::EXC_ASS_BUTTONS = "exc_ass_buttons"

◆ EXC_ASS_IDS

◆ SHOW_EXC_ASSIGNMENT_INFO

const ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO = 'show_exc_assignment_info'

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