50 $this->objId =
$obj->getId();
51 $responseBody = json_decode($responseBody,
true);
53 if (count($responseBody)) {
54 $this->response = $responseBody;
56 $this->response = array();
60 $this->cmixUsersByIdent[$cmixUser->getUsrIdent()] = $cmixUser;
74 foreach ($this->response as $item) {
75 $userIdent = str_replace(
'mailto:',
'', $item[
'mbox']);
76 if (empty($userIdent)) {
77 $userIdent = $item[
'account'];
79 $cmixUser = $this->cmixUsersByIdent[$userIdent];
81 'user_ident' => $userIdent,
85 'score' => $item[
'score'][
'scaled'],
86 'ilias_user_id' => $cmixUser->getUsrId()
90 foreach ($this->response as $item) {
91 $userIdent = $item[
'account'];
92 $cmixUser = $this->cmixUsersByIdent[$userIdent];
94 'user_ident' => $userIdent,
98 'score' => $item[
'score'][
'scaled'],
99 'ilias_user_id' => $cmixUser->getUsrId()
103 foreach ($this->response as $item) {
104 $userIdent = str_replace(
'mailto:',
'', $item[
'mbox']);
105 $cmixUser = $this->cmixUsersByIdent[$userIdent];
107 'user_ident' => $userIdent,
111 'score' => $item[
'score'][
'scaled'],
112 'ilias_user_id' => $cmixUser->getUsrId()
117 return $a[
'score'] !=
$b[
'score'] ?
$a[
'score'] >
$b[
'score'] ? -1 : 1 : 0;
124 foreach (
$rows as $key => $item) {
125 if ($prevScore !== $item[
'score']) {
129 $prevScore =
$rows[$key][
'score'];
131 if (null === $this->userRank) {
133 $userIdent = str_replace(
'mailto:',
'',
$rows[$key][
'user_ident']);
134 $cmixUser = $this->cmixUsersByIdent[$userIdent];
135 if ($cmixUser->getUsrId() == $DIC->user()->getId()) {
136 $this->userRank = $key;
138 $rows[$key][
'user'] = $userObj->getFullname();
140 $retArr[$key] =
$rows[$key];
143 $rows[$key][
'user_ident'] =
false;
144 $retArr[$key] =
$rows[$key];
147 $this->tableData = $retArr;
155 $cmixUser = $this->cmixUsersByIdent[$userIdent];
157 if ($cmixUser->getUsrId() == $DIC->user()->getId()) {
167 foreach ($allDurations as $duration) {
171 $hours = floor($totalDuration / 3600);
172 $hours = strlen($hours) < 2 ?
"0" . $hours : $hours;
173 $totalDuration = $hours .
":" . date(
'i:s', $totalDuration);
175 return $totalDuration;
207 return '<pre>' . json_encode($this->response, JSON_PRETTY_PRINT) .
'</pre>';
static getUsersForObject($objId, $asUsrId=false)
__construct(string $responseBody, $obj)
ilCmiXapiHighscoreReport constructor.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
formatRawTimestamp($rawTimestamp)
fetchTotalDuration($allDurations)
static _ISODurationToCentisec($str)
convert ISO 8601 Timeperiods to centiseconds ta
static fromXapiTimestamp($xapiTimestamp)