Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$consumer->toolProxy is not correctly decoded by DataConnector classes #1

Open
dac514 opened this issue May 3, 2018 · 2 comments
Open

Comments

@dac514
Copy link
Collaborator

dac514 commented May 3, 2018

I'm using your fork for an LTI Provider plugin i'm working on. Thanks for all your fixes and composer support. Very nice.

I need access to $consumer->toolProxy. In my database, AFAIK, lti2_consumer.tool_proxy is stored as a JSON string just like lti2_consumer.profile. Everywhere I see >toolProxy = I see:

$consumer->profile = json_decode($row['profile']);
$consumer->toolProxy = $row['tool_proxy'];

(Seen in: ToolProvider/DataConnector/DataConnector_mysql.php and ToolProvider/DataConnector/DataConnector_pdo.php)

One is coverted into an object, the other is not. I think it should be:

$consumer->profile = json_decode($row['profile']);
$consumer->toolProxy = json_decode($row['tool_proxy']);

Or maybe something like:

function isJson($string) {
 json_decode($string);
 return (json_last_error() == JSON_ERROR_NONE);
}
// ... snip ...
$consumer->profile = isJson( $row['profile'] ) ? json_decode( $row['profile'] ) : $row['profile'];
$consumer->toolProxy = isJson( $row['tool_proxy'] ) ? json_decode( $row['tool_proxy'] ) : $row['tool_proxy'];

What do you think?

PS: $consumer->toolProxy is declared dynamically. No stub in ToolProvider/ToolConsumer.php. This makes it harder to code because my IDE doesn't recognize that field. It would be nice to add it.

@Izumi-kun
Copy link
Owner

Whole project requires huge refactoring. Lot of classes not written completely and not used properly.

For example,

  • toolProxy must be instance of \IMSGlobal\LTI\ToolProvider\MediaType\ToolProxy
  • profile -> \IMSGlobal\LTI\ToolProvider\MediaType\ToolProfile
  • \IMSGlobal\LTI\ToolProvider\MediaType\ToolProfile::$service_offered is array of \IMSGlobal\LTI\Profile\ServiceDefinition
  • etc

I hope that this job can be done by me. But not soon because of free time deficit.

@dac514
Copy link
Collaborator Author

dac514 commented May 4, 2018

Thanks for the response. A thorough refactoring would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants