This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
More...
|
const | URL_DISPLAYER = "https://backpack.openbadges.org/displayer/" |
|
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilBadgeBackpack
- Author
- Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Definition at line 23 of file class.ilBadgeBackpack.php.
◆ __construct()
ilBadgeBackpack::__construct |
( |
string |
$a_email | ) |
|
◆ authenticate()
ilBadgeBackpack::authenticate |
( |
| ) |
|
|
protected |
Definition at line 38 of file class.ilBadgeBackpack.php.
References sendRequest().
Referenced by getBadges(), and getGroups().
41 self::URL_DISPLAYER .
"convert/email",
42 array(
"email" => $this->email),
46 if (!isset($json->status) ||
47 $json->status !==
"okay") {
51 $this->uid = $json->userId;
sendRequest(string $a_url, array $a_param=array(), bool $a_is_post=false)
◆ getBadges()
ilBadgeBackpack::getBadges |
( |
string |
$a_group_id | ) |
|
Definition at line 76 of file class.ilBadgeBackpack.php.
References authenticate(), IL_CAL_UNIX, and sendRequest().
80 self::URL_DISPLAYER . $this->uid .
"/group/" . $a_group_id .
".json" 87 if (property_exists($json,
'status') && $json->status ===
"missing") {
93 foreach ($json->badges as $raw) {
94 $badge = $raw->assertion->badge;
97 $issued_on = is_numeric($raw->assertion->issued_on)
98 ? $raw->assertion->issued_on
99 : strtotime($raw->assertion->issued_on);
102 "title" => $badge->name,
103 "description" => $badge->description,
104 "image_url" => $badge->image,
105 "criteria_url" => $badge->criteria,
106 "issuer_name" => $badge->issuer->name,
107 "issuer_url" => $badge->issuer->origin,
sendRequest(string $a_url, array $a_param=array(), bool $a_is_post=false)
◆ getGroups()
ilBadgeBackpack::getGroups |
( |
| ) |
|
Definition at line 55 of file class.ilBadgeBackpack.php.
References authenticate(), and sendRequest().
59 self::URL_DISPLAYER . $this->uid .
"/groups.json" 64 foreach ($json->groups as $group) {
65 $result[$group->groupId] = array(
66 "title" => $group->name,
67 "size" => $group->badges
sendRequest(string $a_url, array $a_param=array(), bool $a_is_post=false)
◆ sendRequest()
ilBadgeBackpack::sendRequest |
( |
string |
$a_url, |
|
|
array |
$a_param = array() , |
|
|
bool |
$a_is_post = false |
|
) |
| |
|
protected |
Definition at line 117 of file class.ilBadgeBackpack.php.
Referenced by authenticate(), getBadges(), and getGroups().
126 $curl->setOpt(CURLOPT_FRESH_CONNECT,
true);
127 $curl->setOpt(CURLOPT_RETURNTRANSFER,
true);
128 $curl->setOpt(CURLOPT_FORBID_REUSE,
true);
129 $curl->setOpt(CURLOPT_HEADER, 0);
130 $curl->setOpt(CURLOPT_CONNECTTIMEOUT, 3);
131 $curl->setOpt(CURLOPT_POSTREDIR, 3);
134 $curl->setOpt(CURLOPT_SSL_VERIFYPEER,
false);
136 $curl->setOpt(CURLOPT_HTTPHEADER, array(
137 "Accept: application/json",
142 $curl->setOpt(CURLOPT_POST, 1);
143 if (count($a_param)) {
144 $curl->setOpt(CURLOPT_POSTFIELDS, http_build_query($a_param));
147 $curl->setOpt(CURLOPT_HTTPGET, 1);
148 if (count($a_param)) {
149 $a_url .= (strpos($a_url,
"?") ===
false ?
"?" :
"") . http_build_query($a_param);
152 $curl->setOpt(CURLOPT_URL, $a_url);
154 $answer = $curl->exec();
156 $this->main_tpl->setOnScreenMessage(
'failure', $ex->getMessage());
160 return json_decode($answer,
false, 512, JSON_THROW_ON_ERROR);
◆ $email
string ilBadgeBackpack::$email |
|
protected |
◆ $main_tpl
◆ $uid
int ilBadgeBackpack::$uid |
|
protected |
◆ URL_DISPLAYER
const ilBadgeBackpack::URL_DISPLAYER = "https://backpack.openbadges.org/displayer/" |
The documentation for this class was generated from the following file: