25 final public const URL_DISPLAYER =
"https://backpack.openbadges.org/displayer/";
27 private readonly \ilGlobalTemplateInterface
$main_tpl;
32 $this->main_tpl = $DIC->ui()->mainTemplate();
38 self::URL_DISPLAYER .
"convert/email",
39 array(
"email" => $this->email),
43 if (!isset($json->status) ||
44 $json->status !==
"okay") {
48 $this->uid = $json->userId;
56 self::URL_DISPLAYER . $this->uid .
"/groups.json" 61 foreach ($json->groups as $group) {
62 $result[$group->groupId] = array(
63 "title" => $group->name,
64 "size" => $group->badges
73 public function getBadges(
string $a_group_id): ?array
77 self::URL_DISPLAYER . $this->uid .
"/group/" . $a_group_id .
".json" 84 if (property_exists($json,
'status') && $json->status ===
"missing") {
90 foreach ($json->badges as $raw) {
91 $badge = $raw->assertion->badge;
94 $issued_on = is_numeric($raw->assertion->issued_on)
95 ? $raw->assertion->issued_on
96 : strtotime($raw->assertion->issued_on);
99 "title" => $badge->name,
100 "description" => $badge->description,
101 "image_url" => $badge->image,
102 "image_rid" => $badge->image_rid,
103 "criteria_url" => $badge->criteria,
104 "issuer_name" => $badge->issuer->name,
105 "issuer_url" => $badge->issuer->origin,
117 array $a_param = array(),
118 bool $a_is_post =
false 124 $curl->setOpt(CURLOPT_FRESH_CONNECT,
true);
125 $curl->setOpt(CURLOPT_RETURNTRANSFER,
true);
126 $curl->setOpt(CURLOPT_FORBID_REUSE,
true);
127 $curl->setOpt(CURLOPT_HEADER, 0);
128 $curl->setOpt(CURLOPT_CONNECTTIMEOUT, 3);
129 $curl->setOpt(CURLOPT_POSTREDIR, 3);
132 $curl->setOpt(CURLOPT_SSL_VERIFYPEER,
false);
134 $curl->setOpt(CURLOPT_HTTPHEADER, array(
135 "Accept: application/json",
140 $curl->setOpt(CURLOPT_POST, 1);
141 if (count($a_param)) {
142 $curl->setOpt(CURLOPT_POSTFIELDS, http_build_query($a_param));
145 $curl->setOpt(CURLOPT_HTTPGET, 1);
146 if (count($a_param)) {
147 $a_url .= (!str_contains($a_url,
"?") ?
"?" :
"") . http_build_query($a_param);
150 $curl->setOpt(CURLOPT_URL, $a_url);
152 $answer = $curl->exec();
154 $this->main_tpl->setOnScreenMessage(
'failure', $ex->getMessage());
158 return json_decode($answer,
false, 512, JSON_THROW_ON_ERROR);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
sendRequest(string $a_url, array $a_param=array(), bool $a_is_post=false)
final const URL_DISPLAYER
getBadges(string $a_group_id)
__construct(protected string $email)
readonly ilGlobalTemplateInterface $main_tpl