Skip to content

Commit

Permalink
Solved Code Checker issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericgrebotasd committed Feb 29, 2024
1 parent 4579ae3 commit 708b999
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion amd/build/userbadgedisplayer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/userbadgedisplayer.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/src/userbadgedisplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define([
args: {badgeid: elem.data("id")},}
]);
promises[0].done(function(response) {
returnfunc(response);
returnfunc(JSON.parse(response));
});
/**
* Return function.
Expand Down
41 changes: 22 additions & 19 deletions externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ class local_ibob_external extends external_api {
* Get badge infos.
*
* @param int $badgeid
* @return mixed
* @return array
*/
public static function get_badge(int $badgeid) {
global $DB;
global $DB, $USER;

$sql = "SELECT *,expirationdate as expirationformateddate
FROM {local_ibob_badges}
LEFT JOIN {local_ibob_badge_issued}
ON {local_ibob_badges}.id = {local_ibob_badge_issued}.badgeid
WHERE {local_ibob_badges}.id = :id";
$mybadge = $DB->get_record_sql($sql, ["id" => $badgeid]);
$mybadge->image = mb_substr($mybadge->image, 7);
return $mybadge;
$response = ['mybadge' => $mybadge];
return json_encode($response);
}

/**
Expand All @@ -60,29 +60,32 @@ public static function get_badge(int $badgeid) {
* @return mixed
*/
public static function detail_badge_function(int $badgeid) {
$params = self::validate_parameters(self::detail_badge_function_parameters(), ['badgeid' => $badgeid]);
self::validate_parameters(self::detail_badge_function_parameters(), ['badgeid' => $badgeid]);
return self::get_badge($badgeid);
}

/**
* Badge detail function return.
*
* @return external_single_structure
* @return external_value
*/
public static function detail_badge_function_returns() {
return new external_single_structure(
[
'id' => new external_value(PARAM_INT, 'badge id'),
'name' => new external_value(PARAM_TEXT, 'badge name'),
'description' => new external_value(PARAM_TEXT, 'badge description'),
'issuername' => new external_value(PARAM_TEXT, 'badge issuer name'),
'issuerurl' => new external_value(PARAM_TEXT, 'badge issuer url'),
'issuercontact' => new external_value(PARAM_TEXT, 'badge issuer contact'),
'group' => new external_value(PARAM_INT, 'badge group'),
'image' => new external_value(PARAM_TEXT, 'badge image url'),
'expirationformateddate' => new external_value(PARAM_TEXT, 'badge expiration date'),
]
);
return new external_value(PARAM_RAW, 'Json returned');
//return new external_multiple_structure(
// return new external_single_structure(
// [
// 'id' => new external_value(PARAM_RAW, 'badge id'),
// 'name' => new external_value(PARAM_RAW, 'badge name'),
// 'description' => new external_value(PARAM_RAW, 'badge description'),
// 'issuername' => new external_value(PARAM_RAW, 'badge issuer name'),
// 'issuerurl' => new external_value(PARAM_RAW, 'badge issuer url'),
// 'issuercontact' => new external_value(PARAM_RAW, 'badge issuer contact'),
// 'group' => new external_value(PARAM_RAW, 'badge group'),
// 'image' => new external_value(PARAM_RAW, 'badge image url'),
// 'expirationformateddate' => new external_value(PARAM_RAW, 'badge expiration date'),
// ]
//)
//);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions templates/userbadgedisplayer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
]
}
}}
{{#mybadge}}
<div class="ibob-modal">
<div class="image-wrapper"><img src="{{ image }}" alt="badge - {{ name }}" class="img-responsive"></div>
<div class="ibob-modal-detail">
Expand All @@ -51,3 +52,4 @@
</div>
</div>
</div>
{{/mybadge}}

0 comments on commit 708b999

Please sign in to comment.