3 declare(strict_types=1);
47 $responseBody = json_decode($responseBody,
true);
49 if (is_array($responseBody) && count($responseBody)) {
50 $this->response = $responseBody;
52 $this->response = array();
56 $this->cmixUsersByIdent[$cmixUser->getUsrIdent()] = $cmixUser;
71 if ($obj->isMixedContentType()) {
72 foreach ($this->response as $item) {
73 $userIdent = str_replace(
'mailto:',
'', $item[
'mbox']);
74 if (empty($userIdent)) {
75 $userIdent = $item[
'account'];
77 $cmixUser = $this->cmixUsersByIdent[$userIdent];
79 'user_ident' => $userIdent,
83 'score' => $item[
'score'][
'scaled'],
84 'ilias_user_id' => $cmixUser->getUsrId()
88 foreach ($this->response as $item) {
89 $userIdent = $item[
'account'];
90 $cmixUser = $this->cmixUsersByIdent[$userIdent];
92 'user_ident' => $userIdent,
96 'score' => $item[
'score'][
'scaled'],
97 'ilias_user_id' => $cmixUser->getUsrId()
101 foreach ($this->response as $item) {
102 $userIdent = str_replace(
'mailto:',
'', $item[
'mbox']);
103 $cmixUser = $this->cmixUsersByIdent[$userIdent];
105 'user_ident' => $userIdent,
109 'score' => $item[
'score'][
'scaled'],
110 'ilias_user_id' => $cmixUser->getUsrId()
114 usort(
$rows, fn (
$a,
$b):
int =>
$a[
'score'] !=
$b[
'score'] ?
$a[
'score'] >
$b[
'score'] ? -1 : 1 : 0);
121 if ($prevScore !== $item[
'score']) {
127 if (null === $this->userRank) {
129 $userIdent = str_replace(
'mailto:',
'',
$rows[
$key][
'user_ident']);
130 $cmixUser = $this->cmixUsersByIdent[$userIdent];
131 if ($cmixUser->getUsrId() == $DIC->user()->getId()) {
132 $this->userRank =
$key;
134 $rows[
$key][
'user'] = $userObj->getFullname();
143 $this->tableData = $retArr;
151 $cmixUser = $this->cmixUsersByIdent[$userIdent];
153 if ($cmixUser->getUsrId() == $DIC->user()->getId()) {
167 foreach ($allDurations as $duration) {
171 $hours = (string) floor($totalDuration / 3600);
172 $hours = strlen($hours) < 2 ?
"0" . $hours : $hours;
174 return $hours .
":" . date(
'i:s', (
int) round($totalDuration));
207 return '<pre>' . json_encode($this->response, JSON_PRETTY_PRINT) .
'</pre>';
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static getInstance(int $a_id=0, bool $a_reference=true)
static _ISODurationToCentisec(string $str)
convert ISO 8601 Timeperiods to centiseconds
static fromXapiTimestamp(string $xapiTimestamp)
static getInstance(int $a_id=0, bool $a_reference=true)
__construct(string $responseBody, int $objId)
ilCmiXapiHighscoreReport constructor.
identUser(int $userIdent)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
formatRawTimestamp(string $rawTimestamp)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
fetchTotalDuration(array $allDurations)
static _lookupType(int $id, bool $reference=false)
static getUsersForObject(int $objId, bool $asUsrId=false)