Skip to content

Commit

Permalink
Insure the type in the lineitem creation JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Nov 14, 2024
1 parent 8b6a2ae commit 973a04c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vendor/tsugi/lib/src/Util/LTI13.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,11 @@ public static function deleteLineItem($lineitem_url, $access_token, &$debug_log=
* @return mixed If this works it returns an array including the new line item url. If it fails, it returns a string.
*/
public static function createLineItem($lineitems_url, $access_token, $lineitem, &$debug_log = false) {
$scoreMaximum = $lineitem->scoreMaximum ?? 100;
$lineitem->scoreMaximum = is_numeric($scoreMaximum) ? floatval($scoreMaximum) : 100;
$lineitem->scoreMaximum = floatval($lineitem->scoreMaximum);
if ( ! is_string($lineitem->label ?? null) ) $lineitem->label = strval($lineitem->label ?? null);
if ( ! is_string($lineitem->resourceId ?? null) ) $lineitem->resourceId = strval($lineitem->resourceId ?? null);

$lineitems_url = trim($lineitems_url);

Expand Down

0 comments on commit 973a04c

Please sign in to comment.