19 declare(strict_types=0);
43 ?
object $a_parent_obj,
46 bool $a_print_mode =
false 49 $this->objDefinition = $DIC[
'objDefinition'];
50 $this->rbacsystem = $DIC->rbac()->system();
51 $this->
access = $DIC->access();
52 $this->ref_id = $a_ref_id;
56 $this->
setId(
"trsmy");
58 if (!$this->is_root) {
62 if (!$this->objDefinition->isContainer($type)) {
70 $DIC->repositoryTree()->checkForParentType($this->ref_id,
'grp')
72 $this->is_in_group =
true;
75 $DIC->repositoryTree()->checkForParentType($this->ref_id,
'crs')
77 $this->is_in_course =
true;
86 $this->
parseTitle($this->obj_id,
"trac_summary");
97 if (in_array($c, [
"status",
"mark",
"language",
"country",
"gender",
"city",
"sel_country"])) {
100 $this->
addColumn($labels[$c][
"txt"], $c);
104 if ($this->is_root) {
112 $this->
ctrl->getFormActionByClass(get_class($this))
114 $this->
setRowTemplate(
"tpl.trac_summary_row.html",
"Services/Tracking");
117 $this->
getItems($a_parent_obj->getObjId(), $a_ref_id);
122 $lng_map = array(
"user_total" =>
"users",
123 "first_access_min" =>
"trac_first_access",
124 "last_access_max" =>
"trac_last_access",
125 "mark" =>
"trac_mark",
126 "status" =>
"trac_status",
127 'status_changed_max' =>
'trac_status_changed',
128 "spent_seconds_avg" =>
"trac_spent_seconds",
129 "percentage_avg" =>
"trac_percentage",
130 "read_count_sum" =>
"trac_read_count",
131 "read_count_avg" =>
"trac_read_count",
132 "read_count_spent_seconds_avg" =>
"trac_read_count_spent_seconds" 135 $all = array(
"user_total");
140 if ($tracking->hasExtendedData(
143 $all[] =
"read_count_sum";
144 $all[] =
"read_count_avg";
145 $default[] =
"read_count_sum";
147 if ($tracking->hasExtendedData(
153 $all[] =
"spent_seconds_avg";
154 $default[] =
"spent_seconds_avg";
157 if ($tracking->hasExtendedData(
160 $tracking->hasExtendedData(
166 $all[] =
"read_count_spent_seconds_avg";
174 $all[] =
"percentage_avg";
177 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
179 $all[] =
'status_changed_max';
188 $privacy = array(
"gender",
"city",
"country",
"sel_country");
189 foreach ($privacy as $field) {
191 ($this->is_in_course && $this->setting->get(
"usr_settings_course_export_" . $field)) ||
192 ($this->is_in_group && $this->setting->get(
"usr_settings_group_export_" . $field))
200 $default[] =
"percentage_avg";
201 $default[] =
"status";
204 if ($tracking->hasExtendedData(
207 $all[] =
"first_access_min";
208 $all[] =
"last_access_max";
211 $all[] =
"create_date_min";
212 $all[] =
"create_date_max";
219 if (substr($l, -3) ==
"avg") {
221 } elseif (substr($l, -3) ==
"sum" || $l ==
"user_total") {
225 if (isset($lng_map[$l])) {
233 array(
"read_count_avg",
238 $txt .=
" / " . $this->
lng->txt(
"user");
243 "default" => (in_array($column, $default) ?
true :
false)
251 if ($this->is_root) {
252 parent::initBaseFilter(
true,
false);
263 "∑ " . $this->
lng->txt(
"users")
265 $this->
filter[
"user_total"] = $item->getValue();
267 if ($tracking->hasExtendedData(
274 "∑ " . $this->
lng->txt(
"trac_read_count")
276 $this->filter[
"read_count"] = $item->getValue();
279 if ($tracking->hasExtendedData(
289 "Ø " . $this->
lng->txt(
291 ) .
" / " . $this->
lng->txt(
"user")
293 $this->filter[
"spent_seconds"][
"from"] = $item->getCombinationItem(
295 )->getValueInSeconds();
296 $this->filter[
"spent_seconds"][
"to"] = $item->getCombinationItem(
298 )->getValueInSeconds();
309 "Ø " . $this->
lng->txt(
311 ) .
" / " . $this->
lng->txt(
"user")
313 $this->filter[
"percentage"] = $item->getValue();
316 if ($this->is_root || !$this->olp || $this->olp->isActive()) {
323 array(
"" => $this->
lng->txt(
"trac_all"),
338 $this->filter[
"status"] = $item->getValue();
339 if ($this->filter[
"status"]) {
340 $this->filter[
"status"]--;
344 "status_changed_max",
347 $this->
lng->txt(
"trac_status_changed")
349 $this->filter[
"status_changed"] = $item->getDate();
359 $this->
lng->txt(
"trac_mark")
361 $this->filter[
"mark"] = $item->getValue();
364 if ($this->setting->get(
"usr_settings_course_export_gender")) {
372 "" => $this->
lng->txt(
"trac_all"),
373 "n" => $this->
lng->txt(
"gender_n"),
374 "m" => $this->
lng->txt(
"gender_m"),
375 "f" => $this->
lng->txt(
"gender_f"),
378 $this->filter[
"gender"] = $item->getValue();
381 if ($this->setting->get(
"usr_settings_course_export_city")) {
387 $this->filter[
"city"] = $item->getValue();
390 if ($this->setting->get(
"usr_settings_course_export_country")) {
396 $this->filter[
"country"] = $item->getValue();
399 if ($this->setting->get(
"usr_settings_course_export_sel_country")) {
406 array(
"" => $this->
lng->txt(
411 $this->filter[
"sel_country"] = $item->getValue();
419 $this->filter[
"language"] = $item->getValue();
421 if ($tracking->hasExtendedData(
428 $this->
lng->txt(
"trac_first_access")
430 $this->filter[
"first_access"] = $item->getDate();
436 $this->
lng->txt(
"trac_last_access")
438 $this->filter[
"last_access"] = $item->getDate();
442 "registration_filter",
446 $this->filter[
"registration"] = $item->getDate();
453 $options[
$c] = $this->
lng->txt(
"meta_c_" . $c);
462 public function getItems(
int $a_object_id,
int $a_ref_id): void
465 $preselected_obj_ids =
$filter = null;
475 $preselected_obj_ids[$a_object_id][] = $a_ref_id;
476 foreach ($collection->getItems() as $item => $item_info) {
480 if ($tmp_lp->isActive()) {
487 } elseif ($this->is_root) {
492 "read_learning_progress" 517 $status_map = array();
519 foreach ($valid_status as $status) {
520 $status_map[$status] = $status_icons->renderIconForStatus($status);
524 $this->
lng->loadLanguageModule(
"meta");
525 $languages = array();
526 foreach ($this->
lng->getInstalledLanguages() as $lang_key) {
527 $languages[$lang_key] = $this->
lng->txt(
"meta_l_" . $lang_key);
531 foreach (
$data[
"set"] as $idx => $result) {
533 if ($result[
"title"] ==
"" && $result[
"type"] ==
"sess") {
535 $data[
"set"][$idx][
"title"] = $sess->getFirstAppointment(
536 )->appointmentToString();
545 if ($result[
"ref_ids"]) {
547 foreach ($result[
"ref_ids"] as $check_ref_id) {
549 'read_learning_progress',
557 foreach (array_keys(
$data[
"set"][$idx]) as $col_id) {
567 $data[
"set"][$idx][$col_id] = null;
570 $data[
"set"][$idx][
"privacy_conflict"] =
true;
576 $users_no = $result[
"user_total"];
585 "n" => $this->
lng->txt(
"gender_n"),
586 "m" => $this->
lng->txt(
"gender_m"),
587 "f" => $this->
lng->txt(
"gender_f"),
595 $result[
"sel_country"],
610 foreach ($result[
"status"] as $status_code => $status_counter) {
612 if ($status_code ===
"" || !in_array(
618 unset($result[
"status"][$status_code]);
628 $data[
"set"][$idx][
"percentage_avg"] = null;
642 array $value_map = null,
658 $counter = $others_counter = 0;
659 $others_sum = $overall;
667 if ($value_map && isset($value_map[
$id])) {
668 $caption = $value_map[
$id];
670 if ($caption ==
"") {
671 $caption = $this->
lng->txt(
"none");
680 $perc = round($count / $overall * 100);
682 "caption" => $caption,
683 "absolute" => $count,
685 "percentage" => $perc
687 $others_sum -= $count;
693 if ($others_counter) {
694 $perc = round($others_sum / $overall * 100);
696 "caption" => $others_counter .
" " . $this->
lng->txt(
699 "absolute" => $others_sum,
701 "percentage" => $perc
715 array $value_map = null
718 foreach ($value_map as
$id => $caption) {
723 $perc = round($count / $overall * 100);
726 "caption" => $caption,
727 "absolute" => $count,
728 "percentage" => $perc
741 $pos = strrpos($id,
"_");
742 if ($pos !==
false) {
743 $function = strtoupper(substr($id, $pos + 1));
746 array(
"MIN",
"MAX",
"SUM",
"AVG",
"COUNT")
748 $id = substr($id, 0, $pos);
752 if (trim($value) ==
"") {
753 if ($id ==
"title") {
754 return "--" . $this->
lng->txt(
"none") .
"--";
759 case 'status_changed':
773 case "spent_seconds":
774 case "read_count_spent_seconds":
789 $value = $value .
"%";
806 protected function fillRow(array $a_set): void
808 $this->tpl->setVariable(
811 (
int) $a_set[
"obj_id"],
816 $this->tpl->setVariable(
"ICON_ALT", $this->
lng->txt($a_set[
"type"]));
817 $this->tpl->setVariable(
"TITLE", $a_set[
"title"]);
819 if ($a_set[
"offline"] || ($a_set[
"privacy_conflict"] ?? null)) {
821 if ($a_set[
"offline"]) {
822 $mess[] = $this->
lng->txt(
"offline");
824 if ($a_set[
"privacy_conflict"] ?? null) {
825 $mess[] = $this->
lng->txt(
"status_no_permission");
827 $this->tpl->setCurrentBlock(
"status_bl");
828 $this->tpl->setVariable(
"TEXT_STATUS", implode(
", ", $mess));
829 $this->tpl->parseCurrentBlock();
844 case "percentage_avg":
848 $this->tpl->setVariable(strtoupper($c),
"");
854 $value = $this->
parseValue($c, $a_set[$c], $a_set[
"type"]);
855 $this->tpl->setVariable(strtoupper($c), $value);
860 if ($this->is_root) {
863 $this->tpl->setCurrentBlock(
"item_path");
864 foreach (
$path as $ref_id => $path_item) {
865 $this->tpl->setVariable(
"PATH_ITEM", $path_item);
867 if (!$this->anonymized) {
868 $this->
ctrl->setParameterByClass(
869 $this->
ctrl->getCmdClass(),
873 $this->tpl->setVariable(
875 $this->
ctrl->getLinkTargetByClass(
876 $this->ctrl->getCmdClass(),
880 $this->
ctrl->setParameterByClass(
881 $this->
ctrl->getCmdClass(),
885 $this->tpl->setVariable(
892 $this->tpl->setVariable(
899 $this->tpl->setVariable(
901 $this->
lng->txt(
'view')
905 $this->tpl->parseCurrentBlock();
909 $this->tpl->setCurrentBlock(
"item_command");
910 $this->
ctrl->setParameterByClass(
915 $this->tpl->setVariable(
917 $this->
ctrl->getLinkTargetByClass(
922 $this->tpl->setVariable(
924 $this->
lng->txt(
'trac_hide')
926 $this->tpl->parseCurrentBlock();
928 $this->tpl->touchBlock(
"path_action");
929 } elseif ($a_set[
"ref_ids"]) {
934 (
int) array_pop($a_set[
"ref_ids"])
937 $this->tpl->setVariable(
939 $this->
lng->txt(
'path') .
': ' .
$path 948 foreach ($data as $item) {
949 $this->tpl->setCurrentBlock($id .
"_row");
950 $this->tpl->setVariable(
"CAPTION", $item[
"caption"]);
951 $this->tpl->setVariable(
"ABSOLUTE", $item[
"absolute"]);
952 $this->tpl->setVariable(
"PERCENTAGE", $item[
"percentage"]);
953 $this->tpl->parseCurrentBlock();
956 $this->tpl->touchBlock($id);
980 $pos = strrpos($a_field,
"_");
981 if ($pos !==
false) {
982 $function = strtoupper(substr($a_field, $pos + 1));
985 array(
"MIN",
"MAX",
"SUM",
"AVG",
"COUNT",
"TOTAL")
1000 $a_excel->
setCell($a_row, 0, $this->
lng->txt(
"title"));
1005 $label = $labels[
$c][
"txt"];
1006 $label = str_replace(
1008 $this->
lng->txt(
"trac_average"),
1011 $label = str_replace(
1013 $this->
lng->txt(
"trac_sum"),
1018 $a_excel->
setCell($a_row, $cnt, $label);
1021 if ($c !=
"status") {
1022 $a_excel->
setCell($a_row, $cnt, $label .
" #1");
1023 $a_excel->
setCell($a_row, ++$cnt, $label .
" #1");
1024 $a_excel->
setCell($a_row, ++$cnt, $label .
" #1 %");
1025 $a_excel->
setCell($a_row, ++$cnt, $label .
" #2");
1026 $a_excel->
setCell($a_row, ++$cnt, $label .
" #2");
1027 $a_excel->
setCell($a_row, ++$cnt, $label .
" #2 %");
1028 $a_excel->
setCell($a_row, ++$cnt, $label .
" #3");
1029 $a_excel->
setCell($a_row, ++$cnt, $label .
" #3");
1030 $a_excel->
setCell($a_row, ++$cnt, $label .
" #3 %");
1034 $label .
" " . $this->
lng->txt(
1041 $label .
" " . $this->
lng->txt(
1048 $label .
" " . $this->
lng->txt(
1060 foreach ($valid_status as $status) {
1064 $a_excel->
setCell($a_row, ++$cnt, $text);
1065 $a_excel->
setCell($a_row, ++$cnt, $text .
" %");
1082 $a_excel->
setCell($a_row, 0, $a_set[
"title"]);
1087 $val = $this->
parseValue($c, $a_set[$c], $a_set[
"type"]);
1088 $a_excel->
setCell($a_row, $cnt, $val);
1091 foreach ((array) $a_set[$c] as $idx => $value) {
1092 if ($c ==
"status") {
1096 (
int) $value[
"absolute"]
1101 $value[
"percentage"] .
"%" 1104 $a_excel->
setCell($a_row, $cnt, $value[
"caption"]);
1108 (
int) $value[
"absolute"]
1113 $value[
"percentage"] .
"%" 1118 if (
sizeof($a_set[$c]) < 4 && $c !=
"status") {
1119 for ($loop = 4; $loop >
sizeof($a_set[
$c]); $loop--) {
1120 $a_excel->
setCell($a_row, $cnt,
"");
1121 $a_excel->
setCell($a_row, ++$cnt,
"");
1122 $a_excel->
setCell($a_row, ++$cnt,
"");
1136 $label = $labels[
$c][
"txt"];
1137 $label = str_replace(
1139 $this->
lng->txt(
"trac_average"),
1142 $label = str_replace(
1144 $this->
lng->txt(
"trac_sum"),
1151 if ($c !=
"status") {
1162 $label .
" " . $this->
lng->txt(
"trac_others")
1165 $label .
" " . $this->
lng->txt(
"trac_others")
1168 $label .
" " . $this->
lng->txt(
"trac_others") .
" %" 1177 foreach ($valid_status as $status) {
1197 $val = $this->
parseValue($c, $a_set[$c], $a_set[
"type"]);
1200 foreach ((array) $a_set[$c] as $idx => $value) {
1201 if ($c !=
"status") {
1204 $a_csv->
addColumn((
string) $value[
"absolute"]);
1205 $a_csv->
addColumn($value[
"percentage"]);
1207 if (
sizeof($a_set[$c]) < 4 && $c !=
"status") {
1208 for ($loop = 4; $loop >
sizeof($a_set[
$c]); $loop--) {
const LP_STATUS_COMPLETED_NUM
__construct(?object $a_parent_obj, string $a_parent_cmd, int $a_ref_id, bool $a_print_mode=false)
Constructor.
parseValue(string $id, ?string $value, string $type)
Creates a path for a start and endnode.
const EXTENDED_DATA_LAST_ACCESS
fillRow(array $a_set)
Fill table row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
getCurrentFilter(bool $as_query=false)
setExportFormats(array $formats)
Set available export formats.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
const LP_MODE_MANUAL_BY_TUTOR
setFormAction(string $a_form_action, bool $a_multipart=false)
numericOrdering(string $a_field)
fillHeaderCSV(ilCSVWriter $a_csv)
buildPath(array $ref_ids)
const LP_STATUS_NOT_ATTEMPTED
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getItems(int $a_object_id, int $a_ref_id)
Build summary item rows for given object and filter(s.
searchObjects(array $filter, string $permission, ?array $preset_obj_ids=null, bool $a_check_lp_activation=true)
Search objects that match current filters.
getColumnCoord(int $a_col)
Get column "name" from number.
setShowTemplates(bool $a_value)
const LP_STATUS_IN_PROGRESS_NUM
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const LP_MODE_COLLECTION_MANUAL
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
setPrintMode(bool $a_value=false)
const EXTENDED_DATA_READ_COUNT
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
getItemsPercentages( $data=null, int $overall=0, array $value_map=null, $limit=3)
Render data as needed for summary list (based on grouped values)
isArrayColumn(string $a_name)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
const FILTER_NUMBER_RANGE
const LP_STATUS_IN_PROGRESS
static _lookupObjId(int $ref_id)
static getObjectsSummaryForObject(int $a_parent_obj_id, int $a_parent_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, ?array $a_preselected_obj_ids=null)
Get all aggregated tracking data for parent object :TODO: sorting, offset, limit, objectives...
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setBold(string $a_coords)
Set cell(s) to bold.
const FILTER_DATETIME_RANGE
TableGUI class for learning progress.
setDefaultOrderField(string $a_defaultorderfield)
isPercentageAvailable(int $a_obj_id)
const FILTER_DURATION_RANGE
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
static _getLink(?int $a_ref_id, string $a_type='', array $a_params=array(), string $append="")
renderPercentages(string $id, array $data)
const EXTENDED_DATA_SPENT_SECONDS
const LP_STATUS_NOT_ATTEMPTED_NUM
static supportsSpentSeconds(string $obj_type)
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
getItemsPercentagesStatus( $data=null, int $overall=0, array $value_map=null)
Render status data as needed for summary list (based on grouped values)
static getCountryCodes()
Get country codes (DIN EN 3166-1)
static supportsMark(string $obj_type)
static _lookupType(int $id, bool $reference=false)
parseTitle(int $a_obj_id, string $action, int $a_user_id=0)
static isObjectOffline(int $a_obj_id, string $a_type='')
const LP_STATUS_COMPLETED
static getInstance(int $obj_id)
setEnableHeader(bool $a_enableheader)
setMaxCount(int $a_max_count)
set max.
const LP_STATUS_FAILED_NUM