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

I need to insert geo coordinates inside context #33

Open
uest555 opened this issue Jan 19, 2018 · 5 comments
Open

I need to insert geo coordinates inside context #33

uest555 opened this issue Jan 19, 2018 · 5 comments

Comments

@uest555
Copy link

uest555 commented Jan 19, 2018

Hi,
I'm trying to insert gps positions as Extensions into Context Object.
When I call the object i can't find how to insert the values.

This is the code I use to write a context part in the statement


var objContext = new Context();
objContext.extensions = new TinCan.Extensions();

how can now insert the user gps positions?

"http://id.tincanapi.com/extension/latitude" = userLatCoord;
"http://id.tincanapi.com/extension/longitude" = userLongCoord;


Thanks in advance...

Andrea

@brianjmiller
Copy link
Member

brianjmiller commented Jan 19, 2018

Unfortunately there is not currently an interface for adjusting the extensions map on existing objects. This is definitely an oversight in the API. For now I think you would have to work around this by passing the full list of extension properties during construction of the object. You can pass it a JObject. To edit you'd have to grab an existing JObject via the ToJObject method, edit that directly, create a new object and then store it back to your Context (not ideal I realize).

The TinCanJava object that is effectively the same has added an interface for manipulating the Extensions object, you can see it starting here:

https://github.com/RusticiSoftware/TinCanJava/blob/master/src/main/java/com/rusticisoftware/tincan/Extensions.java#L63

When we get around to adding this interface to TinCan.NET it will very likely look the same. If you want to do that and submit a clean PR (IOW no extraneous changes to the .proj, etc.) then it will eventually get included. I can't give a timeframe on review+merge.

@uest555
Copy link
Author

uest555 commented Jan 19, 2018 via email

@valdeezzee
Copy link

@brianjmiller @uest555
Hi. Was there ever a solution to this?

I have been trying to add extensions to my statements without any luck.

I did this:
statement.result.extensions = new TinCan.Extensions();
It created an empty array.

To add to the extension, I tried what @brianjmiller suggested.
I did this:

JObject extensionsObject = new JObject();
extensionsObject.Add("http://id.tincanapi.com/extension/duration", value);
statement.result.extensions = new TinCan.Extensions(extensionsObject);

Doing the above I get this error:
The type 'JObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.

It seems that it is looking for a different version of Newtonson.Json. I've been looking around but it seems that it does not exist.

Any help would be great. Thanks.

@valdeezzee
Copy link

valdeezzee commented Aug 19, 2020

Nevermind. I realized I was using an older version of Newtonsoft.Json. I updated it and it worked perfectly.

@uest555 I know this is a very old post but this worked for editing your extensions.

JObject extensionsObject = new JObject();
extensionsObject.Add("http://id.tincanapi.com/extension/duration", value);
statement.result.extensions = new TinCan.Extensions(extensionsObject);

@uest555
Copy link
Author

uest555 commented Aug 19, 2020 via email

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

No branches or pull requests

3 participants