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;
75 foreach ($this->response as $item) {
76 $userIdent = str_replace(
'mailto:',
'', $item[
'mbox']);
77 if (empty($userIdent))
79 $userIdent = $item[
'account'];
81 $cmixUser = $this->cmixUsersByIdent[$userIdent];
83 'user_ident' => $userIdent,
87 'score' => $item[
'score'][
'scaled'],
88 'ilias_user_id' => $cmixUser->getUsrId()
94 foreach ($this->response as $item) {
95 $userIdent = $item[
'account'];
96 $cmixUser = $this->cmixUsersByIdent[$userIdent];
98 'user_ident' => $userIdent,
102 'score' => $item[
'score'][
'scaled'],
103 'ilias_user_id' => $cmixUser->getUsrId()
109 foreach ($this->response as $item) {
110 $userIdent = str_replace(
'mailto:',
'', $item[
'mbox']);
111 $cmixUser = $this->cmixUsersByIdent[$userIdent];
113 'user_ident' => $userIdent,
117 'score' => $item[
'score'][
'scaled'],
118 'ilias_user_id' => $cmixUser->getUsrId()
123 return $a[
'score'] !=
$b[
'score'] ?
$a[
'score'] >
$b[
'score'] ? -1 : 1 : 0;
130 foreach (
$rows as $key => $item) {
131 if ($prevScore !== $item[
'score']) {
135 $prevScore =
$rows[$key][
'score'];
137 if (null === $this->userRank) {
139 $userIdent = str_replace(
'mailto:',
'',
$rows[$key][
'user_ident']);
140 $cmixUser = $this->cmixUsersByIdent[$userIdent];
141 if ($cmixUser->getUsrId() == $DIC->user()->getId()) {
142 $this->userRank = $key;
144 $rows[$key][
'user'] = $userObj->getFullname();
146 $retArr[$key] =
$rows[$key];
149 $rows[$key][
'user_ident'] =
false;
150 $retArr[$key] =
$rows[$key];
153 $this->tableData = $retArr;
161 $cmixUser = $this->cmixUsersByIdent[$userIdent];
163 if ($cmixUser->getUsrId() == $DIC->user()->getId()) {
173 foreach ($allDurations as $duration) {
177 $hours = floor($totalDuration / 3600);
178 $hours = strlen($hours) < 2 ?
"0" . $hours : $hours;
179 $totalDuration = $hours .
":" . date(
'i:s', $totalDuration);
181 return $totalDuration;
213 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)