-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.2.6, 4.3.3, 4.4
-
MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE
-
MDL-81103-main
-
-
2
-
Moppies PB candidates
Steps to reproduce
- Login as admin.
- Go to Site administration > Badges > Manage backpacks.
- Edit the backpack "https://badgr.io".
- Set the "Backpack API URL" from https://api.badgr.io/v2 to https://api.badgr.io/bcv1/ims/ob/v2p
- Create a badge, enable it and award it to the admin user.
- Go to the user preferences and click "Backpack settings" in the Badges section.
- Connect to your backpack in Badgr.com using a valid email. You'll need to confirm the email account (so your Moodle site must be configured to send emails).
- Open the email client and click the Verify email button that you'll find in the email that has been sent with the subject: "Badges backpack email verification".
- Go to your profile and access the badge you were awarded.
- Click the Add to backpack button.
Expected behaviour
The badge is sent to your backpack and a confirmation notification is displayed.
Current behaviour
The following error is displayed: "count(): Argument #1 ($value) must be of type Countable|array, stdClass given"
badges/classes/backpack_api_mapping.php around line 383:
$response = json_decode($response);
|
if (isset($response->result)) { |
$response = $response->result;
|
}
|
$context = context_system::instance();
|
$exporter = $this->responseexporter; |
if (class_exists($exporter)) { |
$output = $PAGE->get_renderer('core', 'badges'); |
if (!$this->multiple) { |
if (count($response)) { |
$response = $response[0]; |
}
|
if (empty($response)) { |
return null; |
}
|
$apidata = $exporter::map_external_data($response, $this->backpackapiversion); |
$exporterinstance = new $exporter($apidata, ['context' => $context]); |
$data = $exporterinstance->export($output);
|
return $data; |
This is the content of $response in that case:
- timestamp: "2024-03-01T11:19:51.954+00:00",
- status: 405
- error: "Method Not Allowed"
- message: "Request method 'POST' not supported"
- path: "/bcv1/ims/ob/v2p/backpack/import"
- traceId: "04acd2e5-05c1-46d8-afbf-a70c1e87c196"
The existing code should be improved to give more information to users to help them to figure out why the badge can't be added to the backpack.
- has a non-specific relationship to
-
MDLSITE-7931 Badges backpack (Open Badges 2.0) no longer connects since latest minor release
-
- Resolved
-
- has been marked as being related by
-
MDL-79303 Error "Argument #1 ($value) must be of type Countable|array, stdClass given" when accessing to user profile with external badges
-
- Closed
-
- is duplicated by
-
MDL-81270 Error when attempting to display user's badges at their profile page
-
- Closed
-
- will be (partly) resolved by
-
MDLSITE-7921 count(): Argument error viewing My Profile on Moodle.org
-
- Resolved
-
-
MDLSITE-7752 Badges on removed Moodles sites share on external backpacks can break profile pages
-
- Resolved
-